forked from LegitKnots/Prox-Kiox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
272 lines (238 loc) · 8.8 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
#!/bin/bash
echo ""
echo "-----------------------------------------------------------------------------------------------------------------------"
echo ""
echo ""
echo " ___ ___ ___ ___ ___ ___ ___ "
echo " /\\ \\ /\\ \\ /\\ \\ |\\__\\ /\\__\\ ___ /\\ \\ |\\__\\ "
echo " /::\\ \\ /::\\ \\ /::\\ \\ |:| | /:/ / /\\ \\ /::\\ \\ |:| | "
echo " /:/\\:\\ \\ /:/\\:\\ \\ /:/\\:\\ \\ |:| | /:/__/ \\:\\ \\ /:/\\:\\ \\ |:| | "
echo " /::\\~\\:\\ \\ /::\\~\\:\\ \\ /:/ \\:\\ \\ |:|__|__ /::\\__\\____ /::\\__\\ /:/ \\:\\ \\ |:|__|__ "
echo " /:/\\:\\ \\:\\__\\ /:/\\:\\ \\:\\__\\ /:/__/ \\:\\__\\ ____/::::\\__\\ /:/\\:::::\\__\\ __/:/\\/__/ /:/__/ \\:\\__\\ ____/::::\\__\\"
echo " \\/__\\:\\/:/ / \\/_|::\\/:/ / \\:\\ \\ /:/ / \\::::/~~/~ \\/_|:|~~|~ /\\/:/ / \\:\\ \\ /:/ / \\::::/~~/~ "
echo " \\::/ / |:|::/ / \\:\\ /:/ / ~~|:|~~| |:| | \\::/__/ \\:\\ /:/ / ~~|:|~~| "
echo " \\/__/ |:|\\/__/ \\:\\/:/ / |:| | |:| | \\:\\__\\ \\:\\/:/ / |:| | "
echo " |:| | \\::/ / |:| | |:| | \\/__/ \\::/ / |:| | "
echo " \\|__| \\/__/ \\|__| \\|__| \\/__/ \\|__| "
echo ""
echo ""
echo ""
echo "Version 1.4.5"
echo "--------Created by--------------"
echo ""
echo " _______ _____ ______ _______ "
echo "| _ |_| | __ \\ | |"
echo "| | | __/ |"
echo "|___|___|_______|___| |__|____|"
echo ""
echo ""
echo "-------In Part By---------------"
echo ""
echo " _ _ _____ _____ "
echo "| || / __\ \\ / / __|"
echo "| __ \\__ \\\ V /| _|"
echo "|_||_|___/ \\_/ |___|"
echo ""
echo "--------------------------------"
echo ""
echo ""
echo ""
echo "------------------------------------------------------------------"
read -p "Are you reinstalling prox-kiox? [Y/n]: " input
echo ""
input=${input:-Y}
input=${input,,}
## Just a redundant dir change incase not in that dir already
cd /root
if [[ $input == "y" ]]; then
echo "Killing processes..."
killall -q xinit
killall -q firefox-esr
killall -q openbox
echo "Removing old files..."
rm -f /usr/bin/prox-kiox
echo "Removing old dependencies..."
echo "No old dependencies"
echo "Cleaning..."
apt-get autoremove -y
echo "------------------------------------------------------------------"
echo "Done"
echo "------------------------------------------------------------------"
else
echo "------------------------------------------------------------------"
echo "Nothing old to remove"
echo "------------------------------------------------------------------"
echo ""
fi
echo "------------------------------------------------------------------"
echo "Updating the live server"
echo "------------------------------------------------------------------"
sleep 0.5
apt-get update > /dev/null && apt-get upgrade -y > /dev/null
apt-get autoremove -y > /dev/null
echo "------------------------------------------------------------------"
echo "Done"
echo "------------------------------------------------------------------"
echo ""
echo ""
echo "------------------------------------------------------------------"
echo "Installing dependencies: Firefox-ESR"
echo "------------------------------------------------------------------"
sleep 0.5
apt-get install -y firefox-esr > /dev/null
echo "------------------------------------------------------------------"
echo "Done!"
echo "------------------------------------------------------------------"
echo ""
echo ""
echo "------------------------------------------------------------------"
echo "Installing dependencies: Xinit"
echo "------------------------------------------------------------------"
sleep 0.5
apt-get install -y xinit > /dev/null
echo "------------------------------------------------------------------"
echo "Done!"
echo "------------------------------------------------------------------"
echo ""
echo ""
echo "------------------------------------------------------------------"
echo "Installing dependencies: X11 Utils"
echo "------------------------------------------------------------------"
sleep 0.5
apt-get install -y x11-utils > /dev/null
echo "------------------------------------------------------------------"
echo "Done!"
echo "------------------------------------------------------------------"
echo ""
echo ""
echo "------------------------------------------------------------------"
echo "Installing dependencies: Openbox"
echo "------------------------------------------------------------------"
sleep 0.5
apt-get install -y openbox > /dev/null
echo "------------------------------------------------------------------"
echo "Done!"
echo "------------------------------------------------------------------"
echo ""
## Workaround for now to ensure that the .mozilla folder is present before continuing
## Had an issue that would literally brick the system and not allow login, fixing with this and the sleep after no .mozilla in auto run below
echo ""
echo "------------------------------------------------------------------"
echo "Initializing Firefox-ESR"
echo "------------------------------------------------------------------"
sleep 0.5
firefox-esr --headless > /dev/null 2>&1 &
sleep 5
killall firefox-esr > /dev/null
echo "------------------------------------------------------------------"
echo "Done!"
echo "------------------------------------------------------------------"
echo ""
if [[ $? -ne 0 ]]; then
echo ""
echo "------------------------------------------------------------------"
echo "Failed to install dependencies. Purging the rest..."
echo "------------------------------------------------------------------"
sleep 0.5
apt-get purge -y firefox-esr xinit x11-utils > /dev/null
echo "------------------------------------------------------------------"
echo "Installation Failed!"
echo "------------------------------------------------------------------"
exit 1
fi
echo ""
echo "------------------------------------------------------------------"
echo "Installing bash command script"
echo "------------------------------------------------------------------"
# Install the bash command script
if ! echo '#!/bin/bash
if pgrep -x "firefox-esr" >/dev/null; then
clear
echo "Priox-Kiox already running"
return 0
fi
profile_dir=$(find "$HOME/.mozilla/firefox/" -name "*.default-esr" -type d)
if [ -z "$profile_dir" ]; then
echo ""
echo "Firefox profile directory not found."
return 1
fi
prefsfile="$profile_dir/sessionstore-backups"
rm -rf "$prefsfile"/*
mode=""
while [[ $# -gt 0 ]]; do
case $1 in
--kiosk)
mode="kiosk"
shift
;;
*)
echo "Invalid option: $1" >&2
exit 1
;;
esac
shift
done
nohup startx &
sleep 1
export DISPLAY=:0
sleep 1
nohup openbox &
while true; do
result=$(xdpyinfo 2>&1)
if [[ $result == *"unable to open display"* ]]; then
echo "Display not available yet"
sleep 0.25
else
echo "X server is running and display is available."
sleep 0.25
break
fi
done
sleep 1
if [[ $mode = kiosk ]]; then
nohup firefox-esr --kiosk https://127.0.0.1:8006 &
else
nohup firefox-esr https://127.0.0.1:8006 &
fi
wait $!
if pgrep -x "xinit" >/dev/null; then
echo "Killing xinit process"
killall xinit
fi
if pgrep -x "firefox-esr" >/dev/null; then
echo "Killing firefox-esr process"
killall firefox-esr
fi
clear
echo "-----------------"
echo "Exiting Prox-Kiox"
echo "-----------------"' | tee /usr/bin/prox-kiox > /dev/null; then
echo ""
echo "------------------------------------------------------------------"
echo "Failed to install! Removing dependencies...."
echo "------------------------------------------------------------------"
sleep 0.5
apt-get remove -y firefox-esr xinit x11-utils > /dev/null
apt-get purge -y firefox-esr xinit x11-utils > /dev/null
apt-get autoremove -y
echo "------------------------------------------------------------------"
echo "Installation Failed!"
echo "------------------------------------------------------------------"
echo ""
exit 1
else
chmod +x /usr/bin/prox-kiox
fi
echo "------------------------------------------------------------------"
echo "Done!"
echo "------------------------------------------------------------------"
echo ""
echo ""
echo "------------------------------------------------------------------"
echo "Installed!"
echo "------------------------------------------------------------------"
echo ""
rm -f /root/install.sh
echo "You can run Prox-Kiox at any time by running the command 'prox-kiox'"
echo ""