-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·70 lines (50 loc) · 2.18 KB
/
install.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
#!/usr/bin/env sh
! [ -f ~/.mixedtermuxrc ] && cat <<- EOF > ~/.mixedtermuxrc
# https://github.com/Yonle/MixedTermux
# This is a sample MixedTermux configuration file.
# This configuration file is Bash script. You can put some bash script here.
# Distribution / Distro alias
# To view the available distro, Check "proot-distro list" command
DISTRO=alpine
# User to execute as
USER=root
# Keep all environment variables
KEEPENV=1
# Filter some environment variable that should not store
# Each variables splitted by name
FILTER_ENV="SHELL PREFIX PATH LD_PRELOAD LD_LIBRARY_PATH"
# Additional Proot-distro login args. Each flag is separated with space.
# See "proot-distro login --help" to see proot-distro login arguments
# ADDITIONAL_ARGS="--no-kill-on-exit --no-sysvipc"
EOF
cat <<- EOF > $PREFIX/libexec/termux/command-not-found
#!$PREFIX/bin/env bash
DISTRO_PATH=$PREFIX/var/lib/proot-distro/installed-rootfs/\${DISTRO:-"alpine"}
[ -f ~/.mixedtermuxrc ] && source ~/.mixedtermuxrc
! command -v proot-distro > /dev/null && pkg install -y proot-distro
! [ -d \$DISTRO_PATH ] && ! [ -z "\$(ls -A \$DISTRO_PATH)" ] && proot-distro install \${DISTRO:-"alpine"}
environments=""
! [ -z "\$KEEPENV" ] && for i in \$(env); do
filtered=0
# Don't put some filtered variables
for env in \$FILTER_ENV; do
(echo \$i | grep -qo \$env) && filtered=1
done
[ "\$filtered" = 0 ] && environments="\$environments export \$i;"
done
cat <<- END > \$DISTRO_PATH/etc/profile.d/mixedtermux.sh
#!/usr/bin/env sh
\$environments
cd \$(pwd)
rm /etc/profile.d/mixedtermux.sh
END
chmod +x \$DISTRO_PATH/etc/profile.d/mixedtermux.sh
ARGS=("proot-distro login \${DISTRO:-alpine}")
ARGS+=("--termux-home --shared-tmp --fix-low-ports")
! [ -z "\$ADDITIONAL_ARGS" ] && ARGS+=("\$ADDITIONAL_ARGS")
[ -S $(echo \$TMPDIR/pulse-*/native) ] && ARGS+=("--bind \$(echo \$TMPDIR/pulse-*/native):/var/run/pulse/native")
ARGS+=("--bind \$(pwd) --user \${USER:-"root"} --")
exec \${ARGS[@]} \$*
EOF
sed -i "s/command-not-found \"\$1\"/command-not-found \$\*/g" $PREFIX/etc/bash.bashrc
[ -r $PREFIX/share/fish/functions/fish_command_not_found.fish ] && sed -i "s/\$argv\[1\]/\"\$argv\"/g" $PREFIX/share/fish/functions/fish_command_not_found.fish