-
Notifications
You must be signed in to change notification settings - Fork 10
/
install-fedora-gnome-desktop
executable file
·288 lines (268 loc) · 8.81 KB
/
install-fedora-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
#!/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 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 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
banner
read -p "${R} [${W}-${R}]${Y}Do you want to install VLC (y/n) "${W} vlc_answer
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}"
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/fedora" ]]; then
rm -rf /data/data/com.termux/files/usr/bin/fedora
fi
fi
}
function update_sys() {
banner
echo "${R} [${W}-${R}]${G}Updating fedora's System..."
dnf update -y
}
function setup_tx11() {
echo "${G} Fixing gnome black screen issue..."${W}
find /usr -type f -iname "*login1*" -exec rm -f {} \; && mkdir /run/dbus
sleep 2
if [ "$useradd_answer" == "y" ]; then
final_user="$user_name"
else
final_user="root"
fi
cat <<EOF >> "/data/data/com.termux/files/usr/bin/fedora"
if [ "\$1" = "-tx11" ]; then
pkill -f com.termux.x11 2>/dev/null
pulseaudio --start --load="module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" --exit-idle-time=-1
export XDG_RUNTIME_DIR=\${TMPDIR}
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 fedora --shared-tmp -- /bin/bash -c 'export DISPLAY=:0 XDG_RUNTIME_DIR=\${TMPDIR} PULSE_SERVER=127.0.0.1 XDG_CURRENT_DESKTOP="GNOME" && rm -rf /run/dbus/pid && dbus-daemon --system && su - $final_user -c "env DISPLAY=:0 dbus-launch gnome-shell --x11"'
elif [ "\$1" = "-remove" ]; then
proot-distro remove fedora
rm \$PREFIX/bin/fedora
elif [ "\$1" = "-r" ]; then
proot-distro login fedora
else
proot-distro login --user $final_user fedora
fi
EOF
chmod +x /data/data/com.termux/files/usr/bin/fedora
}
# function login() {
# banner
# if [ "$useradd_answer" = "y" ]; then
# useradd -m -s $(which bash) ${user_name}
# echo "${user_name}:${pass}" | chpasswd
# echo "$user_name ALL=(ALL:ALL) ALL" >> /etc/sudoers
# fi
# clear
# }
function vlc_installer() {
banner
if [ "$vlc_answer" == "y" ]; then
echo "${R} [${W}-${R}]${G}Installing vlc.."${W}
dnf install vlc -y
else
echo "${R} [${W}-${R}]${C}Canceling Vlc Installation...."${W}
sleep 1.5
fi
}
function install_chromium() {
banner
echo "${R} [${W}-${R}]${G} installing chromium..."${W}
dnf install chromium -y
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
dnf install firefox -y
}
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 package() {
banner
echo -e "${R} [${W}-${R}]${C} Checking required packages..."${W}
dnf install sudo dbus -y
}
function install_desktop() {
echo "${R} [${W}-${R}]${G}Installing Gnome Core.."${W}
sleep 2
update_sys
dnf install gnome-shell gnome-terminal gnome-software gnome-tweaks -y
clear
}
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}"
pacman -Sy 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 fedora "${W}
echo
echo -e "${G}Type ${C}fedora${G} to login into fedora "${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
questions
get_sys_info
update_sys
package
login
install_desktop
browser_installer
vlc_installer
add_sound
check_install
setup_tx11
note