-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathInstall.sh
336 lines (303 loc) · 9.68 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
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
#!/data/data/com.termux/files/usr/bin/bash
PD=$PREFIX/var/lib/proot-distro/installed-rootfs
ds_name=ubuntu
clear
# Colours
R="$(printf '\033[1;31m')"
G="$(printf '\033[1;32m')"
Y="$(printf '\033[1;33m')"
W="$(printf '\033[1;37m')"
C="$(printf '\033[1;36m')"
## ask() - prompt the user with a message and wait for a Y/N answer
## copied from udroid
ask() {
local msg=$*
echo -ne "$msg\t[y/n]: "
read -r choice
case $choice in
y|Y|yes) return 0;;
n|N|No) return 1;;
"") return 0;;
*) return 1;;
esac
}
## download_script() - download a script online
download_script() {
local url=$1
local dir=$2
local mode=$3
script=$(echo $url | awk -F / '{print $NF}')
case $mode in
verbose) WGET="wget --show-progress" ;;
silence) WGET="wget -q --show-progress" ;;
*) WGET="wget" ;;
esac
$WGET $url -P $dir
}
# Install proot-distro
requirements() {
echo ${G}"This is a script to install ubuntu in proot-distro"
sleep 1
echo ${G}"Installing required packages..."${W}
pkg install pulseaudio proot-distro wget -y
[[ ! -d "$HOME/storage" ]] && {
echo ${C}"Please allow storage permission"${W}
termux-setup-storage
}
[[ ! -d "$PREFIX/var/lib/proot-distro" ]] && {
mkdir -p $PREFIX/var/lib/proot-distro
mkdir -p $PREFIX/var/lib/proot-distro/installed-rootfs
}
echo
[[ -d "$PD/$ds_name" ]] && {
if ask ${Y}"Existing ubuntu found, remove it?"${W}; then
echo ""
echo ${Y}"Deleting existing directory...."${W}
proot-distro remove ubuntu || ( echo ${R}"Cannot remove existing directory.." && exit 1 )
else
echo ${R}"Sorry, but we cannot complete the installation"
exit 1
fi
}
}
# Pick desktop
choose_desktop() {
clear
echo ${C}"Please choose your desktop"${Y}
echo " 1) XFCE (Light Weight)"
echo " 2) GNOME (Default desktop of ubuntu) "
echo " 3) MATE "
echo " 4) Windows 10 (KDE with custom themes)"
echo " 5) Windows 11 (GNOME with custom themes)"
echo " 6) MacOS (XFCE with custom themes)"
echo " 7) Cinnamon "
echo ${C}"Please enter number 1-7 to choose your desktop "
echo ${C}"If you don't want a desktop please just enter '${W}CLI${C}'"${W}
read desktop
sleep 1
case $desktop in
1|2|3|4|5|6|7) echo ${G}"Lets start the installation"${Y} ;;
CLI) echo ${G}"Install raw ubuntu..."${Y} ;;
*) echo ${R}"Invalid answer"; sleep 1 ; choose_desktop ;;
esac
}
# Install and Setup ubuntu
configures() {
proot-distro install ubuntu
echo ${G}"Installing requirements in ubuntu..."${W}
cat > $PD/$ds_name/root/.bashrc <<- EOF
apt-get update
apt install sudo nano wget openssl git -y
exit
echo
EOF
proot-distro login ubuntu
rm -rf $PD/$ds_name/root/.bashrc
}
# Ask if setup a user
user() {
clear
if ask ${C}"Do you want to add a user"${W}; then
echo ""
echo ${C}"Please enter a username : "${W}
read username
directory=$PD/$ds_name/home/$username
login="proot-distro login ubuntu --user $username"
echo ""
sleep 1
echo ${G}"Adding a user ...."
cat > $PD/$ds_name/root/.bashrc <<- EOF
useradd -m \
-G sudo \
-d /home/${username} \
-k /etc/skel \
-s /bin/bash \
$username
echo $username ALL=\(root\) ALL > /etc/sudoers.d/$username
chmod 0440 /etc/sudoers.d/$username
echo "$username ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
exit
echo
EOF
proot-distro login ubuntu
rm -rf $PD/$ds_name/root/.bashrc
sleep 2
[[ ! -d $directory ]] && {
echo -e ${R}"Failed to add user\nKeep installation as root"
directory=$PD/$ds_name/root
login="proot-distro login ubuntu"
}
clear
else
echo ""
echo ${G}"The installation will be completed as root"
sleep 2
clear
directory=$PD/$ds_name/root
login="proot-distro login ubuntu"
fi
}
# install specific desktop
install_desktop() {
desk=true
case $desktop in
1) xfce_mode ;;
2) gnome_mode ;;
3) mate_mode ;;
4) kde_mode ; win10_theme ;;
5) gnome_mode ; win11_theme ;;
6) xfce_mode ; macos_theme ;;
7) cinnamon_mode ;;
*) echo ${G}"No desktop selected , skipping ...." ; desk=false ; sleep 2 ;;
esac
# if desktop is installed, also install external apps
if $desk ; then
apps
fi
}
# Different mode to download different scripts
xfce_mode() {
echo ${G}"Installing XFCE Desktop..."${W}
download_script "https://raw.githubusercontent.com/23xvx/Termux-Ubuntu-Installer/main/Desktop/xfce.sh" $directory silence
$login -- /bin/bash xfce.sh
rm -rf $directory/xfce.sh
}
gnome_mode() {
echo ${G}"Installing GNOME Desktop...."${W}
download_script "https://raw.githubusercontent.com/23xvx/Termux-Ubuntu-Installer/main/Desktop/gnome.sh" $directory silence
$login -- /bin/bash gnome.sh
rm -rf $directory/gnome.sh
}
mate_mode() {
echo ${G}"Installing Mate Desktop..."${W}
download_script "https://raw.githubusercontent.com/23xvx/Termux-Ubuntu-Installer/main/Desktop/mate.sh" $directory silence
$login -- /bin/bash mate.sh
rm -rf $directory/mate.sh
}
kde_mode() {
echo ${G}"Installing KDE Desktop..."${W}
download_script "https://raw.githubusercontent.com/23xvx/Termux-Ubuntu-Installer/main/Desktop/kde.sh" $directory silence
$login -- /bin/bash kde.sh
rm -rf $directory/kde.sh
}
cinnamon_mode() {
echo ${G}"Installing Cinnamon Desktop..."${W}
download_script "https://raw.githubusercontent.com/23xvx/Termux-Ubuntu-Installer/main/Desktop/cinnamon.sh" $directory silence
$login -- /bin/bash cinnamon.sh
rm -rf $directory/cinnamon.sh
}
win10_theme() {
download_script "https://raw.githubusercontent.com/23xvx/Termux-Ubuntu-Installer/main/Themes/Win10-theme.sh" $directory silence
$login -- /bin/bash Win10-theme.sh
rm -rf $directory/Win10-theme.sh
}
win11_theme() {
download_script "https://raw.githubusercontent.com/23xvx/Termux-Ubuntu-Installer/main/Themes/Win11-theme.sh" $directory silence
$login -- /bin/bash Win11-theme.sh
rm -rf $directory/Win11-theme.sh
}
macos_theme() {
download_script "https://raw.githubusercontent.com/23xvx/Termux-Ubuntu-Installer/main/Themes/MacOS-theme.sh" $directory silence
$login -- /bin/bash MacOS-theme.sh
rm -rf $directory/MacOS-theme.sh
}
# Install external apps
apps() {
clear
# Install firefox
if ask ${C}"Install Firefox Web Broswer?"${W}; then
echo -e ${G}"\nInstalling Firefox Broswer ...." ${W}
download_script "https://raw.githubusercontent.com/23xvx/Termux-Ubuntu-Installer/main/Apps/firefox.sh" $directory silence
[[ -f $directory/.bashrc ]] && mv $directory/.bashrc $directory/.bak
cat > $directory/.bashrc <<- EOF
bash firefox.sh
clear
vncstart
sleep 4
DISPLAY=:1 firefox-esr &
sleep 10
pkill -f firefox-esr
vncstop
sleep 2
exit
echo
EOF
$login
echo 'user_pref("sandbox.cubeb", false);
user_pref("security.sandbox.content.level", 1);' >> $directory/.mozilla/firefox-esr/*default-esr*/prefs.js
rm -rf $directory/.bashrc
mv $directory/.bak $directory/.bashrc
clear
sleep 1
else
echo -e ${G}"\nNot installing , skip process..\n"${W}
sleep 1
fi
# Install discord(webcord)
if ask ${C}"Install Discord (Webcord)?"${W}; then
echo -e ${G}"\nInstalling Discord ...." ${W}
download_script "https://raw.githubusercontent.com/23xvx/Termux-Ubuntu-Installer/main/Apps/webcord.sh" $directory silence
$login -- /bin/bash webcord.sh
rm $directory/webcord.sh
clear
else
echo -e ${G}"\nNot installing , skip process..\n" ${W}
sleep 1
fi
# Install VScode
if ask ${C}"Install VScode?"${W}; then
echo -e ${G}"\nInstalling Vscode ...." ${W}
download_script "https://raw.githubusercontent.com/23xvx/Termux-Ubuntu-Installer/main/Apps/vscodefix.sh" $directory silence
$login -- /bin/bash vscodefix.sh
rm $directory/vscodefix.sh
else
echo -e ${G}"\nNot installing , skip process..\n" ${W}
sleep 1
fi
clear
}
# Write startup scripts
fixes() {
[[ -f $PREFIX/bin/start-ubuntu ]] && rm $PREFIX/bin/start-ubuntu
echo "pulseaudio \
--start --load='module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1' \
--exit-idle-time=-1" >> $PREFIX/bin/start-ubuntu
if [[ -z $username ]]; then
echo "proot-distro login ubuntu --shared-tmp" >> $PREFIX/bin/start-ubuntu
else
echo "proot-distro login ubuntu --shared-tmp --user $username" >> $PREFIX/bin/start-ubuntu
fi
chmod +x $PREFIX/bin/start-ubuntu
[[ ! -f "$directory/.bashrc " ]] && {
cp $directory/etc/skel/.bashrc $directory
}
echo "export PULSE_SERVER=127.0.0.1" >> $directory/.bashrc
}
# End
finish () {
clear
sleep 2
echo ${G}"Installation Complete"
echo ""
echo " start-ubuntu To Start Ubuntu "
echo ""
[[ $desk == "true" ]] && {
echo " vncstart To start vncserver (In Ubuntu)"
echo ""
echo " vncstop To stop vncserver (In Ubuntu)"
echo ""
}
echo ${Y}"Notice : You cannot install it by proot-distro after removing it."
}
# Main program
main () {
requirements
choose_desktop
configures
user
install_desktop
fixes
finish
}
# call main program
main