-
Notifications
You must be signed in to change notification settings - Fork 1
/
Firefox-DeSnap.sh
194 lines (174 loc) · 5.34 KB
/
Firefox-DeSnap.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
#!/usr/bin/env bash
## AUTHOR:
### Ciro Mota <[email protected]>
## NAME:
### Firefox-DeSnap.sh.
## DESCRIPTION:
### Install Firefox Latest on Ubuntu after 22.04 and your flavours and Debian Stable, Oldstable or Testing.
## LICENSE:
### GPLv3. <https://github.com/ciro-mota/firefox-desnap/blob/main/LICENSE>
## CHANGELOG:
### Last Update: 13/05/2024. <https://github.com/ciro-mota/firefox-desnap/commits/main>
your_lang="$(locale | head -1 | sed -e 's/LANG=//' -e 's/.UTF-8$//' -e 's/_/-/' | awk '{print tolower($0)}')"
your_lang_deb="$(locale -a | tail -1 | sed -e 's/.utf8$//' -e 's/_/-/' | awk '{print tolower($0)}')"
snap_exist="$(snap list 2>/dev/null | grep firefox | awk '{print $1}')"
esr_exist="$(dpkg -l | grep firefox-esr | awk '{print $2}')"
version_check="$(lsb_release -cs)"
func_snap() {
echo ""
echo -e "\e[32;1mUninstalling Firefox Snap...\e[m\n"
sudo snap remove firefox >/dev/null
sudo tee -a /etc/apt/preferences.d/firefox-no-snap &>/dev/null <<'EOF'
Package: firefox*
Pin: release o=Ubuntu*
Pin-Priority: -1
EOF
sudo tee -a /etc/apt/preferences.d/mozilla &>/dev/null <<'EOF'
Package: *
Pin: origin packages.mozilla.org
Pin-Priority: 1000
EOF
}
func_select_snap() {
echo -e "Firefox Snap detected. Would you like do uninstall?"
echo -e "Type \e[33;1mY\e[m to continue or \e[33;1mN\e[m to not uninstall and exit:\n"
read -r unin_snap
case $unin_snap in
y | Y)
func_snap
func_install_ubuntu
;;
n | N)
exit 1
;;
*)
echo -e "\e[31;1mIncorrect option. Please try again.\e[m\n"
func_select_snap
;;
esac
}
func_install_ubuntu() {
echo -e "Would you like to continue anyway to download and install Firefox not Snap?"
echo -e "Type \e[33;1mY\e[m to continue or \e[33;1mN\e[m to exit the script:\n"
read -r download
case $download in
y | Y)
### Adding PPA.
echo ""
echo -e "\e[32;1mAdding Firefox Oficial PPA...\e[m"
wget -q https://packages.mozilla.org/apt/repo-signing-key.gpg -O- |
sudo tee /etc/apt/keyrings/packages.mozilla.org.asc >/dev/null
echo "deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main" |
sudo tee -a /etc/apt/sources.list.d/mozilla.list >/dev/null
sudo apt-get -qq update >/dev/null
### Install Firefox and lang-pack
sudo apt install -y --allow-downgrades firefox firefox-l10n-"$your_lang"
;;
n | N)
echo -e "\e[32;1mTerminating script...\e[m"
exit 0
;;
*)
echo -e "\e[31;1mIncorrect option. Please try again.\e[m"
func_install_ubuntu
;;
esac
}
func_esr() {
echo -e "\e[32;1mUninstalling Firefox ESR...\e[m\n"
sudo apt-get purge firefox-esr -y >/dev/null
}
func_select_esr() {
echo -e "Firefox ESR detected. Would you like do unistall?"
echo -e "Type \e[33;1mY\e[m to continue or \e[33;1mN\e[m to not uninstall and exit:\n"
read -r unin_esr
case $unin_esr in
y | Y)
func_esr
func_install_debian
;;
n | N)
exit 1
;;
*)
echo -e "\e[31;1mIncorrect option. Please try again.\e[m\n"
func_select_esr
;;
esac
}
func_install_debian() {
echo -e "\e[32;1mAdding Firefox Debian Unstable source...\e[m"
sudo tee -a /etc/apt/sources.list &>/dev/null <<'EOF'
deb http://deb.debian.org/debian/ unstable main
EOF
sudo tee -a /etc/apt/preferences.d/99firefox-unstable &>/dev/null <<'EOF'
Package: *
Pin: release a=stable
Pin-Priority: 900
Package: *
Pin: release a=unstable
Pin-Priority: 10
EOF
sudo apt -qq update && sudo apt install -y -t unstable firefox firefox-l10n-"$your_lang_deb"
}
exec_script() {
echo -e "Script will check if you have Firefox Snap or ESR installed and remove it."
echo -e "Would you like to continue the script? Type \e[33;1mY\e[m to continue or \e[33;1mN\e[m to exit\n"
read -r exists
case $exists in
y | Y)
if [[ $snap_exist = "firefox" ]]; then
func_select_snap
elif [[ $esr_exist = "firefox-esr" ]]; then
func_select_esr
else
echo -e "No Firefox was detected.\n"
exit 0
fi
;;
n | N)
echo -e "\e[32;1mTerminating script...\e[m\n"
exit 0
;;
*)
echo -e "\e[31;1mIncorrect option. Please try again.\e[m\n"
exec_script
;;
esac
}
### Execution in automatic mode.
func_auto() {
echo -e "Would you like to run this script automatically? See the documentation to see what it will do."
echo -e "Type \e[33;1mY\e[m to continue or \e[33;1mN\e[m to interactive mode or \e[33;1mX\e[m to exit.\n"
read -r choose
case $choose in
y | Y)
if [[ $snap_exist = "firefox" ]]; then
func_snap
func_install_ubuntu
elif [[ $esr_exist = "firefox-esr" ]]; then
func_esr
func_install_debian
else
echo -e "No Firefox was detected.\n"
exit 0
fi
;;
n | N)
exec_script
;;
x | X)
exit 1
;;
*)
echo -e "\e[31;1mIncorrect option.\e[m"
func_auto
;;
esac
}
if [[ $version_check =~ ^(noble|mantic|jammy|trixie|bookworm)$ ]]; then
func_auto
else
echo -e "\e[31;1mDistro not supported by this script.\e[m"
exit 1
fi