This repository has been archived by the owner on Aug 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprooted-termux
executable file
·102 lines (92 loc) · 2.81 KB
/
prooted-termux
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
#!/usr/bin/bash
jq=$(command -v jq)
proot=$(command -v proot)
qemu=$(command -v qemu-aarch64)
if [ ! $jq ] && [ ! $proot ] && [ ! $qemu ]; then pkg install proot jq qemu-user-aarch64 -y; fi
if [ ! $jq ]; then pkg install jq -y; fi
if [ ! $proot ]; then pkg install proot -y; fi
if [ ! $qemu ]; then pkg install qemu-user-aarch64 -y; fi
jq=$(command -v jq)
proot=$(command -v proot)
qemu=$(command -v qemu-aarch64)
mkdir -p binds
folder=termux-fs/data/data/com.termux/files
if [ -d "$folder" ]; then
first=1
echo "skipping downloading"
fi
if [ "$first" != 1 ];then
if [ ! -f "bootstrap.zip" ]; then
echo "Getting Download link from Github Release...."
download=`curl -L# https://api.github.com/repos/termux/termux-packages/releases | jq -r .[0].assets[0].browser_download_url`
echo "Downloading bootstrap package"
curl -L#o bootstrap.zip $download
fi
cur=`pwd`
mkdir -p $folder/usr
cd $folder/usr
echo "Decompressing bootstrap image image"
busybox unzip $cur/bootstrap.zip
while read p; do
echo "creating symlink for $p"
ln -s ${p/←/ }
done <SYMLINKS.txt
rm SYMLINKS.txt
for f in bin libexec lib/apt/methods;do
echo "Making files in $f executable"
chmod -R 700 $f/*
done
cd $cur
mkdir -p $folder/home
mkdir -p termux-fs/data/data/com.termux/cache/apt/archives/partials
fi
ff=/data/data/com.termux/files
bin=start.sh
echo "writing launch script"
cat > $bin <<- EOM
#!/usr/bin/bash
proot=$(command -v proot)
qemu=$(command -v qemu-aarch64)
basedir=\$(dirname \$0)
if [ ! $proot ]; then pkg install proot -y; fi
if [ ! $qemu ]; then pkg install qemu-user-aarch64 -y; fi
proot=$(command -v proot)
qemu=$(command -v qemu-aarch64)
#unset LD_PRELOAD in case termux-exec is installed. If termux-exec is also installed inside the jail it will set again.
unset LD_PRELOAD
command="proot"
command+=" -q \$qemu"
command+=" -r \$basedir/termux-fs"
command+=" -b /system"
command+=" -b /dev/"
command+=" -b /sys/"
command+=" -b /etc/"
command+=" -b /proc/"
command+=" -b /vendor"
command+=" -b /data/dalvik-cache/"
if [ -n "\$(ls -A \$basedir/binds)" ]; then
for f in \$basedir/binds/* ;do
. \$f
done
fi
command+=" -w /data/data/com.termux/files/home/"
command+=" $ff/usr/bin/env -i"
command+=" HOME=$ff/home"
command+=" PATH=$ff/usr/bin:$ff/usr/bin/applets"
command+=" TERM=\$TERM"
command+=" ANDROID_DATA=/data"
command+=" ANDROID_ROOT=/system"
command+=" EXTERNAL_STORAGE=/sdcard"
command+=" LANG=\$LANG"
command+=" LD_LIBRARY_PATH=/data/data/com.termux/files/usr/lib"
command+=" PREFIX=/data/data/com.termux/files/usr"
command+=" TMPDIR=/data/data/com.termux/files/usr/tmp"
com="\$@"
if [ -z "\$com" ];then
eval "exec \$command login"
else
eval "exec \$command login -c '\$com'"
fi
EOM
echo "making $bin executable"
chmod +x $bin