-
Notifications
You must be signed in to change notification settings - Fork 6
/
install.sh
executable file
·171 lines (151 loc) · 8.35 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
#! /usr/bin/env bash
#### ####
# #
# This installer will set up a Firefox profile, desktop launcher, and an #
# optional bash_alias for launching from the terminal, configured to browse #
# i2p. It does this in the user's home directory, and does not require root. #
# #
#### ####
if [ "$DIR" = "" ]; then
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
fi
TITLE="i2p Browser Profile Set-Up"
if [ "$USER" = "root" ]; then
exit "BROWSERS SHOULD NOT BE RUN AS ROOT!"
fi
TOR=$(which torsocks)
EEP=$(which eepget)
if [ "x$EEP" = "x" ]; then
UPDATE_URL=https://github.com/eyedeekay/firefox.profile.i2p/releases/download/current/i2pbrowser-profile-update.zip
DL_COMMAND="$TOR curl -L $UPDATE_URL --output i2pbrowser-profile-update.zip"
DL_COMMAND_SUM="$TOR curl -L $UPDATE_URL.sha256sum --output i2pbrowser-profile-update.zip.sha256sum"
DL_COMMAND_SIG="$TOR curl -L $UPDATE_URL.sha256sum.asc --output i2pbrowser-profile-update.zip.sha256sum.asc"
else
if [ "x$EEP_UPDATE_PATH" = "x" ]; then
EEP_UPDATE_PATH="ihcrgsnj2vh5zb7lvatwko3nwm3kiltcy7n3yu7zitgijrbl6rhq.b32.i2p"
fi
UPDATE_URL="http://$EEP_UPDATE_PATH/i2pbrowser-profile-update.zip"
DL_COMMAND="$EEP -o i2pbrowser-profile-update.zip $UPDATE_URL"
DL_COMMAND_SUM="$EEP -o i2pbrowser-profile-update.zip.sha256sum $UPDATE_URL.sha256sum"
DL_COMMAND_SIG="$EEP -o i2pbrowser-profile-update.zip.sha256sum.asc $UPDATE_URL.sha256sum.asc"
fi
USAGE="
#### ####
# #
# This installer will set up a Firefox profile, desktop launcher, and an #
# optional bash_alias for launching from the terminal, configured to browse #
# i2p. It does this in the user's home directory, and does not require root. #
# #
#### ####
The installation will take place in $HOME
usage:
./install.sh install # install the profile and browser launcher
./install.sh uninstall # remove the profile and browser launcher
./install.sh alias # configure a .bash_alias to launch the browser
./install.sh usage # show this usage message
./install.sh update # update the profile from $UPDATE_URL
./install.sh run # run from this directory without installing
firefox --no-remote --profile \"\$DIR/../.firefox.profile.i2p.default\" about:blank \$1
./install.sh private # run in private mode from this directory without installing
firefox --no-remote --profile \"\$DIR/../.firefox.profile.i2p.private\" --private about:blank \$1
./install.sh debug # run with debugger from this directory without installing
firefox --jsconsole --devtools --no-remote --profile \"\$DIR/../.firefox.profile.i2p.debug\" --private about:blank \$1
"
usage(){
echo "$USAGE"
}
update(){
echo "$DIR" | grep -v '/usr/lib/firefox.profile.i2p' && \
INSTALL_DIR="$DIR"
echo "$DIR" | grep '/usr/lib/firefox.profile.i2p' && \
DIR="$HOME"
mv "$DIR/firefox.profile.i2p/" "$DIR/../.firefox.profile.i2p.bak/"
if [ "x$EEP" != "x" ]; then
echo "$EEP detected, updates will be retrieved over i2p"
elif [ "x$TOR" != "x" ]; then
echo "$TOR detected, updates will be retrieved over Tor"
fi
$DL_COMMAND
$DL_COMMAND_SUM
$DL_COMMAND_SIG
sleep 1
sha256sum -c i2pbrowser-profile-update.zip.sha256sum
gpg --keyid-format long --verify i2pbrowser-profile-update.zip.sha256sum.asc i2pbrowser-profile-update.zip.sha256sum
unzip i2pbrowser-profile-update.zip
rm -rf "$DIR/../.firefox.profile.i2p.bak/" i2pbrowser-profile-update.zip
}
install(){
if [ ! -d "$HOME/.mozilla/firefox/firefox.profile.i2p" ]; then
echo "Installing to $HOME"
if [ -d $SNAP/usr/lib/firefox.profile.i2p/ ]; then
rm -rfv "$HOME/.mozilla/firefox/firefox.profile.i2p"
cp -rv "$SNAP/usr/lib/firefox.profile.i2p" "$HOME/.mozilla/firefox/firefox.profile.i2p"
else
rm -rfv "$HOME/.mozilla/firefox/firefox.profile.i2p"
cp -rv "$DIR/" "$HOME/.mozilla/firefox/firefox.profile.i2p"
cp -v "$DIR/i2pbrowser-firefox.desktop" \
"$HOME/.local/share/applications/i2pbrowser-firefox.desktop"
cp -v "$DIR/i2pbrowser-firefox-private.desktop" \
"$HOME/.local/share/applications/i2pbrowser-firefox-private.desktop"
fi
fi
}
uninstall(){
echo "$DIR" | grep -v '/usr/lib/firefox.profile.i2p' && \
INSTALL_DIR="$DIR"
echo "$DIR" | grep '/usr/lib/firefox.profile.i2p' && \
DIR="$HOME"
rm -rfv "$INSTALL_DIR" "$DIR/../.firefox.profile.i2p.default"
rm -fv "$HOME/.local/share/applications/i2pbrowser-firefox.desktop" \
"$HOME/.local/share/applications/i2pbrowser-firefox-private.desktop"
}
debug(){
echo "$DIR" | grep -v '/usr/lib/firefox.profile.i2p' && \
INSTALL_DIR="$DIR"
echo "$DIR" | grep '/usr/lib/firefox.profile.i2p' && \
DIR="$HOME"
mkdir -pv "$DIR/../.firefox.profile.i2p.debug/extensions"
cp -v "$INSTALL_DIR/firefox.profile.i2p/extensions/"*.xpi "$DIR/../.firefox.profile.i2p.debug/extensions"
cp -v "$INSTALL_DIR/firefox.profile.i2p/bookmarks.html" "$DIR/../.firefox.profile.i2p.debug/bookmarks.html"
cp -v "$INSTALL_DIR/firefox.profile.i2p/user.js" "$DIR/../.firefox.profile.i2p.debug/user.js"
cp -v "$INSTALL_DIR/firefox.profile.i2p/storage-sync.sqlite" "$DIR/../.firefox.profile.i2p.debug/storage-sync.sqlite"
cp -v "$INSTALL_DIR/firefox.profile.i2p/search.json.mozlz4" "$DIR/../.firefox.profile.i2p.debug/search.json.mozlz4"
echo "firefox --jsconsole --devtools --no-remote --profile \"$DIR/../.firefox.profile.i2p.debug\" --private about:blank $1"
ls "$DIR/../.firefox.profile.i2p.debug"
firefox --jsconsole --devtools --no-remote --profile "$DIR/../.firefox.profile.i2p.debug" --private about:blank $1
rm -rfv "$DIR/../.firefox.profile.i2p.debug"
}
private(){
echo "$DIR" | grep -v '/usr/lib/firefox.profile.i2p' && \
INSTALL_DIR="$DIR"
echo "$DIR" | grep '/usr/lib/firefox.profile.i2p' && \
DIR="$HOME"
rm -rfv "$DIR/../.firefox.profile.i2p.private"
mkdir -pv "$DIR/../.firefox.profile.i2p.private/extensions"
cp -v "$INSTALL_DIR/firefox.profile.i2p/extensions/"*.xpi "$DIR/../.firefox.profile.i2p.private/extensions"
cp -v "$INSTALL_DIR/firefox.profile.i2p/bookmarks.html" "$DIR/../.firefox.profile.i2p.private/bookmarks.html"
cp -v "$INSTALL_DIR/firefox.profile.i2p/user.js" "$DIR/../.firefox.profile.i2p.private/user.js"
cp -v "$INSTALL_DIR/firefox.profile.i2p/storage-sync.sqlite" "$DIR/../.firefox.profile.i2p.private/storage-sync.sqlite"
cp -v "$INSTALL_DIR/firefox.profile.i2p/search.json.mozlz4" "$DIR/../.firefox.profile.i2p.private/search.json.mozlz4"
firefox --no-remote --profile "$DIR/../.firefox.profile.i2p.private" --private about:blank $1
rm -rfv "$DIR/../.firefox.profile.i2p.private"
}
run(){
echo "$DIR" | grep -v '/usr/lib/firefox.profile.i2p' && \
INSTALL_DIR="$DIR"
echo "$DIR" | grep '/usr/lib/firefox.profile.i2p' && \
DIR="$HOME"
mkdir -pv "$DIR/../.firefox.profile.i2p.default/extensions"
cp -v "$INSTALL_DIR/firefox.profile.i2p/extensions/"*.xpi "$DIR/../.firefox.profile.i2p.default/extensions"
cp -v "$INSTALL_DIR/firefox.profile.i2p/bookmarks.html" "$DIR/../.firefox.profile.i2p.default/bookmarks.html"
cp -v "$INSTALL_DIR/firefox.profile.i2p/user.js" "$DIR/../.firefox.profile.i2p.default/user.js"
cp -v "$INSTALL_DIR/firefox.profile.i2p/storage-sync.sqlite" "$DIR/../.firefox.profile.i2p.default/storage-sync.sqlite"
cp -v "$INSTALL_DIR/firefox.profile.i2p/search.json.mozlz4" "$DIR/../.firefox.profile.i2p.default/search.json.mozlz4"
echo "installed $INSTALL_DIR to $DIR/../.firefox.profile.i2p.default"
firefox --no-remote --profile "$DIR/../.firefox.profile.i2p.default" about:blank $1
}
if [ "x$1" = "x" ]; then
usage
else
"$1" $2
fi