-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsetup
executable file
·295 lines (236 loc) · 9.71 KB
/
setup
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
#!/bin/bash
set -euo pipefail
# Make sure Firefox is closed, to avoid any issues.
# This uses Kdialog, zenity or notify-send as backup.
# It will need to enforce the closing of Firefox.
SCRIPTPATH="$PWD"
# KDE
kdialog_close() {
result=$(kdialog --title "Arkenfox Setup preparation" --yesno "You need to close Firefox to proceed. Close it now?")
if [[ $result == "yes" ]]; then
pkill -9 firefox
echo "Firefox closed."
notify-send -a "Arkenfox Setup" "Firefox Closed"
elif [[ $result == "no" ]]; then
echo "cancelled"
notify-send -a "Arkenfox-install" -t 5000 "Cancelled" "Setup cancelled, to avoid corruption of data." && exit && exit
fi
}
# zenity (GTK)
zenity_close() {
result=$(zenity --question --title "Arkenfox Setup preparation" --text "You need to close Firefox to proceed. Close it now?")
if [[ $result == "true" ]]; then
pkill -9 firefox &&\
echo "Firefox closed." &&\
notify-send -a "Arkenfox Setup" "Firefox Closed"
elif [[ $result == "false" ]]; then
echo "cancelled" &&\
notify-send -a "Arkenfox-install" -t 5000 "Cancelled" "Setup cancelled, to avoid corruption of data." && exit && exit
fi
}
# notify-send enforced Dialog
# sorry for the inconvenience, this needs to be enforced.
enforce_close(){
notify-send -t 15000 -a "Arkenfox Setup preparation" "Firefox will be closed in 30s..." "Close it manually to skip \n\n This is necessary to avoid data corruption."
if pgrep -x "firefox" > /dev\null; then
echo "Firefox is running. Closing Firefox in 30s..." &&\
sleep 25 &&\
echo "Closing in 5s..." &&\
notify-send -t 5000 -a "Arkenfox Setup preparation" "Firefox will be closed in 5s..." &&\
sleep 5 &&\
pkill -9 firefox &&\
echo "Firefox closed." &&\
notify-send -a "Arkenfox Setup" "Firefox Closed."
else
echo "Firefox already closed. Proceeding..."
fi
}
# Check for available dialog tools and execute the corresponding function
if [[ $(command -v kdialog) ]]; then
GUIMETHOD="kdialog"
kdialog_close
elif [[ $(command -v zenity) ]]; then
GUIMETHID="zenity"
zenity_close
else
GUIMETHOD="notifysend"
enforce_close
fi
# ------------- Firefox Version detection ----------
# Which version of Firefox is installed? This sets the base string in the other script
# Leaving out Torbrowser, Librewolf and Mullvad Browser as these are already hardened.
if command -v firefox &> /dev/null; then
echo "Native Firefox chosen."
BASEDIR=~/.mozilla/firefox
RUNCOMMAND="firefox"
elif flatpak list --app | grep -q org.mozilla.firefox; then
echo "Flatpak Firefox chosen."
BASEDIR=~/.var/app/org.mozilla.firefox/.mozilla/firefox
RUNCOMMAND="flatpak run org.mozilla.firefox"
elif snap list | grep -q firefox; then
echo "Snap Firefox chosen."
BASEDIR=~/snap/firefox/current/.mozilla/firefox
RUNCOMMAND="snap run firefox"
else
echo "Firefox is not installed. Exiting script."
notify-send -t 15000 -a "Arkenfox Setup" "Firefox is not installed?" "If you use Librewolf or MullvadBrowser,\n you dont need this script.\n Otherwise, please file an issue report\! \n Setup cancelled."
exit 1
fi
# ------------ Folder creation --------
cd $BASEDIR
mkdir DO-NOT-REMOVE #the directory to store the vanilla Arkenfox user.js in
mkdir ARKENFOX
cat > DO-NOT-REMOVE/README.txt <<EOF
What is this directory?
It belongs to the "Arkenfox Setup script" and contains the original user.js
To keep things sorted, the Arkenfox repo is cloned here. To restore the original arkenfox, just remove the user-overrides.js
EOF
# ----------- Backup and Copy of Profile folder -------
# Get the name of the default directory (Firefox names these randomly, probably against viruses?)
# Find the file with the name *-default-release
DEFAULTDIR=(*-default-release)
# Copying the currently used profile
notify-send -t 20000 -a "Arkenfox Setup" "Copying your profile folder..." "Your current profile is not changed\!\n You find it in $BASEDIR, named $DEFAULTDIR.\n Run '$RUNCOMMAND -p $DEFAULTDIR' to launch the profile selection."
cp $DEFAULTDIR/* ARKENFOX
# --------- Profiles.ini configuration ---------
arkenfox_ini_append(){
cat >> profiles.ini <<EOF
[Profile$i]
Name=Arkenfox
IsRelative=1
Path=ARKENFOX
EOF
}
# Check if the Arkenfox profile is already registered
# If not, set it as the largest "[ProfileX]" entry using the for-loop
if grep -q "^Name=Arkenfox" "profiles.ini"; then
echo "Profile Arkenfox already exists. Exiting."
else
while true; do
profile_name="Profile$i"
if ! grep -q "$profile_name" "profiles.ini"; then
arkenfox_ini_append
echo "Profile Arkenfox added to profiles.ini, as Profile$i."
break
fi
((i++))
done
fi
NEARLYDONE="The softened Arkenfox profile has been created.\n\nUnder 'about:profiles' you can access the normal Profile for Payment sites or others that may not work.\n\nFirefox will open, choose the profile 'Arkenfox' to continue.\n\nYour profile was copied so you can always use it.\n\nIt is not yet finished, so please close Firefox again."
case "$GUIMETHOD" in
"kdialog")
kdialog --title "Setup nearly done!" --msgbox "$NEARLYDONE"
$RUNCOMMAND -p &
sleep 5
pkill -9 firefox
;;
"zenity")
zenity --info --title "Setup nearly done!!" --text="$NEARLYDONE"
$RUNCOMMAND -p &
sleep 5
pkill -9 firefox
;;
"notifysend")
notify-send -t 20000 -a "Setup nearly done!" "$NEARLYDONE"
$RUNCOMMAND -p &
sleep 5
pkill -9 firefox
;;
esac
# ---------- Install Arkenfox ---------
# set profile folder
ARKDIR="$BASEDIR/ARKENFOX"
cd $ARKDIR
# clone arkenfox
notify-send -a "Arkenfox Setup" "Downloading" "Cloning the Arkenfox repository, downloading the overrides.js,\nand running the updater."
echo "Downloading Arkenfox and the overrides..."
git clone https://github.com/arkenfox/user.js arkenfoxgit || git pull https://github.com/arkenfox/user.js
cd arkenfoxgit/
#rm -f *.bat
#rm -rf wiki
# c
echo "Downloading the overrides.js..."
wget https://raw.githubusercontent.com/boredsquirrel/Arkenfox-softening/main/user-overrides.js
echo "Running Arkenfoxes updater"
notify-send -a "Arkenfox Setup" "Running..." "Running the Arkenfox updater and applying the overrides"
echo "Y" | updater.sh &&\
# copy result to parent folder (firefox main user directory)
cp user.js ../
# ------------ A real autoupdating script -------
cat > autoupdater <<EOF
#!/bin/bash
# This script does not much, but update the user.js using the upstream Arkenfox script, using my overrides,
# and copy that result to the profile folder, override the older user.js
echo "Y" | $ARKDIR/user.js/updater.sh &&\
cp -f user.js ../
EOF
chmod +x autoupdater
# ------------ Setup automatic updates ----------
# Desktop entry creation
wget https://raw.githubusercontent.com/boredsquirrel/Arkenfox-softening/main/arkenfox-icon.png -O ~/.local/share/applications/arkenfox-icon.png
cat > ~/.local/share/applications/Update-Arkenfox.desktop <<EOF
[Desktop Entry]
Exec=$ARKDIR/arkenfoxgit/updater.sh
GenericName=Downloads the latest Arkenfox version, applies softening
Icon=$HOME/.local/share/applications/arkenfox-icon.png
Name=Update Arkenfox
EOF
# Profile chooser Desktop Entry
# Some Firefox versions (RPM, Flatpak, ...) may do this automatically, so its useless
# But I like the icon lol
wget https://raw.githubusercontent.com/boredsquirrel/Arkenfox-softening/main/profilechooser-icon.png ~/.local/share/applications/firefox-profilechooser.png
cat > ~/.local/share/applications/Update-Arkenfox.desktop <<EOF
[Desktop Entry]
Exec=$RUNCOMMAND -p
GenericName=Select a Firefox Profile
Icon=$HOME/.local/share/applications/firefox-profilechooser.png
Name=Firefox Profiles
EOF
# --------------- Create Systemd services -----------
mkdir -p ~/.config/systemd/user
# service
cat > ~/.config/systemd/user/arkenfox-updater.service <<EOF
[Unit]
Description=Runs the Arkenfox updater, applies your set changes
[Service]
Type=simple
ExecStart=/bin/bash -c '$ARKDIR/arkenfoxgit/autoupdater'
Restart=always
RestartSec=60
[Install]
WantedBy=default.target
EOF
# timer
cat > ~/.config/systemd/user/arkenfox-updater.timer <<EOF
[Unit]
Description=Run arkenfox-updater every day
[Timer]
OnCalendar=daily
Persistent=true
Wants=network-online.target
[Install]
WantedBy=default.target
EOF
systemctl --user enable arkenfox-updater.service
# ---------- Finish Messages -------
FINISHTEXT="Arkenfox is now set up with default settings.\n\nIt may not suit your needs though.\n\nChange the 'user-overrides.js' in $BASEDIR, do NOT change the user.js to avoid breakage.\n\nThe override is configured to be user-friendly."
NOSCRIPTTEXT="Please install NoScript and disable WebGL on all levels:\n\n- Default\n- Trusted\n- Untrusted\n\nYou can enable it manually if Webapps, Games or Maps require it, by changing the sites Javascript setting to 'custom' and enabling WebGL manually.\n\nWhy? WebGL uses your Graphics card, which can be used to track you.\n\nAlternatively you can report a fake value of your GPU using the Addon 'WebGL Fingerprint Defender'."
case "$GUIMETHOD" in
"kdialog")
kdialog --title "Setup finished!" --msgbox "$FINISHTEXT"
kdialog --title "WebGL enabled" --warningyesno "$NOSCRIPTTEXT"
$RUNCOMMAND -p
;;
"zenity")
zenity --info --title "Setup finished!" --text="$FINISHTEXT"
zenity --warning --title "WebGL enabled" --text "$NOSCRIPTTEXT"
$RUNCOMMAND -p
;;
"notifysend")
notify-send -t 20000 -a "Setup finished!" "$FINISHTEXT"
sleep 10
notify-send -t 20000 -a "WebGL enabled" "$NOSCRIPTTEXT" --urgency=critical
sleep 20
$RUNCOMMAND -p
;;
esac