-
Notifications
You must be signed in to change notification settings - Fork 44
/
install.sh
executable file
·173 lines (150 loc) · 4.47 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
#!/usr/bin/env bash
FF_USER_DIRECTORY=""
CHROME_DIRECTORY=""
RELEASE_NAME=""
message() {
printf "%s\n" "$*" >&2;
}
download_bf() {
message "[>>] Downloading theme..."
curl -LJ0 https://github.com/manilarome/blurredfox/archive/master.tar.gz | tar -xz -C /tmp/
# Download success!
if [[ $? -eq 0 ]];
then
message "[>>] Copying..."
FF_THEME="/tmp/blurredfox-master/"
cp -r "${FF_THEME}"* "${CHROME_DIRECTORY}"
# Backup user.js instead of overwriting it
if [ -e "${CHROME_DIRECTORY}/../user.js" ]
then
message "[>>] Existing user.js detected! Creating backup to user-prefs-backup/..."
user_pref_backup_dir="${CHROME_DIRECTORY}/../user-prefs-backup"
if [[ ! -d "${user_pref_backup_dir}" ]];
then
message "[>>] user-prefs-backup/ folder does not exist! Creating..."
mkdir "${user_pref_backup_dir}"
fi
mv --backup=t "${CHROME_DIRECTORY}/../user.js" "${user_pref_backup_dir}"
fi
# Move user.js to the main profile directory
mv "${CHROME_DIRECTORY}/user.js" "${CHROME_DIRECTORY}/../"
if [[ $? -eq 0 ]];
then
rm -rf "/tmp/blurredfox-master"
else
message " [!!] There was a problem while copying the files. Terminating..."
exit
fi
else
# Download failed
message " [!!] There was a problem while downloading the theme. Terminating..."
exit
fi
echo "░█▀▄░█░░░█░█░█▀▄░█▀▄░█▀▀░█▀▄"
echo "░█▀▄░█░░░█░█░█▀▄░█▀▄░█▀▀░█░█"
echo "░▀▀░░▀▀▀░▀▀▀░▀░▀░▀░▀░▀▀▀░▀▀░"
echo "┏━┛┏━┃┃ ┃"
echo "┏━┛┃ ┃ ┛ "
echo "┛ ━━┛┛ ┛"
message "blurredfox successfully installed! Enjoy!"
}
function check_profile() {
FF_USER_DIRECTORY="$(find "${HOME}/.mozilla/firefox/" -maxdepth 1 -type d -regextype egrep -regex '.*[a-zA-Z0-9]+.'${1})"
}
function print_help() {
echo "Usage:"
echo ""
echo "help - Show this message"
echo "stable - Firefox Stable Build"
echo "dev - Firefox Developer Edition"
echo "beta - Firefox Beta"
echo "nightly - Firefox Nightly"
echo "esr - Firefox Extended Support Release"
echo ""
echo "Example:"
echo "$ ./install stable"
echo "$ ./install dev"
echo "$ curl -fsSL https://raw.githubusercontent.com/manilarome/blurredfox/script/install.sh | bash -s -- stable"
echo ""
echo "Defaults to 'stable' if empty."
}
# Check args
if [[ ! -z "${@}" ]] && [[ ! -z "${1}" ]];
then
if [[ "${1}" == "dev" ]];
then
RELEASE_NAME="Developer Edition"
check_profile "dev-edition-default"
elif [[ "${1}" == "beta" ]];
then
RELEASE_NAME="Beta"
check_profile "default-beta"
elif [[ "${1}" == "nightly" ]];
then
RELEASE_NAME="Nightly"
check_profile "default-nightly"
elif [[ "${1}" == "stable" ]];
then
RELEASE_NAME="Stable"
check_profile "default-release"
elif [[ "${1}" == "esr" ]];
then
RELEASE_NAME="ESR"
check_profile "default-esr"
elif [[ "${1}" == "help" ]];
then
print_help
exit
else
echo -ne "Invalid parameter!\n"
print_help
exit
fi
else
# check_profile "(dev-edition|default)-(release|beta|nightly|default|esr)"
RELEASE_NAME="Stable"
check_profile "default-release"
fi
if [[ -n "$FF_USER_DIRECTORY" ]];
then
message "[>>] Firefox user profile directory located..."
CHROME_DIRECTORY="$(find "$FF_USER_DIRECTORY/" -maxdepth 1 -type d -name 'chrome')"
if [[ -n "$CHROME_DIRECTORY" ]];
then
# Check if the chrome folder is not empty
shopt -s nullglob dotglob
content="${CHROME_DIRECTORY}/"
# If there's a current theme, make a backup
if [ ${#content[@]} -gt 0 ];
then
message "[>>] Existing chrome folder detected! Creating a backup to chrome-backup/..."
backup_dir="${CHROME_DIRECTORY}-backup"
# Create backup folder
if [[ ! -d "${backup_dir}" ]];
then
message "[>>] chrome-backup/ folder does not exist! Creating..."
mkdir "${backup_dir}"
fi
mv --backup=t "${CHROME_DIRECTORY}" "${backup_dir}"
mkdir "${CHROME_DIRECTORY}"
fi
# Download theme
download_bf
else
message "[>>] Chrome folder does not exist! Creating one..."
mkdir "${FF_USER_DIRECTORY}/chrome"
# Check if backup folder exist
if [[ $? -eq 0 ]];
then
CHROME_DIRECTORY="${FF_USER_DIRECTORY}/chrome"
# Download theme
download_bf
else
message "[!!] There was a problem while creating the directory. Terminating..."
exit 1;
fi
fi
else
message "[!!] No Firefox ${RELEASE_NAME} user profile detected! Make sure to run Firefox ${RELEASE_NAME} atleast once! Terminating..."
exit 1;
fi