-
Notifications
You must be signed in to change notification settings - Fork 215
/
proot-distro.sh
executable file
·2759 lines (2518 loc) · 91.2 KB
/
proot-distro.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
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!@TERMUX_PREFIX@/bin/bash
# shellcheck disable=SC2239
##
## Proot-Distro is a script for managing proot containers on Termux.
##
## !!! THIS IS NOT A REPLACEMENT FOR PROOT UTILITY !!!
##
## Originally created by Sylirre <[email protected]> for Termux project.
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This 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. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
##
PROGRAM_VERSION="4.17.3"
#############################################################################
#
# GLOBAL ENVIRONMENT AND INSTALLATION-SPECIFIC CONFIGURATION
#
set -e -u
# Override user-defined PATH.
export PATH="@TERMUX_PREFIX@/bin"
# Reference this where need to retrieve program name.
PROGRAM_NAME=$(basename "$(realpath "$0")")
# Where distribution plug-ins are stored.
DISTRO_PLUGINS_DIR="@TERMUX_PREFIX@/etc/proot-distro"
# Base directory where script keeps runtime data.
RUNTIME_DIR="@TERMUX_PREFIX@/var/lib/proot-distro"
# Where rootfs tarballs are downloaded.
DOWNLOAD_CACHE_DIR="${RUNTIME_DIR}/dlcache"
# Where extracted rootfs are stored.
INSTALLED_ROOTFS_DIR="${RUNTIME_DIR}/installed-rootfs"
# Default name servers.
DEFAULT_PRIMARY_NAMESERVER="8.8.8.8"
DEFAULT_SECONDARY_NAMESERVER="8.8.4.4"
# PATH environment variable for distributions.
DEFAULT_PATH_ENV="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:@TERMUX_PREFIX@/bin:/system/bin:/system/xbin"
# Default fake kernel version.
# Note: faking kernel version is required when using PRoot-Distro on
# old devices that are not compatible with up-to-date versions of GNU libc.
DEFAULT_FAKE_KERNEL_VERSION="6.2.1-PRoot-Distro"
# Emulator type for x86_64 systems.
# Can be either BLINK or QEMU.
: "${PROOT_DISTRO_X64_EMULATOR:=QEMU}"
# Colors.
if [ -n "$(command -v tput)" ] && [ "$(tput colors 2>/dev/null || echo 0)" -ge 8 ] && [ -z "${PROOT_DISTRO_FORCE_NO_COLORS-}" ]; then
RST="$(tput sgr0)"
RED="${RST}$(tput setaf 1)"
BRED="${RST}$(tput bold)$(tput setaf 1)"
GREEN="${RST}$(tput setaf 2)"
YELLOW="${RST}$(tput setaf 3)"
BYELLOW="${RST}$(tput bold)$(tput setaf 3)"
IYELLOW="${RST}$(tput sitm)$(tput setaf 3)"
BLUE="${RST}$(tput setaf 4)"
MAGENTA="${RST}$(tput setaf 5)"
CYAN="${RST}$(tput setaf 6)"
BCYAN="${RST}$(tput bold)$(tput setaf 6)"
ICYAN="${RST}$(tput sitm)$(tput setaf 6)"
else
RED=""
BRED=""
GREEN=""
YELLOW=""
BYELLOW=""
IYELLOW=""
BLUE=""
MAGENTA=""
CYAN=""
BCYAN=""
ICYAN=""
RST=""
fi
# Disable termux-exec or other things which may interfere with proot.
# It is expected that all dependencies have fixed hardcoded paths according
# to Termux file system layout.
unset LD_PRELOAD
# Override umask
umask 0022
#############################################################################
#
# FUNCTION TO PRINT A MESSAGE TO CONSOLE
#
# Prints a given text string to stderr. Supports escape sequences.
#
#############################################################################
msg() {
echo -e "$@" >&2
}
#############################################################################
#
# DEPENDENCY CHECK
#
# Make sure all needed utilities are available in PATH before continuing.
#
#############################################################################
for i in awk basename bzip2 cat chmod cp curl cut du file find grep gzip \
head id lscpu mkdir proot rm sed tar xargs xz; do
if [ -z "$(command -v "$i")" ]; then
msg
msg "${BRED}Utility '${i}' is not installed. Cannot continue.${RST}"
msg
exit 1
fi
done
unset i
# Notify user if bin/bash is not a GNU Bash.
if ! grep -q '^GNU bash' <(bash --version 2>/dev/null | head -n 1); then
msg
msg "${BRED}Warning: bash binary that is available in PATH appears to be not a GNU bash. You may experience issues during installation, backup and restore operations.${RST}"
msg
fi
# Notify user if tar available in PATH is not GNU tar.
if ! grep -q '^tar (GNU tar)' <(tar --version 2>/dev/null | head -n 1); then
msg
msg "${BRED}Warning: tar binary that is available in PATH appears to be not a GNU tar. You may experience issues during installation, backup and restore operations.${RST}"
msg
fi
#############################################################################
#
# ANTI ROOT FUSE
#
# This script should never be executed as root as can mess up the ownership,
# and SELinux labels in $PREFIX.
#
#############################################################################
if [ "$(id -u)" = "0" ]; then
msg
msg "${BRED}Warning: ${PROGRAM_NAME} should not be executed as root user. Do not send bug reports about messed up Termux environment, lost data and bricked devices.${RST}"
msg
fi
#############################################################################
#
# ANTI NESTED PROOT FUSE
#
# Nested PRoot usage leads to performance degradation and other issues.
#
#############################################################################
TRACER_PID=$(grep TracerPid "/proc/$$/status" | cut -d $'\t' -f 2)
if [ "$TRACER_PID" != 0 ]; then
TRACER_NAME=$(grep Name "/proc/${TRACER_PID}/status" | cut -d $'\t' -f 2)
if [ "$TRACER_NAME" = "proot" ]; then
msg
msg "${BRED}Error: ${PROGRAM_NAME} should not be executed under PRoot.${RST}"
msg
exit 1
fi
unset TRACER_NAME
fi
unset TRACER_PID
#############################################################################
#
# FUNCTION TO DETECT CPU ARCHITECTURE IN GIVEN DISTRIBUTION
#
# Check known executable(s) and return CPU architecture.
#
#############################################################################
detect_cpu_arch() {
local dist_path="${INSTALLED_ROOTFS_DIR}/${1}"
local cpu_arch
local i
for i in bash dash sh su ls sha256sum busybox; do
if [ "$(dd if="${dist_path}/bin/${i}" bs=1 skip=1 count=3 2>/dev/null)" = "ELF" ]; then
cpu_arch=$(file "$(realpath "${dist_path}/bin/${i}")" | cut -d':' -f2- | cut -d',' -f2 | cut -d' ' -f2-)
[ -n "$cpu_arch" ] && break
fi
done
case "$cpu_arch" in
"ARM aarch64") cpu_arch="aarch64";;
"ARM") cpu_arch="arm";;
"UCB RISC-V") cpu_arch="riscv64";;
"Intel 80386") cpu_arch="i686";;
"x86-64") cpu_arch="x86_64";;
*) cpu_arch="unknown";;
esac
echo "$cpu_arch"
}
#############################################################################
#
# FUNCTION TO INSTALL THE SPECIFIED DISTRIBUTION
#
# Brief algorithm how it works:
#
# 1. Process arguments supplied to 'install' command.
# 2. Ensure that requested distribution is supported and is not installed.
# 3. Source the distribution configuration plug-in.
# 4. Download the tarball of rootfs for requested distribution unless found
# in cache.
# 5. Verify SHA-256 checksum of the rootfs tarball.
# 6. Extract the rootfs under PRoot with link2symlink extension enabled.
# 7. Perform post-installation actions on distribution to make it ready.
#
#############################################################################
command_install() {
local distro_name
local override_alias
local distro_plugin_script
while (($# >= 1)); do
case "$1" in
--)
shift 1
break
;;
-h|--help)
command_install_help
return 0
;;
--override-alias)
if [ $# -ge 2 ]; then
shift 1
if [ -z "$1" ]; then
msg
msg "${BRED}Error: argument to option '${YELLOW}--override-alias${BRED}' should not be empty.${RST}"
command_install_help
return 1
fi
if ! grep -qP '^[a-z0-9][a-z0-9_.+\-]*$' <<< "$1"; then
msg
msg "${BRED}Error: argument to option '${YELLOW}--override-alias${BRED}' should start only with an alphanumeric character and consist of alphanumeric characters including symbols '_.+-'."
msg
return 1
fi
if grep -qP '^.*\.sh$' <<< "$1"; then
msg
msg "${BRED}Error: argument to option '${YELLOW}--override-alias${BRED}' should not end with '.sh'.${RST}"
msg
return 1
fi
override_alias="$1"
else
msg
msg "${BRED}Error: option '${YELLOW}--override-alias${BRED}' requires an argument.${RST}"
command_install_help
return 1
fi
;;
-*)
msg
msg "${BRED}Error: got unknown option '${YELLOW}${1}${BRED}'.${RST}"
command_install_help
return 1
;;
*)
if [ -z "${distro_name-}" ]; then
if [ -z "$1" ]; then
msg
msg "${BRED}Error: distribution alias argument should not be empty.${RST}"
command_install_help
return 1
fi
distro_name="$1"
else
msg
msg "${BRED}Error: got excessive positional argument '${YELLOW}${1}${BRED}'. Note that distribution can be specified only once.${RST}"
command_install_help
return 1
fi
;;
esac
shift 1
done
if [ -z "${distro_name-}" ]; then
msg
msg "${BRED}Error: distribution alias is not specified.${RST}"
command_install_help
return 1
fi
if [ -z "${SUPPORTED_DISTRIBUTIONS["$distro_name"]+x}" ]; then
msg
msg "${BRED}Error: unknown distribution '${YELLOW}${distro_name}${BRED}' was requested to be installed.${RST}"
msg
msg "${CYAN}View supported distributions by: ${GREEN}${PROGRAM_NAME} list${RST}"
msg
return 1
fi
if [ -n "${override_alias-}" ]; then
if [ ! -e "${DISTRO_PLUGINS_DIR}/${override_alias}.sh" ] && [ ! -e "${DISTRO_PLUGINS_DIR}/${override_alias}.override.sh" ]; then
msg "${BLUE}[${GREEN}*${BLUE}] ${CYAN}Creating file '${DISTRO_PLUGINS_DIR}/${override_alias}.override.sh'...${RST}"
distro_plugin_script="${DISTRO_PLUGINS_DIR}/${override_alias}.override.sh"
cp "${DISTRO_PLUGINS_DIR}/${distro_name}.sh" "${distro_plugin_script}"
sed -i "s/^\(DISTRO_NAME=\)\(.*\)\$/\1\"${SUPPORTED_DISTRIBUTIONS["$distro_name"]} - ${override_alias}\"/g" "${distro_plugin_script}"
SUPPORTED_DISTRIBUTIONS["${override_alias}"]="${SUPPORTED_DISTRIBUTIONS["$distro_name"]}"
distro_name="${override_alias}"
else
msg
msg "${BRED}Error: distribution with alias '${YELLOW}${override_alias}${BRED}' already exists.${RST}"
msg
return 1
fi
else
distro_plugin_script="${DISTRO_PLUGINS_DIR}/${distro_name}.sh"
# Try an alternate distribution name.
if [ ! -f "${distro_plugin_script}" ]; then
distro_plugin_script="${DISTRO_PLUGINS_DIR}/${distro_name}.override.sh"
fi
fi
if [ -d "${INSTALLED_ROOTFS_DIR}/${distro_name}" ]; then
msg
msg "${BRED}Error: distribution '${YELLOW}${distro_name}${BRED}' is already installed.${RST}"
msg
msg "${CYAN}Log in: ${GREEN}${PROGRAM_NAME} login ${distro_name}${RST}"
msg "${CYAN}Reinstall: ${GREEN}${PROGRAM_NAME} reset ${distro_name}${RST}"
msg "${CYAN}Uninstall: ${GREEN}${PROGRAM_NAME} remove ${distro_name}${RST}"
msg
return 1
fi
if [ -f "${distro_plugin_script}" ]; then
msg "${BLUE}[${GREEN}*${BLUE}] ${CYAN}Installing ${YELLOW}${SUPPORTED_DISTRIBUTIONS["$distro_name"]}${CYAN}...${RST}"
# Make sure things are cleared up on failure or user requested exit.
# shellcheck disable=SC2064 # variables must expand here
trap "echo -e \"\\r\\e[2K${BLUE}[${RED}!${BLUE}] ${CYAN}Exiting due to failure.${RST}\"; chmod -R u+rwx \"${INSTALLED_ROOTFS_DIR:?}/${distro_name:?}\"; rm -rf \"${INSTALLED_ROOTFS_DIR:?}/${distro_name:?}\"; [ -e \"${DISTRO_PLUGINS_DIR}/${distro_name}.override.sh\" ] && rm -f \"${DISTRO_PLUGINS_DIR}/${distro_name}.override.sh\"; exit 1;" EXIT
# shellcheck disable=SC2064 # variables must expand here
trap "trap - EXIT; echo -e \"\\r\\e[2K${BLUE}[${RED}!${BLUE}] ${CYAN}Exiting immediately as requested.${RST}\"; chmod -R u+rwx \"${INSTALLED_ROOTFS_DIR:?}/${distro_name:?}\"; rm -rf \"${INSTALLED_ROOTFS_DIR:?}/${distro_name:?}\"; [ -e \"${DISTRO_PLUGINS_DIR}/${distro_name}.override.sh\" ] && rm -f \"${DISTRO_PLUGINS_DIR}/${distro_name}.override.sh\"; exit 1;" HUP INT TERM
msg "${BLUE}[${GREEN}*${BLUE}] ${CYAN}Creating directory '${INSTALLED_ROOTFS_DIR}/${distro_name}'...${RST}"
mkdir -p "${INSTALLED_ROOTFS_DIR}/${distro_name}"
export PROOT_L2S_DIR="${INSTALLED_ROOTFS_DIR}/${distro_name}/.l2s"
if [ ! -d "${INSTALLED_ROOTFS_DIR}/${distro_name}/.l2s" ]; then
echo -e "${BLUE}[${GREEN}*${BLUE}] ${CYAN}Creating directory '${PROOT_L2S_DIR}'...${RST}"
mkdir -p "$PROOT_L2S_DIR"
fi
# This should be overridden in distro plug-in with valid URL for
# each architecture where possible.
TARBALL_URL["aarch64"]=""
TARBALL_URL["arm"]=""
TARBALL_URL["i686"]=""
TARBALL_URL["riscv64"]=""
TARBALL_URL["x86_64"]=""
# This should be overridden in distro plug-in with valid SHA-256
# for corresponding tarballs.
TARBALL_SHA256["aarch64"]=""
TARBALL_SHA256["arm"]=""
TARBALL_SHA256["i686"]=""
TARBALL_SHA256["riscv64"]=""
TARBALL_SHA256["x86_64"]=""
# If your content inside tarball isn't stored in subdirectory,
# you can override this variable in distro plug-in with 0.
TARBALL_STRIP_OPT=1
# Distribution plug-in contains steps on how to get download URL
# and further post-installation configuration.
# shellcheck disable=SC1090
source "${distro_plugin_script}"
# Cannot proceed without URL and SHA-256.
if [ -z "${TARBALL_URL["$DISTRO_ARCH"]}" ]; then
msg "${BLUE}[${RED}!${BLUE}] ${CYAN}The distribution download URL is not defined for CPU architecture '${DISTRO_ARCH}'.${RST}"
return 1
fi
if ! grep -qP '^[0-9a-fA-F]{64}$' <<< "${TARBALL_SHA256["$DISTRO_ARCH"]}"; then
msg
msg "${BRED}Error: got malformed SHA-256 from plug-in script '${distro_plugin_script}'.${RST}"
msg
return 1
fi
if [ ! -d "$DOWNLOAD_CACHE_DIR" ]; then
msg "${BLUE}[${GREEN}*${BLUE}] ${CYAN}Creating directory '$DOWNLOAD_CACHE_DIR'...${RST}"
mkdir -p "$DOWNLOAD_CACHE_DIR"
fi
local tarball_name
tarball_name=$(basename "${TARBALL_URL["$DISTRO_ARCH"]}")
if [ ! -f "${DOWNLOAD_CACHE_DIR}/${tarball_name}" ]; then
msg "${BLUE}[${GREEN}*${BLUE}] ${CYAN}Downloading rootfs tarball...${RST}"
msg "${BLUE}[${GREEN}*${BLUE}] ${CYAN}URL: ${TARBALL_URL["$DISTRO_ARCH"]}${RST}"
# Using temporary file as script can't distinguish the partially
# downloaded file from the complete. Useful in case if curl will
# fail for some reason.
msg
rm -f "${DOWNLOAD_CACHE_DIR}/${tarball_name}.tmp"
if ! curl --disable --fail --retry 5 --retry-connrefused --retry-delay 5 --location \
--output "${DOWNLOAD_CACHE_DIR}/${tarball_name}.tmp" "${TARBALL_URL["$DISTRO_ARCH"]}"; then
msg
msg "${BLUE}[${RED}!${BLUE}] ${CYAN}Download failure, please check your network connection.${RST}"
rm -f "${DOWNLOAD_CACHE_DIR}/${tarball_name}.tmp"
return 1
fi
msg
# If curl finished successfully, rename file to original.
mv -f "${DOWNLOAD_CACHE_DIR}/${tarball_name}.tmp" "${DOWNLOAD_CACHE_DIR}/${tarball_name}"
else
msg "${BLUE}[${GREEN}*${BLUE}] ${CYAN}Using cached rootfs tarball...${RST}"
fi
if [ -n "${TARBALL_SHA256["$DISTRO_ARCH"]}" ]; then
msg "${BLUE}[${GREEN}*${BLUE}] ${CYAN}Checking integrity, please wait...${RST}"
local actual_sha256
actual_sha256=$(sha256sum "${DOWNLOAD_CACHE_DIR}/${tarball_name}" | awk '{ print $1}')
if [ "${TARBALL_SHA256["$DISTRO_ARCH"]}" != "${actual_sha256}" ]; then
msg "${BLUE}[${RED}!${BLUE}] ${CYAN}Integrity checking failed. Try to redo installation again.${RST}"
rm -f "${DOWNLOAD_CACHE_DIR}/${tarball_name}"
return 1
fi
else
msg "${BLUE}[${RED}!${BLUE}] ${CYAN}Integrity checking of downloaded rootfs has been disabled.${RST}"
fi
msg "${BLUE}[${GREEN}*${BLUE}] ${CYAN}Extracting rootfs, please wait...${RST}"
# --exclude='dev' - need to exclude /dev directory which may contain device files.
# --delay-directory-restore - set directory permissions only when files were extracted
# to avoid issues with Arch Linux bootstrap archives.
set +e
proot --link2symlink \
tar -C "${INSTALLED_ROOTFS_DIR}/${distro_name}" --warning=no-unknown-keyword \
--delay-directory-restore --preserve-permissions --strip="${TARBALL_STRIP_OPT}" \
-xf "${DOWNLOAD_CACHE_DIR}/${tarball_name}" --exclude='dev' |& grep -v "/linkerconfig/" >&2
set -e
# If no /etc in rootfs, terminate installation.
# This usually indicates that downloaded distribution tarball doesn't contain
# actual rootfs, wrong tar strip option was specified or the distribution has
# high grade of customization and doesn't respect FHS standard.
if [ ! -e "${INSTALLED_ROOTFS_DIR}/${distro_name}/etc" ]; then
msg
msg "${BRED}Error: the rootfs of distribution '${YELLOW}${distro_name}${BRED}' has unexpected structure (no /etc directory). Make sure that variable TARBALL_STRIP_OPT specified in distribution plug-in is correct.${RST}"
msg
return 1
fi
# Write important environment variables to /etc/environment.
chmod u+rw "${INSTALLED_ROOTFS_DIR}/${distro_name}/etc/environment" >/dev/null 2>&1 || true
msg "${BLUE}[${GREEN}*${BLUE}] ${CYAN}Writing file '${INSTALLED_ROOTFS_DIR}/${distro_name}/etc/environment'...${RST}"
for var in ANDROID_ART_ROOT ANDROID_DATA ANDROID_I18N_ROOT ANDROID_ROOT \
ANDROID_RUNTIME_ROOT ANDROID_TZDATA_ROOT BOOTCLASSPATH COLORTERM \
DEX2OATBOOTCLASSPATH EXTERNAL_STORAGE; do
set +u
if [ -n "${!var}" ]; then
echo "${var}=${!var}" >> "${INSTALLED_ROOTFS_DIR}/${distro_name}/etc/environment"
fi
set -u
done
unset var
# Don't touch these variables.
# TERM is being inherited from currect environment. Otherwise it is being
# set to xterm-256color (Termux app default).
cat <<- EOF >> "${INSTALLED_ROOTFS_DIR}/${distro_name}/etc/environment"
LANG=en_US.UTF-8
MOZ_FAKE_NO_SANDBOX=1
PATH=${DEFAULT_PATH_ENV}
PULSE_SERVER=127.0.0.1
TERM=${TERM-xterm-256color}
TMPDIR=/tmp
EOF
# Fix PATH in some configuration files.
for f in /etc/bash.bashrc /etc/profile /etc/login.defs; do
[ ! -e "${INSTALLED_ROOTFS_DIR}/${distro_name}${f}" ] && continue
msg "${BLUE}[${GREEN}*${BLUE}] ${CYAN}Updating PATH in '${INSTALLED_ROOTFS_DIR}/${distro_name}${f}' if needed...${RST}"
sed -i -E "s@\<(PATH=)(\"?[^\"[:space:]]+(\"|\$|\>))@\1\"${DEFAULT_PATH_ENV}\"@g" \
"${INSTALLED_ROOTFS_DIR}/${distro_name}${f}"
done
unset f
# Default /etc/resolv.conf may be empty or unsuitable for use.
msg "${BLUE}[${GREEN}*${BLUE}] ${CYAN}Creating file '${INSTALLED_ROOTFS_DIR}/${distro_name}/etc/resolv.conf'...${RST}"
rm -f "${INSTALLED_ROOTFS_DIR}/${distro_name}/etc/resolv.conf"
cat <<- EOF > "${INSTALLED_ROOTFS_DIR}/${distro_name}/etc/resolv.conf"
nameserver ${DEFAULT_PRIMARY_NAMESERVER}
nameserver ${DEFAULT_SECONDARY_NAMESERVER}
EOF
# Default /etc/hosts may be empty or incomplete.
msg "${BLUE}[${GREEN}*${BLUE}] ${CYAN}Creating file '${INSTALLED_ROOTFS_DIR}/${distro_name}/etc/hosts'...${RST}"
chmod u+rw "${INSTALLED_ROOTFS_DIR}/${distro_name}/etc/hosts" >/dev/null 2>&1 || true
cat <<- EOF > "${INSTALLED_ROOTFS_DIR}/${distro_name}/etc/hosts"
# IPv4.
127.0.0.1 localhost.localdomain localhost
# IPv6.
::1 localhost.localdomain localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
EOF
# Add Android-specific UIDs/GIDs to /etc/group and /etc/gshadow.
msg "${BLUE}[${GREEN}*${BLUE}] ${CYAN}Registering Android-specific UIDs and GIDs...${RST}"
chmod u+rw "${INSTALLED_ROOTFS_DIR}/${distro_name}/etc/passwd" \
"${INSTALLED_ROOTFS_DIR}/${distro_name}/etc/shadow" \
"${INSTALLED_ROOTFS_DIR}/${distro_name}/etc/group" \
"${INSTALLED_ROOTFS_DIR}/${distro_name}/etc/gshadow" >/dev/null 2>&1 || true
echo "aid_$(id -un):x:$(id -u):$(id -g):Termux:/:/sbin/nologin" >> \
"${INSTALLED_ROOTFS_DIR}/${distro_name}/etc/passwd"
echo "aid_$(id -un):*:18446:0:99999:7:::" >> \
"${INSTALLED_ROOTFS_DIR}/${distro_name}/etc/shadow"
local group_name group_id
while read -r group_name group_id; do
echo "aid_${group_name}:x:${group_id}:root,aid_$(id -un)" \
>> "${INSTALLED_ROOTFS_DIR}/${distro_name}/etc/group"
if [ -f "${INSTALLED_ROOTFS_DIR}/${distro_name}/etc/gshadow" ]; then
echo "aid_${group_name}:*::root,aid_$(id -un)" \
>> "${INSTALLED_ROOTFS_DIR}/${distro_name}/etc/gshadow"
fi
done < <(paste <(id -Gn | tr ' ' '\n') <(id -G | tr ' ' '\n'))
# Ensure that proot will be able to bind fake /proc and /sys entries.
setup_fake_sysdata
# Run optional distro-specific hook.
if declare -f -F distro_setup >/dev/null 2>&1; then
msg "${BLUE}[${GREEN}*${BLUE}] ${CYAN}Running distribution-specific configuration steps...${RST}"
(cd "${INSTALLED_ROOTFS_DIR}/${distro_name}"
distro_setup
)
fi
# Reset trap for HUP/INT/TERM.
trap - EXIT
trap 'echo -e "\\r\\e[2K${BLUE}[${RED}!${BLUE}] ${CYAN}Exiting immediately as requested.${RST}"; exit 1;' HUP INT TERM
msg "${BLUE}[${GREEN}*${BLUE}] ${CYAN}Finished.${RST}"
msg
msg "${CYAN}Log in with: ${GREEN}${PROGRAM_NAME} login ${distro_name}${CYAN}${RST}"
msg
return 0
else
# Reset trap for HUP/INT/TERM.
trap - EXIT
trap 'echo -e "\\r\\e[2K${BLUE}[${RED}!${BLUE}] ${CYAN}Exiting immediately as requested.${RST}"; exit 1;' HUP INT TERM
msg "${BLUE}[${RED}!${BLUE}] ${CYAN}Cannot find '${distro_plugin_script}' which is used to define a distribution properties.${RST}"
return 1
fi
}
# Special function for executing a command inside rootfs.
# Intended to be used inside plug-in distro_setup() function.
# shellcheck disable=SC2317 # run_proot_cmd called indirectly
run_proot_cmd() {
if [ -z "${distro_name-}" ]; then
msg
msg "${BRED}Error: called run_proot_cmd() but \${distro_name} is not set. Make sure that run_proot_cmd() is used inside distro_setup() function.${RST}"
msg
return 1
fi
if [ -z "${DISTRO_ARCH-}" ]; then
msg
msg "${BRED}Error: called run_proot_cmd() but \${DISTRO_ARCH} is not set.${RST}"
msg
return 1
fi
local cpu_emulator_arg=""
if [ "$DISTRO_ARCH" != "$DEVICE_CPU_ARCH" ]; then
local cpu_emulator_path=""
# If CPU and host OS are 64bit, we can run 32bit guest OS without emulation.
# Everything else requires emulator (QEMU).
case "$DISTRO_ARCH" in
aarch64) cpu_emulator_path="@TERMUX_PREFIX@/bin/qemu-aarch64";;
arm)
if [ "$DEVICE_CPU_ARCH" != "aarch64" ] || ! $SUPPORT_32BIT; then
cpu_emulator_path="@TERMUX_PREFIX@/bin/qemu-arm"
fi
;;
i686)
if [ "$DEVICE_CPU_ARCH" != "x86_64" ]; then
cpu_emulator_path="@TERMUX_PREFIX@/bin/qemu-i386"
fi
;;
riscv64) cpu_emulator_path="@TERMUX_PREFIX@/bin/qemu-riscv64";;
x86_64)
if [ "$PROOT_DISTRO_X64_EMULATOR" = "QEMU" ]; then
cpu_emulator_path="@TERMUX_PREFIX@/bin/qemu-x86_64"
elif [ "$PROOT_DISTRO_X64_EMULATOR" = "BLINK" ]; then
cpu_emulator_path="@TERMUX_PREFIX@/bin/blink"
else
msg
msg "${BRED}Error: PROOT_DISTRO_X64_EMULATOR has unknown value '$PROOT_DISTRO_X64_EMULATOR'. Valid values are: BLINK, QEMU."
msg
fi
;;
*)
msg
msg "${BRED}Error: DISTRO_ARCH has unknown value '$DISTRO_ARCH'. Valid values are: aarch64, arm, i686, riscv64, x86_64."
msg
return 1
;;
esac
if [ -n "$cpu_emulator_path" ]; then
if [ -x "$cpu_emulator_path" ]; then
cpu_emulator_arg="-q ${cpu_emulator_path}"
else
local cpu_emulator_pkg=""
case "$DISTRO_ARCH" in
aarch64) cpu_emulator_pkg="qemu-user-aarch64";;
arm) cpu_emulator_pkg="qemu-user-arm";;
i686) cpu_emulator_pkg="qemu-user-i386";;
riscv64) cpu_emulator_pkg="qemu-user-riscv64";;
x86_64)
if [ "$PROOT_DISTRO_X64_EMULATOR" = "QEMU" ]; then
cpu_emulator_pkg="qemu-user-x86-64"
elif [ "$PROOT_DISTRO_X64_EMULATOR" = "BLINK" ]; then
cpu_emulator_pkg="blink"
else
msg
msg "${BRED}Error: PROOT_DISTRO_X64_EMULATOR has unknown value '$PROOT_DISTRO_X64_EMULATOR'. Valid values are: BLINK, QEMU."
msg
fi
;;
*) cpu_emulator_pkg="qemu-user-${DISTRO_ARCH}";;
esac
msg
msg "${BRED}Error: package '${cpu_emulator_pkg}' is not installed.${RST}"
msg
return 1
fi
fi
else
# Warn about CPU not supporting 32-bit instructions
if ! $SUPPORT_32BIT; then
msg "${BRED}Warning: CPU doesn't support 32-bit instructions, some software may not work.${RST}"
fi
fi
if [ -n "$cpu_emulator_arg" ]; then
if [ -d "/apex" ]; then
cpu_emulator_arg="${cpu_emulator_arg} --bind=/apex"
fi
if [ -e "/linkerconfig/ld.config.txt" ]; then
cpu_emulator_arg="${cpu_emulator_arg} --bind=/linkerconfig/ld.config.txt"
fi
cpu_emulator_arg="${cpu_emulator_arg} --bind=@TERMUX_PREFIX@"
cpu_emulator_arg="${cpu_emulator_arg} --bind=/system"
cpu_emulator_arg="${cpu_emulator_arg} --bind=/vendor"
if [ -f "/plat_property_contexts" ]; then
cpu_emulator_arg="${cpu_emulator_arg} --bind=/plat_property_contexts"
fi
if [ -f "/property_contexts" ]; then
cpu_emulator_arg="${cpu_emulator_arg} --bind=/property_contexts"
fi
fi
# Ensure that proot will be able to bind fake /proc and /sys entries.
setup_fake_sysdata
# With this tools should assume that no SELinux present.
set -- "--bind=${INSTALLED_ROOTFS_DIR}/${distro_name}/sys/.empty:/sys/fs/selinux" "$@"
# shellcheck disable=SC2086 # ${cpu_emulator_arg} should expand into nothing rather than into ''.
proot ${cpu_emulator_arg} \
-L \
--kernel-release="${DEFAULT_FAKE_KERNEL_VERSION}" \
--link2symlink \
--kill-on-exit \
--rootfs="${INSTALLED_ROOTFS_DIR}/${distro_name}" \
--root-id \
--cwd=/root \
--bind=/dev \
--bind="/dev/urandom:/dev/random" \
--bind=/proc \
--bind="/proc/self/fd:/dev/fd" \
--bind="/proc/self/fd/0:/dev/stdin" \
--bind="/proc/self/fd/1:/dev/stdout" \
--bind="/proc/self/fd/2:/dev/stderr" \
--bind=/sys \
--bind="${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.loadavg:/proc/loadavg" \
--bind="${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.stat:/proc/stat" \
--bind="${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.uptime:/proc/uptime" \
--bind="${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.version:/proc/version" \
--bind="${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.vmstat:/proc/vmstat" \
--bind="${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.sysctl_entry_cap_last_cap:/proc/sys/kernel/cap_last_cap" \
--bind="${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.sysctl_inotify_max_user_watches:/proc/sys/fs/inotify/max_user_watches" \
--bind="${INSTALLED_ROOTFS_DIR}/${distro_name}/sys/.empty:/sys/fs/selinux" \
/usr/bin/env -i \
"HOME=/root" \
"LANG=C.UTF-8" \
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \
"TERM=${TERM-xterm-256color}" \
"TMPDIR=/tmp" \
"$@"
}
# A function for preparing fake content for certain system data interfaces
# which known to be restricted on Android OS.
#
# All /proc entries are based on values retrieved from Arch Linux (x86_64)
# running on a VM with 8 CPUs and 8 GiB of memory. Date 2023.03.28, Linux 6.2.1.
# Some values edited to fit the PRoot-Distro.
setup_fake_sysdata() {
local d
for d in proc sys sys/.empty; do
if [ ! -e "${INSTALLED_ROOTFS_DIR}/${distro_name}/${d}" ]; then
mkdir -p "${INSTALLED_ROOTFS_DIR}/${distro_name}/${d}"
fi
chmod 700 "${INSTALLED_ROOTFS_DIR}/${distro_name}/${d}"
done
unset d
if [ ! -f "${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.loadavg" ]; then
cat <<- EOF > "${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.loadavg"
0.12 0.07 0.02 2/165 765
EOF
fi
if [ ! -f "${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.stat" ]; then
cat <<- EOF > "${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.stat"
cpu 1957 0 2877 93280 262 342 254 87 0 0
cpu0 31 0 226 12027 82 10 4 9 0 0
cpu1 45 0 664 11144 21 263 233 12 0 0
cpu2 494 0 537 11283 27 10 3 8 0 0
cpu3 359 0 234 11723 24 26 5 7 0 0
cpu4 295 0 268 11772 10 12 2 12 0 0
cpu5 270 0 251 11833 15 3 1 10 0 0
cpu6 430 0 520 11386 30 8 1 12 0 0
cpu7 30 0 172 12108 50 8 1 13 0 0
intr 127541 38 290 0 0 0 0 4 0 1 0 0 25329 258 0 5777 277 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 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 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 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 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 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
ctxt 140223
btime 1680020856
processes 772
procs_running 2
procs_blocked 0
softirq 75663 0 5903 6 25375 10774 0 243 11685 0 21677
EOF
fi
if [ ! -f "${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.uptime" ]; then
cat <<- EOF > "${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.uptime"
124.08 932.80
EOF
fi
if [ ! -f "${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.version" ]; then
cat <<- EOF > "${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.version"
Linux version ${DEFAULT_FAKE_KERNEL_VERSION} (proot@termux) (gcc (GCC) 12.2.1 20230201, GNU ld (GNU Binutils) 2.40) #1 SMP PREEMPT_DYNAMIC Wed, 01 Mar 2023 00:00:00 +0000
EOF
fi
if [ ! -f "${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.vmstat" ]; then
cat <<- EOF > "${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.vmstat"
nr_free_pages 1743136
nr_zone_inactive_anon 179281
nr_zone_active_anon 7183
nr_zone_inactive_file 22858
nr_zone_active_file 51328
nr_zone_unevictable 642
nr_zone_write_pending 0
nr_mlock 0
nr_bounce 0
nr_zspages 0
nr_free_cma 0
numa_hit 1259626
numa_miss 0
numa_foreign 0
numa_interleave 720
numa_local 1259626
numa_other 0
nr_inactive_anon 179281
nr_active_anon 7183
nr_inactive_file 22858
nr_active_file 51328
nr_unevictable 642
nr_slab_reclaimable 8091
nr_slab_unreclaimable 7804
nr_isolated_anon 0
nr_isolated_file 0
workingset_nodes 0
workingset_refault_anon 0
workingset_refault_file 0
workingset_activate_anon 0
workingset_activate_file 0
workingset_restore_anon 0
workingset_restore_file 0
workingset_nodereclaim 0
nr_anon_pages 7723
nr_mapped 8905
nr_file_pages 253569
nr_dirty 0
nr_writeback 0
nr_writeback_temp 0
nr_shmem 178741
nr_shmem_hugepages 0
nr_shmem_pmdmapped 0
nr_file_hugepages 0
nr_file_pmdmapped 0
nr_anon_transparent_hugepages 1
nr_vmscan_write 0
nr_vmscan_immediate_reclaim 0
nr_dirtied 0
nr_written 0
nr_throttled_written 0
nr_kernel_misc_reclaimable 0
nr_foll_pin_acquired 0
nr_foll_pin_released 0
nr_kernel_stack 2780
nr_page_table_pages 344
nr_sec_page_table_pages 0
nr_swapcached 0
pgpromote_success 0
pgpromote_candidate 0
nr_dirty_threshold 356564
nr_dirty_background_threshold 178064
pgpgin 890508
pgpgout 0
pswpin 0
pswpout 0
pgalloc_dma 272
pgalloc_dma32 261
pgalloc_normal 1328079
pgalloc_movable 0
pgalloc_device 0
allocstall_dma 0
allocstall_dma32 0
allocstall_normal 0
allocstall_movable 0
allocstall_device 0
pgskip_dma 0
pgskip_dma32 0
pgskip_normal 0
pgskip_movable 0
pgskip_device 0
pgfree 3077011
pgactivate 0
pgdeactivate 0
pglazyfree 0
pgfault 176973
pgmajfault 488
pglazyfreed 0
pgrefill 0
pgreuse 19230
pgsteal_kswapd 0
pgsteal_direct 0
pgsteal_khugepaged 0
pgdemote_kswapd 0
pgdemote_direct 0
pgdemote_khugepaged 0
pgscan_kswapd 0
pgscan_direct 0
pgscan_khugepaged 0
pgscan_direct_throttle 0
pgscan_anon 0
pgscan_file 0
pgsteal_anon 0
pgsteal_file 0
zone_reclaim_failed 0
pginodesteal 0
slabs_scanned 0
kswapd_inodesteal 0
kswapd_low_wmark_hit_quickly 0
kswapd_high_wmark_hit_quickly 0
pageoutrun 0
pgrotated 0
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 0
pgmigrate_fail 0
thp_migration_success 0
thp_migration_fail 0
thp_migration_split 0
compact_migrate_scanned 0
compact_free_scanned 0
compact_isolated 0
compact_stall 0
compact_fail 0
compact_success 0
compact_daemon_wake 0
compact_daemon_migrate_scanned 0
compact_daemon_free_scanned 0
htlb_buddy_alloc_success 0
htlb_buddy_alloc_fail 0
cma_alloc_success 0
cma_alloc_fail 0
unevictable_pgs_culled 27002
unevictable_pgs_scanned 0
unevictable_pgs_rescued 744
unevictable_pgs_mlocked 744
unevictable_pgs_munlocked 744
unevictable_pgs_cleared 0
unevictable_pgs_stranded 0
thp_fault_alloc 13
thp_fault_fallback 0
thp_fault_fallback_charge 0
thp_collapse_alloc 4
thp_collapse_alloc_failed 0
thp_file_alloc 0
thp_file_fallback 0
thp_file_fallback_charge 0
thp_file_mapped 0
thp_split_page 0
thp_split_page_failed 0
thp_deferred_split_page 1
thp_split_pmd 1
thp_scan_exceed_none_pte 0
thp_scan_exceed_swap_pte 0
thp_scan_exceed_share_pte 0
thp_split_pud 0
thp_zero_page_alloc 0
thp_zero_page_alloc_failed 0
thp_swpout 0
thp_swpout_fallback 0
balloon_inflate 0
balloon_deflate 0
balloon_migrate 0
swap_ra 0
swap_ra_hit 0
ksm_swpin_copy 0
cow_ksm 0
zswpin 0
zswpout 0
direct_map_level2_splits 29
direct_map_level3_splits 0
nr_unstable 0
EOF
fi
if [ ! -f "${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.sysctl_entry_cap_last_cap" ]; then
cat <<- EOF > "${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.sysctl_entry_cap_last_cap"
40
EOF
fi
if [ ! -f "${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.sysctl_inotify_max_user_watches" ]; then
cat <<- EOF > "${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.sysctl_inotify_max_user_watches"
4096
EOF
fi
}
command_install_help() {
msg
msg "${BYELLOW}Usage: ${BCYAN}${PROGRAM_NAME} ${GREEN}install ${CYAN}[${GREEN}OPTIONS${CYAN}] [${GREEN}DISTRIBUTION ALIAS${CYAN}]${RST}"
msg
msg "${CYAN}Command aliases: ${GREEN}add${CYAN}, ${GREEN}i${CYAN}, ${GREEN}in${CYAN}, ${GREEN}ins${RST}"
msg
msg "${CYAN}Install a specified Linux distribution.${RST}"
msg
msg "${CYAN}Options:${RST}"
msg
msg " ${GREEN}--help ${CYAN}- Show this help information.${RST}"