forked from ZhymabekRoman/Exagear-For-Termux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart-exagear.sh
executable file
·571 lines (516 loc) · 19.2 KB
/
start-exagear.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
#!/bin/bash
##
## Script for managing Exagear'ed Linux distribution installations/running in Termux.
## by Zhymabek Roman
##
## Some pieces of code taken from proot-distro: https://github.com/termux/proot-distro
# Constants
PROGRAM_NAME="ExaGear for Termux"
PROGRAM_VERSION="2.4"
CURRENT_WORK_FOLDER=$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)
DEFAULT_ROOTFS_FOLDER="exagear-fs/"
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
# Enable bash strict mode
set -euo pipefail
# Check whether it is running, in the root or normal environment.
if [ "$(id -u)" = "0" ] && [ "$(uname -o)" = "Android" ]; then
echo
echo -e "${RED}Error: '${PROGRAM_NAME}' should not be used as root.${NC}"
echo
exit 1
fi
arch=$(dpkg --print-architecture)
if ! [[ $arch == arm* ]] && ! [[ $arch = aarch64 ]]; then
echo
echo -e "${RED}Error: Exagear can only be started on systems with arm processors.${NC}"
echo
exit 1
fi
# Check memory configuration
if ./bin/test-memory-available 0xa0000000 ; then
MEMORY_BITS="3g"
else
MEMORY_BITS="2g"
fi
function print_welcome_message {
echo -e "
░█░█░█▀█░█▀▄░█▀█
░░▀█░█▀▀░█░█░█▀█
░░░▀░▀░░░▀▀░░▀░▀
"
echo "${PROGRAM_NAME} by Zhymabek_Roman"
echo "Version: ${PROGRAM_VERSION}"
echo -e "Copyright (c) 2013-2019 'Elbrus Technologies' LLC. All rights reserved.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
echo -e "\n"
}
function print_usage_and_exit {
echo 'Usage: ./start-exagear.sh'
exit 0
}
function generate_proot_env_exec_cmd {
local rootfs_path="${CURRENT_WORK_FOLDER}/${1}"
local make_host_tmp_shared="$2"
if [ "$MEMORY_BITS" = '3g' ]; then
exagear_command="./bin/ubt_x32a32_al_mem3g"
elif [ "$MEMORY_BITS" = '2g' ]; then
exagear_command="./bin/ubt_x32a32_al_mem2g"
fi
exagear_command+=" --path-prefix "$rootfs_path""
exagear_command+=" --vfs-hacks=tlsasws,tsi,spd"
exagear_command+=" --vfs-kind guest-first"
exagear_command+=" --vpaths-list "$CURRENT_WORK_FOLDER"/bin/vpaths-list"
exagear_command+=" --tmp-dir "$rootfs_path"/tmp"
exagear_command+=" -- /usr/bin/env -i
USER=root
HOME=/root
PATH=/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr
LANG=en_US.utf8
LANGUAGE=en_US.utf8
LC_ALL=C
BASH=/bin/bash
SHELL=/bin/bash
PREFIX=/usr
TERM=xterm
TMDIR=/tmp
LD_LIBRARY_PATH=/lib:/usr/lib:/usr/lib/i386-linux-gnu/:/var/lib:/var/lib/dpkg/:/lib/i386-linux-gnu:/usr/local/lib/"
exagear_command+=" /bin/bash --login "
exec_cmd="${exagear_command}"
}
function generate_termux_env_exec_cmd {
local rootfs_path="$1"
local make_host_tmp_shared="$2"
if [ "$MEMORY_BITS" = '3g' ]; then
exagear_command="/bin/ubt_x32a32_al_mem3g"
elif [ "$MEMORY_BITS" = '2g' ]; then
exagear_command="/bin/ubt_x32a32_al_mem2g"
fi
exagear_command+=" --path-prefix /"$rootfs_path""
exagear_command+=" --vfs-hacks=tlsasws,tsi,spd"
exagear_command+=" --vfs-kind guest-first"
exagear_command+=" --vpaths-list /bin/vpaths-list"
exagear_command+=" --tmp-dir /"$rootfs_path"/tmp"
exagear_command+=" -- /usr/bin/env -i
USER=root
HOME=/root
PATH=/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr
LANG=en_US.utf8
LANGUAGE=en_US.utf8
LC_ALL=C
BASH=/bin/bash
SHELL=/bin/bash
PREFIX=/usr
TERM=xterm
TMDIR=/tmp
LD_LIBRARY_PATH=/lib:/usr/lib:/usr/lib/i386-linux-gnu/:/var/lib:/var/lib/dpkg/:/lib/i386-linux-gnu:/usr/local/lib/"
exagear_command+=" /bin/bash --login "
proot_command="$CURRENT_WORK_FOLDER/bin/proot-static/proot_static"
proot_command+=" -0"
proot_command+=" --link2symlink"
proot_command+=" -r $CURRENT_WORK_FOLDER/"
proot_command+=" -L"
proot_command+=" --sysvipc"
proot_command+=" --kill-on-exit"
proot_command+=" --kernel-release=5.4.0-fake-kernel"
proot_command+=" -b /sys"
proot_command+=" -b /proc"
proot_command+=" -b /dev"
proot_command+=" -b /storage"
proot_command+=" -b $rootfs_path/sys/fs/selinux/:/sys/fs/selinux"
proot_command+=" -b $rootfs_path/tmp/:/dev/shm/"
proot_command+=" -b /dev/urandom:/dev/random"
proot_command+=" -w /"
proot_command+=" -b $rootfs_path/proc/.stat:/proc/stat"
proot_command+=" -b $rootfs_path/proc/.loadavg:/proc/loadavg"
proot_command+=" -b $rootfs_path/proc/.uptime:/proc/uptime"
proot_command+=" -b $rootfs_path/proc/.version:/proc/version"
proot_command+=" -b $rootfs_path/proc/.vmstat:/proc/vmstat"
if $make_host_tmp_shared; then
proot_command+=" -b $PREFIX/tmp/:/tmp/"
fi
exec_cmd="${proot_command} ${exagear_command}"
}
function generate_termux_old_env_exec_cmd {
local rootfs_path="${CURRENT_WORK_FOLDER}/${1}"
local make_host_tmp_shared="$2"
if [ "$MEMORY_BITS" = '3g' ]; then
exagear_command="./bin/ubt_x32a32_al_mem3g"
elif [ "$MEMORY_BITS" = '2g' ]; then
exagear_command="./bin/ubt_x32a32_al_mem2g"
fi
exagear_command+=" --path-prefix "$rootfs_path""
exagear_command+=" --vfs-hacks=tlsasws,tsi,spd"
exagear_command+=" --vfs-kind guest-first"
exagear_command+=" --vpaths-list "$CURRENT_WORK_FOLDER"/bin/vpaths-list-old"
exagear_command+=" --tmp-dir "$rootfs_path"/tmp"
exagear_command+=" -- /usr/bin/env -i
USER=root
HOME=/root
PATH=/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr
LANG=en_US.utf8
LANGUAGE=en_US.utf8
LC_ALL=C
BASH=/bin/bash
SHELL=/bin/bash
PREFIX=/usr
TERM=xterm
TMDIR=/tmp
LD_LIBRARY_PATH=/lib:/usr/lib:/usr/lib/i386-linux-gnu/:/var/lib:/var/lib/dpkg/:/lib/i386-linux-gnu:/usr/local/lib/"
exagear_command+=" /bin/bash --login "
proot_command="$CURRENT_WORK_FOLDER/bin/proot-static/proot_static"
proot_command+=" -0"
proot_command+=" --link2symlink"
proot_command+=" -L"
proot_command+=" --sysvipc"
proot_command+=" --kill-on-exit"
proot_command+=" --kernel-release=5.4.0-fake-kernel"
proot_command+=" -b /sys:"$rootfs_path"/sys"
proot_command+=" -b /proc:"$rootfs_path"/proc"
proot_command+=" -b /dev:"$rootfs_path"/dev"
proot_command+=" -b /storage:"$rootfs_path"/storage"
proot_command+=" -b "$rootfs_path"/sys/fs/selinux/"
proot_command+=" -b "$rootfs_path"/tmp:"$rootfs_path"/dev/shm"
proot_command+=" -b /dev/urandom:/dev/random"
proot_command+=" -b "$rootfs_path"/proc/.stat:"$rootfs_path"/proc/stat"
proot_command+=" -b "$rootfs_path"/proc/.loadavg:"$rootfs_path"/proc/loadavg"
proot_command+=" -b "$rootfs_path"/proc/.uptime:"$rootfs_path"/proc/uptime"
proot_command+=" -b "$rootfs_path"/proc/.version:"$rootfs_path"/proc/version"
proot_command+=" -b "$rootfs_path"/proc/.vmstat:"$rootfs_path"/proc/vmstat"
if $make_host_tmp_shared; then
proot_command+=" -b $PREFIX/tmp/:"$rootfs_path"/tmp/"
fi
exec_cmd="${proot_command} ${exagear_command}"
}
function edit_passwd
{
local rootfs_path="$1"
cat <<- EOF > ""$rootfs_path"/etc/passwd"
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-timesync:x:100:102:systemd Time Synchronization,,,:/run/systemd:/bin/false
systemd-network:x:101:103:systemd Network Management,,,:/run/systemd/netif:/bin/false
systemd-resolve:x:102:104:systemd Resolver,,,:/run/systemd/resolve:/bin/false
systemd-bus-proxy:x:103:105:systemd Bus Proxy,,,:/run/systemd:/bin/false
syslog:x:104:108::/home/syslog:/bin/false
_apt:x:105:65534::/nonexistent:/bin/false
messagebus:x:106:110::/var/run/dbus:/bin/false
pulse:x:107:112:PulseAudio daemon,,,:/var/run/pulse:/bin/false
rtkit:x:108:114:RealtimeKit,,,:/proc:/bin/false
EOF
}
function setup_fake_proc
{
local rootfs_path="$1"
mkdir -p ""$rootfs_path"/proc"
chmod 700 ""$rootfs_path"/proc"
mkdir -p ""$rootfs_path"/sys/fs/selinux/"
if [ ! -f ""$rootfs_path"/sys/fs/selinux/enforce" ]; then
cat <<- EOF > ""$rootfs_path"/sys/fs/selinux/enforce"
0
EOF
fi
if [ ! -f ""$rootfs_path"/proc/.loadavg" ]; then
cat <<- EOF > ""$rootfs_path"/proc/.loadavg"
0.54 0.41 0.30 1/931 370386
EOF
fi
if [ ! -f ""$rootfs_path"/proc/.stat" ]; then
cat <<- EOF > ""$rootfs_path"/proc/.stat"
cpu 1050008 127632 898432 43828767 37203 63 99244 0 0 0
cpu0 212383 20476 204704 8389202 7253 42 12597 0 0 0
cpu1 224452 24947 215570 8372502 8135 4 42768 0 0 0
cpu2 222993 17440 200925 8424262 8069 9 17732 0 0 0
cpu3 186835 8775 195974 8486330 5746 3 8360 0 0 0
cpu4 107075 32886 48854 8688521 3995 4 5758 0 0 0
cpu5 90733 20914 27798 1429573 2984 1 11419 0 0 0
intr 53261351 0 686 1 0 0 1 12 31 1 20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7818 0 0 0 0 0 0 0 0 255 33 1912 33 0 0 0 0 0 0 3449534 2315885 2150546 2399277 696281 339300 22642 19371 0 0 0 0 0 0 0 0 0 0 0 2199 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2445 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 162240 14293 2858 0 151709 151592 0 0 0 284534 0 0 0 0 0 0 0 0 0 0 0 0 0 0 185353 0 0 938962 0 0 0 0 736100 0 0 1 1209 27960 0 0 0 0 0 0 0 0 303 115968 452839 2 0 0 0 0 0 0 0 0 0 0 0 0 0 160361 8835 86413 1292 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3592 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6091 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 35667 0 0 156823 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 138 2667417 0 41 4008 952 16633 533480 0 0 0 0 0 0 262506 0 0 0 0 0 0 126 0 0 1558488 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 8 0 0 6 0 0 0 10 3 4 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 1 1 83806 0 1 1 0 1 0 1 1 319686 2 8 0 0 0 0 0 0 0 0 0 244534 0 1 10 9 0 10 112 107 40 221 0 0 0 144
ctxt 90182396
btime 1595203295
processes 270853
procs_running 2
procs_blocked 0
softirq 25293348 2883 7658936 40779 539155 497187 2864 1908702 7229194 279723 7133925
EOF
fi
if [ ! -f ""$rootfs_path"/proc/.uptime" ]; then
cat <<- EOF > ""$rootfs_path"/proc/.uptime"
284684.56 513853.46
EOF
fi
if [ ! -f ""$rootfs_path"/proc/.version" ]; then
cat <<- EOF > ""$rootfs_path"/proc/.version"
Linux version 5.4.0-faked (termux@androidos) (gcc version 4.9.x (Faked /proc/version by Exagear-For-Termux) ) #1 SMP PREEMPT Fri Jul 10 00:00:00 UTC 2020
EOF
fi
if [ ! -f ""$rootfs_path"/proc/.vmstat" ]; then
cat <<- EOF > ""$rootfs_path"/proc/.vmstat"
nr_free_pages 146031
nr_zone_inactive_anon 196744
nr_zone_active_anon 301503
nr_zone_inactive_file 2457066
nr_zone_active_file 729742
nr_zone_unevictable 164
nr_zone_write_pending 8
nr_mlock 34
nr_page_table_pages 6925
nr_kernel_stack 13216
nr_bounce 0
nr_zspages 0
nr_free_cma 0
numa_hit 672391199
numa_miss 0
numa_foreign 0
numa_interleave 62816
numa_local 672391199
numa_other 0
nr_inactive_anon 196744
nr_active_anon 301503
nr_inactive_file 2457066
nr_active_file 729742
nr_unevictable 164
nr_slab_reclaimable 132891
nr_slab_unreclaimable 38582
nr_isolated_anon 0
nr_isolated_file 0
workingset_nodes 25623
workingset_refault 46689297
workingset_activate 4043141
workingset_restore 413848
workingset_nodereclaim 35082
nr_anon_pages 599893
nr_mapped 136339
nr_file_pages 3086333
nr_dirty 8
nr_writeback 0
nr_writeback_temp 0
nr_shmem 13743
nr_shmem_hugepages 0
nr_shmem_pmdmapped 0
nr_file_hugepages 0
nr_file_pmdmapped 0
nr_anon_transparent_hugepages 57
nr_unstable 0
nr_vmscan_write 57250
nr_vmscan_immediate_reclaim 2673
nr_dirtied 79585373
nr_written 72662315
nr_kernel_misc_reclaimable 0
nr_dirty_threshold 657954
nr_dirty_background_threshold 328575
pgpgin 372097889
pgpgout 296950969
pswpin 14675
pswpout 59294
pgalloc_dma 4
pgalloc_dma32 101793210
pgalloc_normal 614157703
pgalloc_movable 0
allocstall_dma 0
allocstall_dma32 0
allocstall_normal 184
allocstall_movable 239
pgskip_dma 0
pgskip_dma32 0
pgskip_normal 0
pgskip_movable 0
pgfree 716918803
pgactivate 68768195
pgdeactivate 7278211
pglazyfree 1398441
pgfault 491284262
pgmajfault 86567
pglazyfreed 1000581
pgrefill 7551461
pgsteal_kswapd 130545619
pgsteal_direct 205772
pgscan_kswapd 131219641
pgscan_direct 207173
pgscan_direct_throttle 0
zone_reclaim_failed 0
pginodesteal 8055
slabs_scanned 9977903
kswapd_inodesteal 13337022
kswapd_low_wmark_hit_quickly 33796
kswapd_high_wmark_hit_quickly 3948
pageoutrun 43580
pgrotated 200299
drop_pagecache 0
drop_slab 0
oom_kill 0
numa_pte_updates 0
numa_huge_pte_updates 0
numa_hint_faults 0
numa_hint_faults_local 0
numa_pages_migrated 0
pgmigrate_success 768502
pgmigrate_fail 1670
compact_migrate_scanned 1288646
compact_free_scanned 44388226
compact_isolated 1575815
compact_stall 863
compact_fail 392
compact_success 471
compact_daemon_wake 975
compact_daemon_migrate_scanned 613634
compact_daemon_free_scanned 26884944
htlb_buddy_alloc_success 0
htlb_buddy_alloc_fail 0
unevictable_pgs_culled 258910
unevictable_pgs_scanned 3690
unevictable_pgs_rescued 200643
unevictable_pgs_mlocked 199204
unevictable_pgs_munlocked 199164
unevictable_pgs_cleared 6
unevictable_pgs_stranded 6
thp_fault_alloc 10655
thp_fault_fallback 130
thp_collapse_alloc 655
thp_collapse_alloc_failed 50
thp_file_alloc 0
thp_file_mapped 0
thp_split_page 612
thp_split_page_failed 0
thp_deferred_split_page 11238
thp_split_pmd 632
thp_split_pud 0
thp_zero_page_alloc 2
thp_zero_page_alloc_failed 0
thp_swpout 4
thp_swpout_fallback 0
balloon_inflate 0
balloon_deflate 0
balloon_migrate 0
swap_ra 9661
swap_ra_hit 7872
EOF
fi
}
function start_guest {
local rootfs_path=$DEFAULT_ROOTFS_FOLDER
local make_host_tmp_shared=false
local old_termux_exec_cmd=false
local exec_cmd="None"
while (($# >= 1)); do
case "$1" in
--)
shift 1
break
;;
--shared-tmp)
make_host_tmp_shared=true
;;
--old)
old_termux_exec_cmd=true
;;
*)
echo "Error: unknown parameter: '$1'"
exit 1
;;
esac
shift 1
done
chmod +x "$CURRENT_WORK_FOLDER"/bin/ubt_x32a32_al_mem2g "$CURRENT_WORK_FOLDER"/bin/ubt_x32a32_al_mem3g "$CURRENT_WORK_FOLDER"/bin/test-memory-available
# Check the integrity of the guest system
if [ ! -d "$rootfs_path"/bin/ ]; then
echo -e "Folder 'bin' in guest system not found. The guest system is likely damaged\n"
exit
fi
case `cat "$rootfs_path"/etc/passwd` in
xdroid:x:*:*::/home/xdroid/:/bin/sh)
echo -e "ExaGear Windows/RPG/Strategy's rootfs system detected. Editing passwd for better compatibility\n"
edit_passwd "$rootfs_path" ;;
"")
echo "'passwd' file in guest system not found. Exiting"
exit 1 ;;
esac
# unset LD_PRELOAD in case termux-exec is installed
# We need this to disable the preloaded libtermux-exec.so library
# which redefines 'execve()' implementation.
unset LD_PRELOAD
# /etc/resolv.conf and /etc/hosts may not be configured, so write in it our configuraton.
echo -e "Writing resolv.conf file (NS 8.8.8.8/8.8.4.4)...\n"
echo "127.0.0.1 localhost" > "$rootfs_path"/etc/hosts
echo "nameserver 8.8.8.8" > "$rootfs_path"/etc/resolv.conf
echo "nameserver 8.8.4.4" >> "$rootfs_path"/etc/resolv.conf
# Check the storage and dev folders exists
if [ ! -d "$rootfs_path"/storage/ ]; then
echo -e "Folder 'storage' in guest system not found. Creating....\n"
mkdir $rootfs_path/storage/
fi
if [ ! -d "$rootfs_path"/dev/ ]; then
echo -e "Folder 'dev' in guest system not found. Creating....\n"
mkdir $rootfs_path/dev/
fi
if [ ! -d "$rootfs_path"/proc/ ]; then
echo -e "Folder 'proc' in guest system not found. Creating....\n"
mkdir $rootfs_path/proc/
fi
if [ ! -d "$rootfs_path"/sys/ ]; then
echo -e "Folder 'sys' in guest system not found. Creating....\n"
mkdir $rootfs_path/sys/
fi
# This step is only needed for Ubuntu to prevent Group error
touch "$rootfs_path"/root/.hushlogin
setup_fake_proc "$CURRENT_WORK_FOLDER"/"$rootfs_path"/
echo -e "System memory configuration is determined as ${MEMORY_BITS}\n"
if [ ! -d "${CURRENT_WORK_FOLDER}/bin/proot-static/" ]; then
echo "Git submodule 'proot-static' not found! Try running these commands again:"
echo "git submodule init"
echo "git submodule update"
exit 1
fi
if [ "$(uname -o)" = "Android" ]; then
if $old_termux_exec_cmd; then
echo -e "Your environment is defined as Termux (executed with --old flag)\n"
generate_termux_old_env_exec_cmd "$rootfs_path" "$make_host_tmp_shared"
else
echo -e "Your environment is defined as Termux\n"
generate_termux_env_exec_cmd "$rootfs_path" "$make_host_tmp_shared"
fi
else
echo -e "Your environment is defined as proot\n"
generate_proot_env_exec_cmd "$rootfs_path" "$make_host_tmp_shared"
fi
echo -e "${GREEN}[Starting x86 environment]${NC}\n"
exec ${exec_cmd}
echo -e "\n${GREEN}[Exit from x86 environment]${NC}\n"
}
ARG_ACTION="${1:-}"
ARG_PARAMS="${@:2}"
case "${ARG_ACTION}" in
"login")
print_welcome_message
start_guest $ARG_PARAMS
;;
"")
echo -e "${RED}WARNING: starting the utility start-exagear.sh without parameters is DEPRECATED! Running without parameters WILL BE REMOVED in version 3.0. \n\nNew comand line syntax: start-exagear.sh login <PARAMETERS>${NC}"
print_welcome_message
start_guest $ARG_PARAMS
;;
-h|--help|help|--usage|-dh)
shift 1
print_usage_and_exit
;;
*)
echo "Error: unknown command '${ARG_ACTION}'"
exit 1
;;
esac