Upload ubuntu.sh
Browse files
ubuntu.sh
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/data/data/com.termux/files/usr/bin/bash
|
2 |
+
folder=ubuntu-fs
|
3 |
+
if [ -d "$folder" ]; then
|
4 |
+
first=1
|
5 |
+
echo "skipping downloading"
|
6 |
+
fi
|
7 |
+
tarball="ubuntu-rootfs.tar.xz"
|
8 |
+
if [ "$first" != 1 ];then
|
9 |
+
if [ ! -f $tarball ]; then
|
10 |
+
echo "Download Rootfs, this may take a while base on your internet speed."
|
11 |
+
case `dpkg --print-architecture` in
|
12 |
+
aarch64)
|
13 |
+
archurl="arm64" ;;
|
14 |
+
arm)
|
15 |
+
archurl="armhf" ;;
|
16 |
+
amd64)
|
17 |
+
archurl="amd64" ;;
|
18 |
+
x86_64)
|
19 |
+
archurl="amd64" ;;
|
20 |
+
i*86)
|
21 |
+
archurl="i386" ;;
|
22 |
+
x86)
|
23 |
+
archurl="i386" ;;
|
24 |
+
*)
|
25 |
+
echo "unknown architecture"; exit 1 ;;
|
26 |
+
esac
|
27 |
+
wget "https://raw.githubusercontent.com/EXALAB/AnLinux-Resources/master/Rootfs/Ubuntu/${archurl}/ubuntu-rootfs-${archurl}.tar.xz" -O $tarball
|
28 |
+
fi
|
29 |
+
cur=`pwd`
|
30 |
+
mkdir -p "$folder"
|
31 |
+
cd "$folder"
|
32 |
+
echo "Decompressing Rootfs, please be patient."
|
33 |
+
proot --link2symlink tar -xJf ${cur}/${tarball}||:
|
34 |
+
cd "$cur"
|
35 |
+
fi
|
36 |
+
mkdir -p ubuntu-binds
|
37 |
+
bin=start-ubuntu.sh
|
38 |
+
echo "writing launch script"
|
39 |
+
cat > $bin <<- EOM
|
40 |
+
#!/bin/bash
|
41 |
+
cd \$(dirname \$0)
|
42 |
+
pulseaudio --start
|
43 |
+
## For rooted user: pulseaudio --start --system
|
44 |
+
## unset LD_PRELOAD in case termux-exec is installed
|
45 |
+
unset LD_PRELOAD
|
46 |
+
command="proot"
|
47 |
+
command+=" --link2symlink"
|
48 |
+
command+=" -0"
|
49 |
+
command+=" -r $folder"
|
50 |
+
if [ -n "\$(ls -A ubuntu-binds)" ]; then
|
51 |
+
for f in ubuntu-binds/* ;do
|
52 |
+
. \$f
|
53 |
+
done
|
54 |
+
fi
|
55 |
+
command+=" -b /dev"
|
56 |
+
command+=" -b /proc"
|
57 |
+
command+=" -b ubuntu-fs/root:/dev/shm"
|
58 |
+
## uncomment the following line to have access to the home directory of termux
|
59 |
+
#command+=" -b /data/data/com.termux/files/home:/root"
|
60 |
+
## uncomment the following line to mount /sdcard directly to /
|
61 |
+
command+=" -b /sdcard"
|
62 |
+
command+=" -w /root"
|
63 |
+
command+=" /usr/bin/env -i"
|
64 |
+
command+=" HOME=/root"
|
65 |
+
command+=" PATH=/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/games:/usr/local/games"
|
66 |
+
command+=" TERM=\$TERM"
|
67 |
+
command+=" LANG=C.UTF-8"
|
68 |
+
command+=" /bin/bash --login"
|
69 |
+
com="\$@"
|
70 |
+
if [ -z "\$1" ];then
|
71 |
+
exec \$command
|
72 |
+
else
|
73 |
+
\$command -c "\$com"
|
74 |
+
fi
|
75 |
+
EOM
|
76 |
+
|
77 |
+
echo "Setting up pulseaudio so you can have music in distro."
|
78 |
+
|
79 |
+
apt install pulseaudio -y
|
80 |
+
|
81 |
+
if grep -q "anonymous" ~/../usr/etc/pulse/default.pa;then
|
82 |
+
echo "module already present"
|
83 |
+
else
|
84 |
+
echo "load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" >> ~/../usr/etc/pulse/default.pa
|
85 |
+
fi
|
86 |
+
|
87 |
+
echo "exit-idle-time = -1" >> ~/../usr/etc/pulse/daemon.conf
|
88 |
+
echo "Modified pulseaudio timeout to infinite"
|
89 |
+
echo "autospawn = no" >> ~/../usr/etc/pulse/client.conf
|
90 |
+
echo "Disabled pulseaudio autospawn"
|
91 |
+
echo "export PULSE_SERVER=127.0.0.1" >> ubuntu-fs/etc/profile
|
92 |
+
echo "Setting Pulseaudio server to 127.0.0.1"
|
93 |
+
|
94 |
+
echo "fixing shebang of $bin"
|
95 |
+
termux-fix-shebang $bin
|
96 |
+
echo "making $bin executable"
|
97 |
+
chmod +x $bin
|
98 |
+
echo "removing image for some space"
|
99 |
+
echo "You can now launch Ubuntu with the ./${bin} script"
|