-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathinstall-gnome-desktop
executable file
·385 lines (360 loc) · 11.6 KB
/
install-gnome-desktop
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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
#!/bin/bash
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')"
function banner() {
clear
printf "\033[33m╭━━━╮╱╱╱╱╱╱╱╱╱╱╱╱╭━━╮╱╱╱╭━━━━╮\033[0m\n"
printf "\033[33m┃╭━╮┃╱╱╱╱╱╱╱╱╱╱╱╱╰┫┣╯╱╱╱┃╭╮╭╮┃\033[0m\n"
printf "\033[33m┃┃╱╰╋━╮╭━━┳╮╭┳━━╮╱┃┃╭━╮╱╰╯┃┃┣┻━┳━┳╮╭┳╮╭┳╮╭╮\033[0m\n"
printf "\033[33m┃┃╭━┫╭╮┫╭╮┃╰╯┃┃━┫╱┃┃┃╭╮╮╱╱┃┃┃┃━┫╭┫╰╯┃┃┃┣╋╋╯\033[0m\n"
printf "\033[33m┃╰┻━┃┃┃┃╰╯┃┃┃┃┃━┫╭┫┣┫┃┃┃╱╱┃┃┃┃━┫┃┃┃┃┃╰╯┣╋╋╮\033[0m\n"
printf "\033[33m╰━━━┻╯╰┻━━┻┻┻┻━━╯╰━━┻╯╰╯╱╱╰╯╰━━┻╯╰┻┻┻━━┻╯╰╯\033[0m\n"
echo "${C}${BOLD} Install Gnome Desktop In Termux ${W}"
echo
}
function package_install_and_check() {
packs_list=($@)
for package_name in "${packs_list[@]}"; do
echo "${R}[${W}-${R}]${G}${BOLD} Installing package: ${C}$package_name "${W}
apt install "$package_name" -y
if [ $? -ne 0 ]; then
apt --fix-broken install -y
dpkg --Configuring -a
fi
if dpkg -s "$package_name" >/dev/null 2>&1; then
echo "${R}[${W}-${R}]${G} $package_name installed successfully "${W}
else
if
type -p "$package_name" &>/dev/null || [ -e "$PREFIX/bin/$package_name"* ] || [ -e "$PREFIX/bin/"*"$package_name" ]; then
echo "${R}[${W}-${R}]${C} $package_name ${G}installed successfully "${W}
fi
fi
done
}
function check_root(){
if [ $EUID -ne 0 ]; then
echo -ne " ${R}Please Login Into Root User Then Run it Again!\n\n"${W}
exit 1
fi
}
function questions() {
banner
echo
echo "${R} [${W}-${R}]${G}Select the Gnome Desktop type"${W}
echo
echo "${Y}1. Full (~3.5Gb of space)"${W}
echo
echo "${Y}2. Core (~1.5GB of space)"${W}
echo
read -p "${Y}select an option (Default 1): "${W} answer_desktop
answer_desktop=${answer_desktop:-1}
echo
echo "${R}[${W}-${R}]${G}Continuing with answer: $answer_desktop"${W}
sleep 0.2
banner
echo
echo "${R} [${W}-${R}]${G}Select browser you want to install"${W}
echo
echo "${Y}1. firefox"${W}
echo
echo "${Y}2. chromium"${W}
echo
echo "${Y}3. firefox & chromium (both)"${W}
echo
read -p "${Y}select an option (Default 1): "${W} answer_browser
answer_browser=${answer_browser:-1}
echo
echo "${R}[${W}-${R}]${G}Continuing with answer: $answer_browser"${W}
sleep 0.2
banner
read -p "${R} [${W}-${R}]${Y}Do you want to install VLC (y/n) "${W} vlc_answer
vlc_answer=${vlc_answer:-y}
echo
echo "${R}[${W}-${R}]${G}Continuing with answer: $vlc_answer"${W}
sleep 0.2
banner
read -p "${R} [${W}-${R}]${Y}Do you want to create a normal user account (y/n) "${W} useradd_answer
useradd_answer="${useradd_answer:-y}"
echo "${R}[${W}-${R}]${G}Continuing with answer: $useradd_answer"${W}
sleep 0.2
banner
if [[ "$useradd_answer" == "n" ]]; then
banner
echo "${R} [${W}-${R}]${G}Skiping User Account Setup"${W}
else
echo "${R} [${W}-${R}]${G}Create user account"${W}
echo
while true; do
read -p "${R} [${W}-${R}]${G}Input username [Lowercase]: "${W} user_name
echo
read -p "${R} [${W}-${R}]${G}Input Password: "${W} pass
echo
read -p "${R} [${W}-${R}]${Y}Do you want to continue with username ${C}$user_name ${Y}and password ${C}$pass${Y} ? (y/n) : " choice
choice="${choice:-y}"
case $choice in
[yY]* )
echo "${R} [${W}-${R}]${G}Continuing with username ${C}$user_name ${G}and password ${C}$pass"
sleep 0.3
break;;
[nN]* )
echo "${G}Skipping useradd step"${W}
sleep 0.3
break;;
* )
echo "${R}Invalid input. Please enter 'y' or 'n'."${W}
;;
esac
done
fi
}
function get_sys_info() {
if [ -f /etc/os-release ]; then
. /etc/os-release
if [[ -e "/data/data/com.termux/files/usr/bin/$ID" ]]; then
rm -rf /data/data/com.termux/files/usr/bin/$ID
fi
fi
}
function update_sys() {
banner
echo "${R} [${W}-${R}]${G}Updating ${ID}'s System..."
apt update && apt-get update
}
function setup_tx11() {
if [ "$useradd_answer" == "y" ]; then
final_user="$user_name"
else
final_user="root"
fi
cat <<EOF >> "/data/data/com.termux/files/usr/bin/$ID"
session_dir="\$HOME/.cache/sessions"
if [ -d "\$session_dir" ]; then
files_to_remove=\$(find "\$session_dir" -type f -name 'x*')
if [ -n "\$files_to_remove" ]; then
rm "\$session_dir"/x* > /dev/null 2>&1
fi
fi
if [ "\$1" = "-remove" ]; then
proot-distro remove $ID
rm /data/data/com.termux/files/home/.${ID}-sound-service
rm \$PREFIX/bin/$ID
elif [ "\$1" = "-r" ]; then
proot-distro login $ID
elif [ "\$1" = "-tx11" ]; then
pkill -f com.termux.x11 2>/dev/null
termux-x11 :0 >/dev/null &
sleep 3
am start --user 0 -n com.termux.x11/com.termux.x11.MainActivity > /dev/null 2>&1
sleep 1
proot-distro login $ID --user $final_user --shared-tmp -- /bin/bash -c "sudo service dbus start && export XDG_CURRENT_DESKTOP="GNOME" && env DISPLAY=:0 gnome-shell --x11"
exit 0
else
proot-distro login --user $final_user $ID
fi
EOF
chmod +x /data/data/com.termux/files/usr/bin/$ID
echo -e "${R} [${W}-${R}]${C} Fixing Login Issue.."${W}
for file in $(find /usr -type f -iname "*login1*"); do rm -rf $file
done
}
function login() {
banner
if [ "$useradd_answer" == "y" ]; then
groupadd storage
groupadd wheel
useradd -m -g users -s $(which bash) ${user_name}
usermod -aG wheel,polkitd,audio,video,storage ${user_name}
echo "${user_name}:${pass}" | chpasswd
apt install sudo -y
echo "$user_name ALL=(ALL:ALL) ALL" | tee -a /etc/sudoers
fi
}
function vlc_installer() {
banner
if [ "$vlc_answer" == "y" ]; then
echo "${R} [${W}-${R}]${G}Installing vlc.."${W}
package_install_and_check "vlc"
else
echo "${R} [${W}-${R}]${C}Canceling Vlc Installation...."${W}
sleep 1.5
fi
}
function install_chromium() {
banner
echo -e "${R} [${W}-${R}]${G} installing chromium..."${W}
if [ "$ID" == "ubuntu" ]; then
wget https://raw.githubusercontent.com/sabamdarif/gnome-in-termux/main/patch/chromium.sh
bash chromium.sh
rm chromium.sh
else
package_install_and_check "chromium"
fi
sed -i 's/chromium %U/chromium --no-sandbox %U/g' /usr/share/applications/chromium.desktop
}
function firefox_install() {
clear
banner
sleep 1
clear
echo "${R} [${W}-${R}]${Y} Installing Firefox..."${W}
echo
echo
if [ "$ID" == "ubuntu" ]; then
wget https://raw.githubusercontent.com/sabamdarif/gnome-in-termux/main/patch/firefox.sh
bash firefox.sh
rm firefox.sh
else
package_install_and_check "firefox-esr"
fi
}
function browser_installer() {
banner
if [[ ${answer_browser} == "1" ]]; then
firefox_install
elif [[ ${answer_browser} == "2" ]]; then
install_chromium
elif [[ ${answer_browser} == "3" ]]; then
firefox_install
install_chromium
elif [[ ${answer_browser} == "" ]]; then
firefox_install
else
firefox_install
fi
}
function install_gnome_core() {
echo "${R} [${W}-${R}]${G}Installing Gnome Core.."${W}
sleep 2
package_install_and_check "gnome-shell gnome-terminal gnome-tweaks gnome-software nautilus gnome-shell-extension-manager"
clear
}
function install_gnome_full() {
echo "${R} [${W}-${R}]${G}Installing Gnome Full.."${W}
sleep 2
if [ "${ID}" == "ubuntu" ]; then
package_install_and_check "ubuntu-gnome-desktop gnome-tweaks gnome-software gnome-shell-extension-manager"
elif [ "${ID}" == "kali" ]; then
package_install_and_check "kali-desktop-gnome gnome-software gnome-tweaks gnome-shell-extension-manager"
elif [ "${ID}" == "debian" ]; then
package_install_and_check "gnome"
else
echo "${G}Installing Gnome Core First"${W}
sleep 1
install_gnome_core
package_install_and_check "gnome"
fi
clear
}
function package() {
banner
echo -e "${R} [${W}-${R}]${C} Checking required packages..."${W}
apt update
package_install_and_check "sudo nano wget software-properties-common gnupg2 dbus-x11"
}
function install_desktop() {
banner
if [[ "${answer_desktop}" == "1" ]]; then
install_gnome_full
elif [[ "${answer_desktop}" == "2" ]]; then
install_gnome_core
elif [[ "${answer_desktop}" == "" ]]; then
install_gnome_full
fi
}
function add_sound() {
echo -e "\n${R} [${W}-${R}]${C} Fixing Sound Problem..."${W}
if [[ ! -e "/data/data/com.termux/files/home/.${ID}-sound-service" ]]; then
touch /data/data/com.termux/files/home/.${ID}-sound-service
fi
echo "pulseaudio --start --exit-idle-time=-1" >> /data/data/com.termux/files/home/.${ID}-sound-service
echo "pacmd load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" >> /data/data/com.termux/files/home/.${ID}-sound-service
echo "$(echo "bash ~/.${ID}-sound-service" | cat - /data/data/com.termux/files/usr/bin/$ID )" > /data/data/com.termux/files/usr/bin/$ID
echo "export PULSE_SERVER=127.0.0.1" >> /etc/profile
source /etc/profile
}
function check_firefox() {
echo "${R} [${W}-${R}]${Y}Checking if Firefox is installed or not...${W}"
if ! type -p "firefox" &>/dev/null; then
sleep 2
echo "${R} [${W}-${R}]${R}Firefox not installed...${W}"
firefox_install
else
echo "${R} [${W}-${R}]${G}Firefox is already installed.${W}"
fi
}
function check_chromium() {
echo "${R} [${W}-${R}]${Y}Checking if Chromium is installed or not...${W}"
if ! type -p "chromium" &>/dev/null; then
sleep 2
echo "${R} [${W}-${R}]${R}Chromium is not installed...${W}"
install_chromium
else
echo "${R} [${W}-${R}]${G}Chromium is already installed.${W}"
fi
}
function check_install() {
echo "${R} [${W}-${R}]${Y}Checking if everything is installed or not...${W}"
sleep 1
# Desktop check
echo "${R} [${W}-${R}]${Y}Checking if GNOME installed...${W}"
if ! type -p "gnome-shell" &>/dev/null; then
sleep 2
echo "${R} [${W}-${R}]${R}GNOME Desktop is not installed perfectly...${W}"
echo "${G}Fixing ..."${W}
sleep 2
install_desktop
else
echo "${R} [${W}-${R}]${G}GNOME Desktop is Installed Successfully...${W}"
sleep 2
fi
# Browser check
if [[ "${answer_browser}" == "1" ]]; then
check_firefox
elif [[ "${answer_browser}" == "2" ]]; then
check_chromium
elif [[ "${answer_browser}" == "3" ]]; then
check_firefox
check_chromium
else
check_firefox
fi
# VLC check
if [[ "${vlc_answer}" == "y" ]]; then
echo "${R} [${W}-${R}]${Y}Checking if VLC is installed or not...${W}"
if ! type -p "vlc" &>/dev/null; then
sleep 2
echo "${R} [${W}-${R}]${R}VLC is not installed, installing now...${W}"
apt install vlc -y
fi
fi
}
function note() {
banner
echo -e "${G} Successfully Installed !"${W}
sleep 3
echo
echo -e "${G}Now Restart Termux First And Login Into $ID "${W}
echo
echo -e "${G}Type ${C}$ID${G} to login into $ID "${W}
echo
echo "${C}Check the NOTE (👇) section in Github Readme to know all commands"${W}
echo
echo "https://github.com/sabamdarif/gnome-in-termux/blob/main/README.md#note"
echo
}
check_root
get_sys_info
questions
update_sys
package
login
install_desktop
browser_installer
vlc_installer
setup_tx11
add_sound
check_install
note