Skip to content

Commit a35c7ee

Browse files
authored
Add files via upload
1 parent 64975ad commit a35c7ee

File tree

1 file changed

+136
-0
lines changed

1 file changed

+136
-0
lines changed

‎ubuntu19.10‎

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#!/data/data/com.termux/files/usr/bin/bash
2+
3+
4+
time1="$( date +"%r" )"
5+
6+
install1 () {
7+
directory=ubuntu-fs
8+
UBUNTU_VERSION=19.10
9+
if [ -d "$directory" ];then
10+
first=1
11+
printf "\x1b[38;5;214m[${time1}]\e[0m \x1b[38;5;227m[WARNING]:\e[0m \x1b[38;5;87m Skipping the download and the extraction\n"
12+
elif [ -z "$(command -v proot)" ];then
13+
printf "\x1b[38;5;214m[${time1}]\e[0m \x1b[38;5;203m[ERROR]:\e[0m \x1b[38;5;87m Please install proot.\n"
14+
printf "\e[0m"
15+
exit 1
16+
elif [ -z "$(command -v wget)" ];then
17+
printf "\x1b[38;5;214m[${time1}]\e[0m \x1b[38;5;203m[ERROR]:\e[0m \x1b[38;5;87m Please install wget.\n"
18+
printf "\e[0m"
19+
exit 1
20+
fi
21+
if [ "$first" != 1 ];then
22+
if [ -f "ubuntu.tar.gz" ];then
23+
rm -rf ubuntu.tar.gz
24+
fi
25+
if [ ! -f "ubuntu.tar.gz" ];then
26+
printf "\x1b[38;5;214m[${time1}]\e[0m \x1b[38;5;83m[Installer thread/INFO]:\e[0m \x1b[38;5;87m Downloading the ubuntu rootfs, please wait...\n"
27+
ARCHITECTURE=$(dpkg --print-architecture)
28+
case "$ARCHITECTURE" in
29+
aarch64) ARCHITECTURE=arm64;;
30+
arm) ARCHITECTURE=armhf;;
31+
amd64|x86_64) ARCHITECTURE=amd64;;
32+
x86|i*86) ARCHITECTURE=i386;;
33+
*)
34+
printf "\x1b[38;5;214m[${time1}]\e[0m \x1b[38;5;203m[ERROR]:\e[0m \x1b[38;5;87m Unknown architecture :- $ARCHITECTURE"
35+
exit 1
36+
;;
37+
38+
esac
39+
40+
wget http://cdimage.ubuntu.com/ubuntu-base/releases/${UBUNTU_VERSION}/release/ubuntu-base-${UBUNTU_VERSION}-base-${ARCHITECTURE}.tar.gz -q -O ubuntu.tar.gz
41+
printf "\x1b[38;5;214m[${time1}]\e[0m \x1b[38;5;83m[Installer thread/INFO]:\e[0m \x1b[38;5;87m Download complete!\n"
42+
43+
fi
44+
45+
cur=`pwd`
46+
mkdir -p $directory
47+
cd $directory
48+
printf "\x1b[38;5;214m[${time1}]\e[0m \x1b[38;5;83m[Installer thread/INFO]:\e[0m \x1b[38;5;87m Decompressing the ubuntu rootfs, please wait...\n"
49+
proot --link2symlink tar -zxf $cur/ubuntu.tar.gz --exclude='dev'||:
50+
printf "\x1b[38;5;214m[${time1}]\e[0m \x1b[38;5;83m[Installer thread/INFO]:\e[0m \x1b[38;5;87m The ubuntu rootfs have been successfully decompressed!\n"
51+
printf "\x1b[38;5;214m[${time1}]\e[0m \x1b[38;5;83m[Installer thread/INFO]:\e[0m \x1b[38;5;87m Fixing the resolv.conf, so that you have access to the internet\n"
52+
printf "nameserver 8.8.8.8\nnameserver 8.8.4.4\n" > etc/resolv.conf
53+
stubs=()
54+
stubs+=('usr/bin/groups')
55+
for f in ${stubs[@]};do
56+
printf "\x1b[38;5;214m[${time1}]\e[0m \x1b[38;5;83m[Installer thread/INFO]:\e[0m \x1b[38;5;87m Writing stubs, please wait...\n"
57+
echo -e "#!/bin/sh\nexit" > "$f"
58+
done
59+
printf "\x1b[38;5;214m[${time1}]\e[0m \x1b[38;5;83m[Installer thread/INFO]:\e[0m \x1b[38;5;87m Successfully wrote stubs!\n"
60+
cd $cur
61+
62+
fi
63+
64+
mkdir -p ubuntu-binds
65+
bin=startubuntu.sh
66+
printf "\x1b[38;5;214m[${time1}]\e[0m \x1b[38;5;83m[Installer thread/INFO]:\e[0m \x1b[38;5;87m Creating the start script, please wait...\n"
67+
cat > $bin <<- EOM
68+
#!/bin/bash
69+
cd \$(dirname \$0)
70+
## unset LD_PRELOAD in case termux-exec is installed
71+
unset LD_PRELOAD
72+
command="proot"
73+
command+=" --link2symlink"
74+
command+=" -0"
75+
command+=" -r $directory"
76+
if [ -n "\$(ls -A ubuntu-binds)" ]; then
77+
for f in ubuntu-binds/* ;do
78+
. \$f
79+
done
80+
fi
81+
command+=" -b /dev"
82+
command+=" -b /proc"
83+
command+=" -b /sys"
84+
command+=" -b ubuntu-fs/tmp:/dev/shm"
85+
command+=" -b /data/data/com.termux"
86+
command+=" -b /:/host-rootfs"
87+
command+=" -b /sdcard"
88+
command+=" -b /storage"
89+
command+=" -b /mnt"
90+
command+=" -w /root"
91+
command+=" /usr/bin/env -i"
92+
command+=" HOME=/root"
93+
command+=" PATH=/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/games:/usr/local/games"
94+
command+=" TERM=\$TERM"
95+
command+=" LANG=C.UTF-8"
96+
command+=" /bin/bash --login"
97+
com="\$@"
98+
if [ -z "\$1" ];then
99+
exec \$command
100+
else
101+
\$command -c "\$com"
102+
fi
103+
EOM
104+
printf "\x1b[38;5;214m[${time1}]\e[0m \x1b[38;5;83m[Installer thread/INFO]:\e[0m \x1b[38;5;87m The start script has been successfully created!\n"
105+
printf "\x1b[38;5;214m[${time1}]\e[0m \x1b[38;5;83m[Installer thread/INFO]:\e[0m \x1b[38;5;87m Fixing shebang of startubuntu.sh, please wait...\n"
106+
termux-fix-shebang $bin
107+
printf "\x1b[38;5;214m[${time1}]\e[0m \x1b[38;5;83m[Installer thread/INFO]:\e[0m \x1b[38;5;87m Successfully fixed shebang of startubuntu.sh! \n"
108+
printf "\x1b[38;5;214m[${time1}]\e[0m \x1b[38;5;83m[Installer thread/INFO]:\e[0m \x1b[38;5;87m Making startubuntu.sh executable please wait...\n"
109+
chmod +x $bin
110+
printf "\x1b[38;5;214m[${time1}]\e[0m \x1b[38;5;83m[Installer thread/INFO]:\e[0m \x1b[38;5;87m Successfully made startubuntu.sh executable\n"
111+
printf "\x1b[38;5;214m[${time1}]\e[0m \x1b[38;5;83m[Installer thread/INFO]:\e[0m \x1b[38;5;87m Cleaning up please wait...\n"
112+
rm ubuntu.tar.gz -rf
113+
printf "\x1b[38;5;214m[${time1}]\e[0m \x1b[38;5;83m[Installer thread/INFO]:\e[0m \x1b[38;5;87m Successfully cleaned up!\n"
114+
printf "\x1b[38;5;214m[${time1}]\e[0m \x1b[38;5;83m[Installer thread/INFO]:\e[0m \x1b[38;5;87m The installation has been completed! You can now launch Ubuntu with ./startubuntu.sh\n"
115+
printf "\e[0m"
116+
117+
}
118+
if [ "$1" = "-y" ];then
119+
install1
120+
elif [ "$1" = "" ];then
121+
printf "\x1b[38;5;214m[${time1}]\e[0m \x1b[38;5;127m[QUESTION]:\e[0m \x1b[38;5;87m Do you want to install ubuntu-in-termux? [Y/n] "
122+
123+
read cmd1
124+
if [ "$cmd1" = "y" ];then
125+
install1
126+
elif [ "$cmd1" = "Y" ];then
127+
install1
128+
else
129+
printf "\x1b[38;5;214m[${time1}]\e[0m \x1b[38;5;203m[ERROR]:\e[0m \x1b[38;5;87m Installation aborted.\n"
130+
printf "\e[0m"
131+
exit
132+
fi
133+
else
134+
printf "\x1b[38;5;214m[${time1}]\e[0m \x1b[38;5;203m[ERROR]:\e[0m \x1b[38;5;87m Installation aborted.\n"
135+
printf "\e[0m"
136+
fi

0 commit comments

Comments
 (0)