This commit is contained in:
kyodev 2017-07-24 11:29:16 +02:00
parent 9e8fabb7db
commit 2b00f87c22
4 changed files with 218 additions and 207 deletions

View File

@ -26,7 +26,7 @@ chmod +x getFirefox && ./getFirefox
\__, |\___|\__|_| |_|_| \___|_| \___/_/\_\
|___/
pour Debian, version 0.7.1 - 21/07/2017
pour Debian, version 1.0.0 - 24/07/2017
getFirefox installé dans le système.
maintenant, appel du script par: getFirefox (sans ./)
@ -88,7 +88,7 @@ lancer le script sans arguments: `getFirefox` ou avec l'option help `getFirefox
\__, |\___|\__|_| |_|_| \___|_| \___/_/\_\
|___/
pour Debian, version 0.7.1 - 21/07/2017
pour Debian, version 1.0.0 - 24/07/2017
----------------------------------------------------------------------
./getFirefox : installation du script dans le système
@ -114,6 +114,7 @@ lancer le script sans arguments: `getFirefox` ou avec l'option help `getFirefox
Il désinstallera le *paquet Debian* firefox-esr si présent.
----------------------------------------------------------------------
plus d'infos: https://framagit.org/kyodev/kyopages/raw/master/scripts/getFirefox
```
@ -132,7 +133,7 @@ getFirefox i-latest
\__, |\___|\__|_| |_|_| \___|_| \___/_/\_\
|___/
pour Debian, version 0.7.1 - 21/07/2017
pour Debian, version 1.0.0 - 24/07/2017
_.-~-.
7'' Q..\
@ -148,30 +149,37 @@ getFirefox i-latest
/..\ /..\__/ ' '::: | | | | | | (_) / /| | | | (_| | ::'
vVVv vVVv ': |_| |_| |_|\___/___|_|_|_|\__,_| ''
installation Firefox-latest
- installation Firefox-latest
téléchargement...
- téléchargement...
/tmp/getFirefox-21745/firefox-late 100%[======================================>] 58,95M 8,12MB/s in 11s
/tmp/getFirefox-9736/firefox-late 100%[======================================>] 58,95M 8,12MB/s in 11s
décompression...
- décompression...
- installation...
- récupération du profil default existant <moq4laqz.default>
- alternatives installées pour <latest>
installation...
Firefox-latest installé.
```
* la dernière officielle Firefox est installée, en étant directement chargée du site Mozilla.
* un lanceur par canal Firefox doit se trouver dans les menus (comme Applications/Internet)
* l'installation sur un canal existant est refaite en totalité, mais le profil n'est pas modifié
* l'installation sur un canal existant est refaite en **totalité**, mais le profil n'est pas modifié
* si un profil _xyz.default_ (d'un paquet _firefox-esr_ par exemple) existe, il sera laissé en place, mais
une **copie** sera utilisée pour le profil latest (ou ESR). le passage d'une version paquet Debian à une
version Mozilla Release (ou ESR) utilisera donc une copie du profil en cours.
version Mozilla Release (ou ESR) utilisera donc une copie du profil en cours. l'éventuel profil default sera
utilisé pour la première installation d'un canal latest ou esr. les réinstallations ultérieures, si les profils
ne sont pas supprimés, n'utiliseront pas de profil défault détecté
* les canaux peuvent coexister
* chaque canal peut être lancé en console: `firefox-latest` `firefox-beta` `firefox-dev` `firefox-nightly`
`firefox-esr`
* le plus bas canal installé peut lui être lancé avec: `firefox`
* le plus bas canal installé peut lui être lancé avec: `firefox` (_/usr/bin/firefox_)
* si supporté, update-alternatives est configuré pour le plus bas canal installé
4 autres canaux sont possibles:
@ -219,20 +227,20 @@ getFirefox u-latest
\__, |\___|\__|_| |_|_| \___|_| \___/_/\_\
|___/
pour Debian, version 0.7.3 - 22/07/2017
pour Debian, version 1.0.0 - 24/07/2017
récupération du profil default existant <moq4laqz.default>
- alternatives installées pour <latest>
profil <latest> configuré pour kyodev
- profil <latest> configuré pour kyodev
```
* il faut que canal Firefox soit déjà installé
* pour éviter de télécharger inutilement une nouvelle fois pour un nouvel utilisateur:
* changer de session en se connectant sous un nouvel utilisateur
* utiliser l'option `u-latest` `u-beta` `u-nightly` `u-esr` `u-dev` selon ce qui est installé
* utile pour modifier les **alternatives**, pour configurer en alternatives nightly par exemple: u-nightly
* le navigateur Firefox sera disponible dans les menus avec un nouveau profil firefox
* le navigateur Firefox sera disponible dans les menus
* un nouveau profil firefox adéquat sera crée si besoin
* update-alternatives restera sur le plus bas canal firefox
sans changer de session, on devrait pouvoir utiliser, pour un utilisateur titi et un canal beta, par exemple:
```shell
@ -252,22 +260,21 @@ USER_INSTALL=titi getFirefox u-beta
\__, |\___|\__|_| |_|_| \___|_| \___/_/\_\
|___/
pour Debian, version 0.7.0 - 21/07/2017
pour Debian, version 1.0.0b1 - 24/07/2017
Firefox installé(s):
latest: 54.0.1
beta: 55.0
dev: 55.0
nightly: 56.0a1
Version Firefox en ligne:
version Firefox en ligne:
Release : 54.0.1
Beta/dev: 55.0b10
Beta/dev: 55.0b11
Nightly : 56.0a1
ESR : 52.2.1
version script en ligne: 0.7.1, mise à jour possible
version script en ligne: 1.0.0, mise à jour possible
_.-~-.
7'' Q..\
_7 (_
@ -290,10 +297,10 @@ vVVv vVVv ': |_| |_| |_|\___/___|_|_|_|\__,_| ''
## désinstallation d'un canal Firefox
`getFirefox r-canal` par exemple, pour la version nightly, en **root**:
`getFirefox r-canal` par exemple, pour la version beta, en **root**:
```shell
getFirefox r-nightly
getFirefox r-beta
```
```text
_ _____ _ __
@ -303,7 +310,7 @@ getFirefox r-nightly
\__, |\___|\__|_| |_|_| \___|_| \___/_/\_\
|___/
pour Debian, version 0.7.1 - 21/07/2017
pour Debian, version 1.0.0 - 24/07/2017
_.-~-.
7'' Q..\
@ -319,20 +326,19 @@ getFirefox r-nightly
/..\ /..\__/ ' '::: | | | | | | (_) / /| | | | (_| | ::'
vVVv vVVv ': |_| |_| |_|\___/___|_|_|_|\__,_| ''
alternatives installées pour <latest>
- alternatives installées pour <latest>
Firefox-nightly désinstallé.
Firefox-beta désinstallé.
```
* le profil **n'est pas supprimé**, il sera donc utilisable en cas de réinstallation
* si firefox est ouvert il sera fermé
* update-alternatives est configuré sur le plus bas canal installé .
pour reconfigurer alternatives sur un autre canal, utiliser `getFirefox u-beta` par exemple
* update-alternatives reste configuré sur le plus bas canal installé
* `firefox` est lui aussi configuré pour le plus bas canal installé
## suppression d'un profil firefox
## suppression d'un profil Firefox
en user, lancer en terminal, le profile manager de Firefox: `firefox -P` :
@ -354,14 +360,13 @@ en user, lancer en terminal, le profile manager de Firefox: `firefox -P` :
\__, |\___|\__|_| |_|_| \___|_| \___/_/\_\
|___/
pour Debian, version 0.7.0 - 21/07/2017
pour Debian, version 1.0.0b1 - 24/07/2017
version script en ligne: 0.7.1, mise à jour possible
version script en ligne: 1.0.0, mise à jour possible
/tmp/getFirefox-15112/getFirefox 100%[======================================>] 21,06K --.-KB/s in 0,05s
getFirefox mis à jour en version 0.7.1
getFirefox mis à jour en version 1.0.0
```
@ -398,7 +403,7 @@ en **root**:
\__, |\___|\__|_| |_|_| \___|_| \___/_/\_\
|___/
pour Debian, version 0.7.1 - 21/07/2017
pour Debian, version 1.0.0 - 24/07/2017
getFirefox supprimé du système.

View File

@ -1,52 +1,54 @@
#!/bin/bash
user_agent="Mozilla/5.0 (X11; Linux $(uname -m); rv:54.0) Gecko/20100101 Firefox/54.0"
# test wget, $1 url à tester, retourne url testée & entêtes
f__testWget(){
echo "$1: $2"
wget -Sq --tries=1 --timeout=10 --user-agent="$user_agent" --spider --save-headers "$2" &>tempoTest
http="$(cat tempoTest | grep -i 'HTTP/')"
http="$(echo $http | tr '\n' ' - ')"
location="$(cat tempoTest | grep -i 'location')"
echo " $http"
echo " $location"
file_tempo_test="tempoTest-$RANDOM"
# test wget, $1 url à tester, $2 objet, affiche url testée & entêtes http & location
f__wget_entete(){
wget -Sq --tries=1 --timeout=10 --user-agent="$user_agent" --spider --save-headers "$1" &>$file_tempo_test
http="$(grep -i 'HTTP/' $file_tempo_test)"
http=" $(echo $http | tr -d '\n')"
location="$(grep -i 'location' $file_tempo_test)"
echo "$2: $1"
echo "$http"
echo "$http" | grep '40' &>/dev/null && echo " ERREUR 404" || echo "$location"
}
for architecture in linux linux64; do
echo ""
echo "Architecture: $architecture"
echo "====================="
for product in latest esr beta dev nightly; do
if [ "$product" == "latest" ]; then
recup_url="https://download.mozilla.org/?product=firefox-$product&os=$architecture&lang=fr"
elif [ "$product" == "esr" ]; then
recup_url="https://download.mozilla.org/?product=firefox-$product-latest&os=$architecture&lang=fr"
elif [ "$product" == "beta" ]; then
recup_url="https://download.mozilla.org/?product=firefox-beta-latest&os=$architecture&lang=fr"
elif [ "$product" == "dev" ]; then
recup_url="https://download.mozilla.org/?product=firefox-devedition-latest-ssl&os=$architecture&lang=fr"
elif [ "$product" == "nightly" ]; then
recup_url="https://download.mozilla.org/?product=firefox-$product-latest-l10n-ssl&os=$architecture&lang=fr" ;fi
f__testWget "$product" "$recup_url"
echo ""
echo "Architecture: $architecture"
echo "====================="
for product in latest esr beta dev nightly; do
if [ "$product" == "latest" ]; then
recup_url="https://download.mozilla.org/?product=firefox-$product&os=$architecture&lang=fr"
elif [ "$product" == "esr" ]; then
recup_url="https://download.mozilla.org/?product=firefox-$product-latest&os=$architecture&lang=fr"
elif [ "$product" == "beta" ]; then
recup_url="https://download.mozilla.org/?product=firefox-beta-latest&os=$architecture&lang=fr"
elif [ "$product" == "dev" ]; then
recup_url="https://download.mozilla.org/?product=firefox-devedition-latest-ssl&os=$architecture&lang=fr"
elif [ "$product" == "nightly" ]; then
recup_url="https://download.mozilla.org/?product=firefox-$product-latest-l10n-ssl&os=$architecture&lang=fr" ;fi
f__wget_entete "$recup_url" "$product"
done
done
done
rm tempoTest
fileTmp=sdxfcggbjkl-$RANDOM
echo -e "\n===== versions ======"
recup_url="https://download.mozilla.org/?product=firefox-beta-latest&os=linux64&lang=fr"
wget -Sq --tries=1 --timeout=10 --user-agent="$user_agent" --spider --save-headers "$recup_url" &>"$fileTmp"
verBeta="$(cat $fileTmp | grep -i 'location' | sed -E 's/.*firefox-(.*)\.tar.bz2/\1/')"
wget -Sq --tries=1 --timeout=10 --user-agent="$user_agent" --spider --save-headers "$recup_url" &>"$file_tempo_test"
verBeta="$(grep -i 'location' $file_tempo_test | sed -E 's/.*firefox-(.*)\.tar.bz2/\1/')"
recup_url="https://download.mozilla.org/?product=firefox-nightly-latest-l10n-ssl&os=linux64&lang=fr"
wget -Sq --tries=1 --timeout=10 --user-agent="$user_agent" --spider --save-headers "$recup_url" &>"$fileTmp"
verNightly="$(cat $fileTmp | grep -i 'location' | sed -E 's/.*firefox-(.*)\.fr.linux.*/\1/')"
rm "$fileTmp"
wget -Sq --tries=1 --timeout=10 --user-agent="$user_agent" --spider --save-headers "$recup_url" &>"$file_tempo_test"
verNightly="$(grep -i 'location' $file_tempo_test | sed -E 's/.*firefox-(.*)\.fr.linux.*/\1/')"
echo "Beta/Dev: $verBeta"
echo "Nightly : $verNightly"
echo ""
rm $file_tempo_test
exit
### liens

View File

@ -1,7 +1,7 @@
#!/bin/bash
version=0.7.6
date="22/07/2017"
version=1.0.0
date="24/07/2017"
projet="Kyodev"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues"
script="getFirefox"
@ -36,7 +36,7 @@ cat << 'EOF'
EOF
echo -e "$YELLOW pour Debian, version $version - $date$COLOR\n"
# detect system architecture, assign $architecture : linux | linux64, return 1 on unknown architecture
# détection architecture, assign $architecture : linux|linux64, return 1 si architecture inconnue
f__architecture(){
case "$(uname -m)" in
amd64 | x86_64 )
@ -75,9 +75,9 @@ f__user(){
fi
}
#test dépendances (commandes disponibles), $1 liste commandes
# test dépendances (commandes disponibles), $1 liste commandes ou $1...$x, si manquant, sortie avec erreur
f__requis(){
for i in "$@"; do
for i in $@; do
if [ ! "$(which $i)" ]; then
testDepends="ko"
f__info "$RED vous devez avoir la commande $i pour exploiter ce script"
@ -86,20 +86,20 @@ f__requis(){
[ -z "$testDepends" ] || f__error "Paquets manquants" " Contacter administrateur pour disposer de ces commandes"
}
# test wget, $1 url à tester, retourne url testée & entêtes
f__testWget(){
# test wget, $1 url à tester, sortie sur erreur
f__wget_test(){
echo " $1"
wget -Sq --tries=1 --timeout=15 --user-agent="$user_agent" -O /dev/null "$1"
f__error "Erreur wget" " réessayer et si persistance, contacter $projet $contact" " en indiquant les messages précédents."
}
# test validité archive, $1 fichier (bzip2), assigne $archive_detect, return 1 si invalide
f__testArchive(){
file -b "$1" | grep 'bzip2 compressed data' &>/dev/null && archive_detect="bzip2" || return 1
# test validité archive, $1 fichier (bzip2), return 1 si invalide
f__archive_test(){
file -b "$1" | grep 'bzip2 compressed data' &>/dev/null || return 1
}
# sortie sur erreur, log $1 si upgrade
f__error() { #affichage $1 en rouge, $1++ optionnels en bleu, sortie du script, log $1 si upgrade
# affichage $1 en rouge, $1++ optionnels en bleu, sortie script sur erreur, log $1 si upgrade($opType)
f__error() {
echo -e "\n$RED Erreur critique: $1 $COLOR"
for (( i=2 ; i<=$# ; i++ )); do echo -e " $BLUE${!i}"; done
echo "$COLOR"
@ -107,16 +107,16 @@ f__error() { #affichage $1 en rouge, $1++ optionnels en bleu, sortie du script,
exit 1
}
# affichage information, log $1 si upgrade
f__info() { # tous les paramètres en ligne en couleur bleue, accepte \n, ligne vide à la fin
# affichage des paramètres en bleu, ligne vide à la fin, syslog $1 si upgrade
f__info() {
for (( i=1 ; i<=$# ; i++ )); do echo -e " $BLUE${!i}"; done
echo "$COLOR"
if [ "$opType" == "upgrade" ]; then logger --id -p user.info "$1"; fi
}
# root? return 0 else 1
f__root(){
if [ $EUID -eq 0 ]; then return 0; else return 1; fi
f__root(){
[ $EUID -eq "0" ] && return 0 || return 1
}
# install du script dans le système
@ -157,22 +157,22 @@ fscript_remove(){
f__info "$GREEN$script supprimé du système."
}
# version script en ligne, assigne $versionScript, $uptd_script=""|ko,
# version script en ligne, assigne $script_aJour=ok|ko,
fscript_version(){
versionScript="$(wget -q --tries=2 --timeout=15 --user-agent="$user_agent" -O - "$urlScript" | grep '^version=' | cut -d '=' -f 2)"
if [ "$version" != "$versionScript" ]; then
f__info "version script en ligne: $versionScript, mise à jour possible"
uptd_script="ko"
else uptd_script=""; fi
script_aJour="ko"
else script_aJour="ok"; fi
}
# mise à jour script si dispo
fscript_dl(){
if [ "$uptd_script" != "ko" ]; then return 0; fi
if [ "$script_aJour" == "ok" ]; then return 0; fi
dirTemp="/tmp/$script-$RANDOM/"
mkdir -p "$dirTemp"
wget -q --show-progress --tries=2 --timeout=15 --user-agent="$user_agent" -O "$dirTemp$script" "$urlScript"
if [ "$?" != "0" ]; then f__testWget "$urlScript"; fi
if [ "$?" != "0" ]; then f__wget_test "$urlScript"; fi
chmod a+rwx "$dirTemp$script"
chown "$user_": "$dirTemp$script"
cp -d "$dirTemp$script" /opt/bin/"$script"
@ -181,10 +181,10 @@ fscript_dl(){
exit 0
}
#inscription dans tache upgrade en cron hebdomadaire, une partie requiert root
# inscription dans tache upgrade en anacron hebdomadaire, via cron horaire
fscript_cronAnacron(){
case "$1" in
"install" )
install )
# table anacron
echo "7 05 getFF nice /opt/bin/$script upgrade &>/dev/null" > "/home/$user_/.mozilla/$script.anacrontab"
## test: anacron journalier:
@ -196,7 +196,7 @@ chown "$user_": "/home/$user_/.config/anacron/spool"
# cron tab pour activation horaire anacron
echo "@hourly $user_ /usr/sbin/anacron -t /home/$user_/.mozilla/$script.anacrontab -S /home/$user_/.config/anacron/spool" >> /etc/crontab
;;
"remove" )
remove )
[ -e "/home/$user_/.config/anacron/spool/getFF" ] && rm "/home/$user_/.config/anacron/spool/getFF"
sed -i "/^\@hourly.*$script.anacrontab.*$/d" /etc/crontab
rm "/home/$user_/.mozilla/$script.anacrontab"
@ -204,7 +204,7 @@ rm "/home/$user_/.mozilla/$script.anacrontab"
esac
}
# ascii art godzilla
# ascii art godzilla; ligne vide finale
ffx_godzilla(){
printf "$RED"
cat << 'EOF'
@ -259,19 +259,18 @@ EOF
echo -e "plus d'infos:$GREEN https://framagit.org/kyodev/kyopages/raw/master/scripts/getFirefox$COLOR\n"
}
# version Firefox en ligne, $verLatest, $verEsr, $versionInstall, $urlOnline, si $1="quiet", pas d'affichage version en ligne
ffx_versionFF(){
urlOnline="https://www.mozilla.org/en-US/firefox/notes/"
stockUrlOnline="$(wget -q --tries=2 --timeout=15 --user-agent=$user_agent -O - $urlOnline)"
verLatest="$(echo $stockUrlOnline | grep -Eo 'data-latest-firefox="[0-9\.]+"' | grep -Eo '[0-9\.]+')"
verEsr="$(echo $stockUrlOnline | grep -Eo 'data-esr-versions="[0-9\.]+"' | grep -Eo '[0-9\.]+')"
fileTmp=sdxfcggbjkl-$RANDOM
# version Firefox en ligne
ffx_versionsFF(){
stockageUrlOnline="$(wget -q --tries=2 --timeout=15 --user-agent=$user_agent -O - https://www.mozilla.org/en-US/firefox/notes/)"
verLatest="$(echo $stockageUrlOnline | grep -Eo 'data-latest-firefox="[0-9\.]+"' | grep -Eo '[0-9\.]+')"
verEsr="$(echo $stockageUrlOnline | grep -Eo 'data-esr-versions="[0-9\.]+"' | grep -Eo '[0-9\.]+')"
fileTmp="sdxfcggbjkl-$RANDOM"
recup_url="https://download.mozilla.org/?product=firefox-beta-latest&os=linux64&lang=fr"
wget -Sq --tries=1 --timeout=10 --user-agent="$user_agent" --spider --save-headers "$recup_url" &>"$fileTmp"
verBeta="$(cat $fileTmp | grep -i 'location' | sed -E 's/.*firefox-(.*)\.tar.bz2/\1/')"
verBeta="$(grep -i 'location' $fileTmp | sed -E 's/.*firefox-(.*)\.tar.bz2/\1/')"
recup_url="https://download.mozilla.org/?product=firefox-nightly-latest-l10n-ssl&os=linux64&lang=fr"
wget -Sq --tries=1 --timeout=10 --user-agent="$user_agent" --spider --save-headers "$recup_url" &>"$fileTmp"
verNightly="$(cat $fileTmp | grep -i 'location' | sed -E 's/.*firefox-(.*)\.fr.linux.*/\1/')"
verNightly="$(grep -i 'location' $fileTmp | sed -E 's/.*firefox-(.*)\.fr.linux.*/\1/')"
rm "$fileTmp"
for product in latest esr beta dev nightly; do
if [ -x "$dirInstall$product/firefox" ]; then
@ -279,118 +278,111 @@ ffx_versionFF(){
fi
done
f__info "Firefox installé(s): $versionInstall"
f__info "Version Firefox en ligne:\n Release : $verLatest\n Beta/dev: $verBeta\n Nightly : $verNightly\n ESR : $verEsr"
f__info "version Firefox en ligne:\n Release : $verLatest\n Beta/dev: $verBeta\n Nightly : $verNightly\n ESR : $verEsr"
}
# création lanceur.desktop
ffx_lanceur_desktop(){
fileDesktopEnCeation="/usr/share/applications/firefox-$product.desktop"
echo "#!/usr/bin/env xdg-open" > "$fileDesktopEnCeation"
echo "[Desktop Entry]" >> "$fileDesktopEnCeation"
echo "Name=Firefox $product" >> "$fileDesktopEnCeation"
echo "Name[fr]=Firefox $product" >> "$fileDesktopEnCeation"
echo "X-GNOME-FullName=Firefox-$product Web Browser" >> "$fileDesktopEnCeation"
echo "X-GNOME-FullName[fr]=Firefox-$product Navigateur Web" >> "$fileDesktopEnCeation"
echo "StartupWMClass=Firefox-$product" >> "$fileDesktopEnCeation"
echo "Exec=/usr/bin/firefox-$product %u" >> "$fileDesktopEnCeation"
echo "Icon=$dirInstall$product/browser/icons/mozicon128.png" >> "$fileDesktopEnCeation"
echo "Comment=Browse the World Wide Web" >> "$fileDesktopEnCeation"
echo "Comment[fr]=Naviguer sur Internet" >> "$fileDesktopEnCeation"
echo "GenericName=Web Browser" >> "$fileDesktopEnCeation"
echo "GenericName[fr]=Navigateur Web" >> "$fileDesktopEnCeation"
echo "Terminal=false" >> "$fileDesktopEnCeation"
echo "X-MultipleArgs=false" >> "$fileDesktopEnCeation"
echo "Type=Application" >> "$fileDesktopEnCeation"
echo "Categories=Network;WebBrowser;" >> "$fileDesktopEnCeation"
echo "MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/vnd.mozilla.xul+xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;" >> "$fileDesktopEnCeation"
echo "StartupNotify=true" >> "$fileDesktopEnCeation"
fileDesktop="/usr/share/applications/firefox-$product.desktop"
echo "#!/usr/bin/env xdg-open" > "$fileDesktop"
echo "[Desktop Entry]" >> "$fileDesktop"
echo "Name=Firefox $product" >> "$fileDesktop"
echo "Name[fr]=Firefox $product" >> "$fileDesktop"
echo "X-GNOME-FullName=Firefox-$product Web Browser" >> "$fileDesktop"
echo "X-GNOME-FullName[fr]=Firefox-$product Navigateur Web" >> "$fileDesktop"
echo "StartupWMClass=Firefox-$product" >> "$fileDesktop"
echo "Exec=/usr/bin/firefox-$product %u" >> "$fileDesktop"
echo "Icon=$dirInstall$product/browser/icons/mozicon128.png" >> "$fileDesktop"
echo "Comment=Browse the World Wide Web" >> "$fileDesktop"
echo "Comment[fr]=Naviguer sur Internet" >> "$fileDesktop"
echo "GenericName=Web Browser" >> "$fileDesktop"
echo "GenericName[fr]=Navigateur Web" >> "$fileDesktop"
echo "Terminal=false" >> "$fileDesktop"
echo "X-MultipleArgs=false" >> "$fileDesktop"
echo "Type=Application" >> "$fileDesktop"
echo "Categories=Network;WebBrowser;" >> "$fileDesktop"
echo "MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/vnd.mozilla.xul+xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;" >> "$fileDesktop"
echo "StartupNotify=true" >> "$fileDesktop"
}
# traitement de profile.ini, inscription si utile (pas déjà existante)
ffx_profilIni(){
#si déjà profil existant dans profil.ini, sortir
if [ "$(grep -rc Name=$product $fileProfileIni)" != 0 ]; then return; fi
#comptage profils existants
nbProfiles="$(grep -rEc '\[Profile[0-9]+\]' $fileProfileIni)"
#création profil dans profile.ini
# traitement de profile.ini, inscription si pas déjà existante
ffx_profilIni_inscription(){
# si déjà profil existant dans profil.ini, sortir
if [ "$(grep -c Name=$product $fileProfileIni)" != 0 ]; then return; fi
# comptage profils existants
nbProfiles="$(grep -Ec '\[Profile[0-9]+\]' $fileProfileIni)"
# création profil dans profile.ini
echo "" >> "$fileProfileIni"
echo "[Profile$nbProfiles]" >> "$fileProfileIni"
echo "Name=$product" >> "$fileProfileIni"
echo "IsRelative=1" >> "$fileProfileIni"
echo "Path=$product" >> "$fileProfileIni"
#si existant et latest, supprimer Default=1 et attribuer à latest, dans profile.ini
# si existant et latest (ou esr), supprimer Default=1 et attribuer à latest, dans profile.ini
if [ "$product" == "latest" ] || [ "$product" == "esr" ]; then
sed -i 's/Default=1//' "$fileProfileIni"
echo "Default=1" >> "$fileProfileIni"
else echo "" >> "$fileProfileIni"; fi
else echo "" >> "$fileProfileIni"; fi
}
# traitement update-alternatives, $1 install|remove,
ffx_upt_altern(){
which update-alternatives &>/dev/null || return 0
# suppression alternatives x-www-browser si existantes
if update-alternatives --get-selections | grep firefox | grep x-www-browser &>/dev/null; then
update-alternatives --quiet --remove-all x-www-browser
fi
if [ "$1" == "install" ]; then
update-alternatives --quiet --install /usr/bin/firefox x-www-browser "/usr/bin/firefox-$product" 100
elif [ "$1" == "remove" ]; then
for i in nightly dev beta esr latest; do
if [ -d "$dirInstall$i/" ]; then firefoxBas="$i"; fi
done
update-alternatives --quiet --install /usr/bin/firefox x-www-browser "/usr/bin/firefox-$firefoxBas" 100
f__info "alternatives installées pour <$firefoxBas>"
fi
}
# lien /usr/bin/firefox pour la plus basse version firefox installée
ffx_usr_bin(){
# détermination canal bas Firefox installé, assigne $firefoxCanalBas
ffx_canal_bas(){
for i in nightly dev beta esr latest; do
if [ -d "$dirInstall$i/" ]; then firefoxBas="$i"; fi
if [ -d "$dirInstall$i/" ]; then firefoxCanalBas="$i"; fi
done
ln -sf "/usr/bin/firefox-$firefoxBas" "/usr/bin/firefox"
}
# traitement update-alternatives
ffx_update_alternatives(){
which update-alternatives &>/dev/null || return 0 # update-laternatives n'est pas sur cette distrib
ffx_canal_bas
update-alternatives --quiet --install /usr/bin/firefox x-www-browser "/usr/bin/firefox-$firefoxCanalBas" 100
f__info " - alternatives installées pour <$firefoxCanalBas>"
}
# lien /usr/bin/firefox pour le plus bas canal Firefox installé, utile si update-alternatives pas fonctionnel
ffx_usr_bin(){
ffx_canal_bas
ln -sf "/usr/bin/firefox-$firefoxCanalBas" "/usr/bin/firefox"
}
# traitement utilisateur, $1 user, si appel indépendant pour reconfiguration
ffx_profilUser(){
ffx_profil_User(){
if [ "$1" == "user" ] && [ ! -x "/usr/bin/firefox-$product" ]; then
f__error "firefox <$product> n'est pas installé" " il faut donc utiliser l'installation et pas l'ajout d'un nouveau profil"
fi
dirProfil="/home/$user_/.mozilla/firefox"
fileProfileIni="$dirProfil/profiles.ini"
# si profile.ini existe on traite default sinon on le crée avec minimum d'entête
# si profile.ini existe on traite default sinon on le crée avec minimum d'entête (première installation Firefox)
if [ -w "$fileProfileIni" ]; then
# recherche éventuel profil tuvwxyz.default dans profile.ini
profileDefault="$(grep -r '\.default' $fileProfileIni | sed 's/Path=//')"
profileDefault="$(grep '\.default' $fileProfileIni | sed 's/Path=//')"
# si profileDefault existant, on l'utilise pour latest (ou esr) si pas déjà présent
if [ "$profileDefault" ] && [ -d "$dirProfil/$profileDefault" ] && [ "$product" == "latest" ] || [ "$product" == "esr" ]; then
if [ ! -d "$dirProfil/$product" ]; then
if [ ! -d "$dirProfil/$product" ]; then # le profil cible n'existe pas
f__info " - récupération du profil default existant <$profileDefault>"
mkdir -p "$dirProfil/$product"
f__info "récupération du profil default existant <$profileDefault>"
cp -R "$dirProfil/$profileDefault"/* "$dirProfil/$product/"
fi
fi
else
echo -e "[General]\nStartWithLastProfile=1\n\n" >> "$fileProfileIni"
chown "$user_": "$fileProfileIni"
chmod u+rw,go+r "$fileProfileIni"
chown "$user_": "$fileProfileIni" # propriété du fichier profile.ini à l'user
chmod u+rw,go+r "$fileProfileIni" # permissions du fichier profile.ini à l'user
fi
mkdir -p "$dirProfil/$product"
chown -R "$user_": "$dirProfil/$product/" # propriété du répertoire profile à l'user
chmod g-rx,o-rx "$dirProfil/$product/" # droits répertoire comme firefox officiel
ffx_profilIni
chmod g-rx,o-rx "$dirProfil/$product/" # droits répertoire comme Firefox officiel
ffx_profilIni_inscription
ffx_lanceur_desktop
ffx_upt_altern "install"
if [ "$1" == "user" ]; then f__info "profil <$product> configuré pour $user_"; fi
ffx_update_alternatives
if [ "$1" == "user" ]; then f__info " - profil <$product> configuré pour $user_"; fi
}
# calcul url téléchargement, assigne $recup_url
# calcul url téléchargement, assigne $recup_url. fixer url pour beta et nightly dans ffx_versionsFF
ffx_recup_url(){
if [ "$product" == "latest" ]; then
if [ "$product" == "latest" ]; then
recup_url="https://download.mozilla.org/?product=firefox-$product&os=$architecture&lang=fr"
elif [ "$product" == "esr" ]; then
elif [ "$product" == "esr" ]; then
recup_url="https://download.mozilla.org/?product=firefox-$product-latest&os=$architecture&lang=fr"
elif [ "$product" == "beta" ]; then
elif [ "$product" == "beta" ]; then
recup_url="https://download.mozilla.org/?product=firefox-beta-latest&os=$architecture&lang=fr"
elif [ "$product" == "dev" ]; then
recup_url="https://download.mozilla.org/?product=firefox-devedition-latest-ssl&os=$architecture&lang=fr"
@ -398,27 +390,26 @@ ffx_recup_url(){
recup_url="https://download.mozilla.org/?product=firefox-$product-latest-l10n-ssl&os=$architecture&lang=fr" ;fi
}
# install firefox
# installation Firefox
ffx_install(){
f__root || f__error "vous devez être ROOT pour installer Firefox"
ffx_godzilla
f__info "installation Firefox-$product"
# dossier temporaire de travail, création $dirTemp
f__info " - installation Firefox-$product"
# dossier temporaire de travail
dirTemp="/tmp/$script-$RANDOM/"
mkdir -p "$dirTemp"
# téléchargement, test archive
f__info "téléchargement..."
# téléchargement & test archive
f__info " - téléchargement..."
file="firefox-$product.$architecture.tar.bz2"
ffx_recup_url
wget -q -c --show-progress --tries=2 --timeout=15 --user-agent="$user_agent" -O "$dirTemp$file" "$recup_url"
if [ "$?" != "0" ]; then f__testWget "$recup_url"; fi
f__testArchive "$dirTemp$file" || f__error "Le fichier $dirTemp$file n'est pas une archive tar.gz valide"
if [ "$?" != "0" ]; then f__wget_test "$recup_url"; fi
f__archive_test "$dirTemp$file" || f__error "Le fichier $dirTemp$file n'est pas une archive tar.gz valide"
# décompression
f__info "\n décompression..."
f__info "\n - décompression..."
tar -xaf "$dirTemp$file" -C "$dirTemp"
f__info "installation..."
# on déplace le répertoire firefox dans le répertoire installation
# mise en place finale
f__info " - installation..."
rm -rf "$dirInstall$product"/ # effacement éventuel répertoire existant: "vraie" install
mkdir -p "$dirInstall$product"/
mv -f "$dirTemp"firefox/* "$dirInstall$product"/
@ -426,53 +417,56 @@ ffx_install(){
chmod -R g+wrs,a+r "$dirInstall$product"/
rm -rf "$dirTemp"
# lien icône Firefox
ln -sf "$dirInstall$product"/browser/chrome/icons/default/default48.png /usr/share/pixmaps/firefox-"$product".png
ln -sf "$dirInstall$product/browser/chrome/icons/default/default48.png" "/usr/share/pixmaps/firefox-$product.png"
# lanceur dans /usr/bin
echo "#!/bin/sh" > /usr/bin/firefox-"$product"
echo "exec $dirInstall$product/firefox -P $product" "\$@" >> /usr/bin/firefox-"$product"
chmod a+x /usr/bin/firefox-"$product"
echo "#!/bin/sh" > "/usr/bin/firefox-$product"
echo "exec $dirInstall$product/firefox -P $product" "\$@" >> "/usr/bin/firefox-$product"
chmod a+x "/usr/bin/firefox-$product"
ffx_usr_bin
# traitement user
ffx_profilUser
ffx_profil_User
f__info "$GREEN""Firefox-$product installé."
}
# désinstallation de firefox
# désinstallation de Firefox
ffx_remove(){
f__root || f__error "vous devez être ROOT pour désinstaller"
ffx_godzilla
killall "/opt/usr/share/firefox-$product/firefox" &>/dev/null
# si pas de lanceur desktop, on considère que ce canal firefox n'est pas installé, retour
if [ ! -e "/usr/share/applications/firefox-$product.desktop" ]; then
f__info "$GREEN" "Firefox-$product n'est pas installé."
return 1
# si pas de lanceur desktop, on considère que ce canal Firefox n'est pas installé, retour
if [ ! -e "/usr/share/applications/firefox-$product.desktop" ]; then # si test répertoire, on détecterait pas l'ancien répertoire éventuel
f__info "$GREEN""Firefox-$product n'est pas installé."
return 0
fi
# suppression du répertoire firefox
# suppression du répertoire Firefox
if [ -d "/opt/firefox-$product/" ]; then rm -rf "/opt/firefox-$product/"; fi # ancien répertoire éventuel
if [ -d "$dirInstall$product/" ]; then rm -rf "$dirInstall$product/"; fi
# suppression lanceurs
rm -f /usr/share/applications/firefox-"$product".desktop
rm -f /usr/bin/firefox-"$product"
rm -f "/usr/share/applications/firefox-$product.desktop"
rm -f "/usr/bin/firefox-$product"
# suppression des liens
unlink "/usr/share/pixmaps/firefox-$product.png" &>/dev/null
unlink "/usr/bin/firefox-$product" &>/dev/null
# recréation lanceur Firefox & update-alternatives
ffx_usr_bin
ffx_upt_altern "remove"
ffx_update_alternatives
f__info "$GREEN""Firefox-$product désinstallé."
}
#initialisation
# initialisation
f__architecture || f__error "Architecture non supportée"
f__user
f__requis "wget" "logger" "file" "tar"
f__requis "wget logger file tar logger"
dirInstall="/opt/usr/share/firefox-"
dirProfil="/home/$user_/.mozilla/firefox"
fileProfileIni="$dirProfil/profiles.ini"
# installation du script si pas dans le système
# installation du script si appel pas fait depuis le système
dirname "$0" | grep 'bin' &>/dev/null || fscript_install
# détection droits inappropriés sur le script
[ "$1" != "sysremove" ] && [ -e "/opt/bin/$script" ] && ls -l "/opt/bin/$script" | grep 'root' &>/dev/null && f__error "bug sécu 01" \
"veuillez désinstaller le script et le réinstaller" "voir: $urlNotice#messages-avertissement"
#détection ancien repertoire install
# détection ancien répertoire installation
ls -ld /opt/firefox-* &>/dev/null && f__info "$RED""Ancien répertoire d'installation détecté" \
"Il faudrait désinstaller et réinstaller pour être à jour" "version(s) détectée(s):" \
"$(ls -ld /opt/firefox-* | sed -E 's/.*firefox-(.*)/ \1/')"
@ -481,9 +475,9 @@ case "$1" in
sysremove )
fscript_remove ;; # désinstallation du script
version | -v | --version | -version )
ffx_versionFF
ffx_versionsFF
fscript_version
ffx_godzilla ;; # affiche versions FF en ligne & installée & version script
ffx_godzilla ;; # affiche versions Firefox en ligne & installées & version script
upgrade )
opType="upgrade"
fscript_version
@ -491,14 +485,14 @@ case "$1" in
i-latest | i-esr | i-dev | i-beta | i-nightly | \
+latest | +esr | +dev | +beta | +nightly )
product="$(echo $1 | sed 's/i-//' | sed 's/+//')"
ffx_install ;; # installation plugin
ffx_install ;; # install: installation canal Firefox
r-latest | r-esr | r-dev | r-beta | r-nightly | \
-latest | -esr | -dev | -beta | -nightly )
product="$(echo $1 | sed 's/r-//' | sed 's/-//' )"
ffx_remove ;; # désinstallation plugin
ffx_remove ;; # remove: désinstallation Firefox
u-latest | u-esr | u-dev | u-beta | u-nightly )
product="$(echo $1 | sed 's/u-//')"
ffx_profilUser "user" ;; # installation profil pour utilisateur en cours
ffx_profil_User "user" ;; # user: profil pour utilisateur en cours ou reconfiguration
* )
ffx_help ;; # affichage help par défaut
esac

View File

@ -1,5 +1,15 @@
# changelog getFirefox
## todo
* install: utilisation copie du plus bas profil existant?
## 1.0.0 24/07/2017
* relecture
* update-alternatives: firefoxCanalBas pour install/remove
## 0.7.6 22/07/2017
* pas d'update-alternatives si hors debian