This commit is contained in:
kyodev 2017-07-20 20:32:31 +02:00
parent 2e929a0585
commit c87cec4e11
3 changed files with 138 additions and 86 deletions

View File

@ -62,7 +62,7 @@ chmod +x getFirefox && ./getFirefox
\__, |\___|\__|_| |_|_| \___|_| \___/_/\_\
|___/
pour Debian, version 0.5.0 - 19/07/2017
pour Debian, version 0.5.0 - 19/07/2017
getFirefox installé dans le système.
maintenant, appel du script par: getFirefox (sans ./)
@ -86,7 +86,7 @@ lancer le script sans arguments: `getFirefox`ou avec l'option help `getFirefox h
\__, |\___|\__|_| |_|_| \___|_| \___/_/\_\
|___/
pour Debian, version 0.5.0 - 19/07/2017
pour Debian, version 0.6.0 - 20/07/2017
----------------------------------------------------------------------
./getFirefox : installation du script dans le système
@ -103,6 +103,8 @@ lancer le script sans arguments: `getFirefox`ou avec l'option help `getFirefox h
getFirefox -nightly : désinstallation Firefox Nightly
getFirefox -esr : désinstallation Firefox ESR
----
getFirefox u-canal : profil pour un nouvel utilisateur (u-latest, u-beta...)
----
getFirefox version : version en ligne Firefox Release & ESR
getFirefox upgrade : mise à jour forcée du script
----
@ -112,6 +114,7 @@ lancer le script sans arguments: `getFirefox`ou avec l'option help `getFirefox h
les installations et les désinstallations.
Il désinstallera le *paquet Debian* firefox-esr si présent.
----------------------------------------------------------------------
```
@ -130,7 +133,7 @@ getFirefox +latest
\__, |\___|\__|_| |_|_| \___|_| \___/_/\_\
|___/
pour Debian, version 0.5.0 - 19/07/2017
pour Debian, version 0.5.0 - 19/07/2017
_.-~-.
7'' Q..\
@ -196,6 +199,43 @@ la version **aurora** est abandonnée et la **developer edition** est basée sur
* la nightly est mise à jour quotidiennement
## nouvel utilisateur
ajouter un profil d'un canal Firefox installé pour un nouvel utilisateur en cours.
**en root**:
```shell
getFirefox u-nightly
```
```text
_ _____ _ __
__ _ ___| |_| ___(_)_ __ ___ / _| _____ __
/ _' |/ _ \ __| |_ | | '__/ _ \ |_ / _ \ \/ /
| (_| | __/ |_| _| | | | | __/ _| (_) > <
\__, |\___|\__|_| |_|_| \___|_| \___/_/\_\
|___/
pour Debian, version 0.6.0 - 20/07/2017
récupération du profil default existant moq4laqz.default
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é
* le navigateur Firefox sera disponible dans les menus avec un nouveau profil firefox
sans changer de session, on devrait pouvoir utiliser, pour un utilisateur titi et un canal beta, par exemple:
```shell
USER_INSTALL=titi getFirefox u-latest
```
**attention**: il faut que l'utilisateur souhaité ait déjà un home
## version
`getFirefox version`: affiche la version en ligne de Firefox _Release_ et _ESR_, ainsi que
@ -209,7 +249,7 @@ les versions installées par ce script.
\__, |\___|\__|_| |_|_| \___|_| \___/_/\_\
|___/
pour Debian, version 0.5.2 - 20/07/2017
pour Debian, version 0.5.2 - 20/07/2017
Firefox installé(s):
latest: 54.0.1
@ -255,7 +295,7 @@ getFirefox +latest
\__, |\___|\__|_| |_|_| \___|_| \___/_/\_\
|___/
pour Debian, version 0.5.0 - 19/07/2017
pour Debian, version 0.5.0 - 19/07/2017
_.-~-.
7'' Q..\
@ -294,7 +334,7 @@ le profil **n'est pas supprimé**, il sera donc utilisé en cas de réinstallati
\__, |\___|\__|_| |_|_| \___|_| \___/_/\_\
|___/
pour Debian, version 0.5.0b5 - 19/07/2017
pour Debian, version 0.5.0b5 - 19/07/2017
version script en ligne: 0.5.0, mise à jour possible
@ -335,7 +375,7 @@ en **root**:
\__, |\___|\__|_| |_|_| \___|_| \___/_/\_\
|___/
pour Debian, version 0.5.0 - 19/07/2017
pour Debian, version 0.5.0 - 19/07/2017
getFirefox supprimé du système.

View File

@ -1,6 +1,6 @@
#!/bin/bash
version=0.5.5
version=0.6.0
date="20/07/2017"
projet="Kyodev"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues"
@ -24,7 +24,6 @@ YELLOW=`printf "\033[0;33m"` # ?
RED=`printf "\033[0;31m"` # alerte
#### entete ============================================================
clear
printf "$BLUE"
cat << 'EOF'
@ -36,11 +35,9 @@ cat << 'EOF'
|___/
EOF
echo -e "$YELLOW pour Debian, version $version - $date\n$COLOR"
echo -e "$YELLOW pour Debian, version $version - $date\n$COLOR"
#### fonctions diverses ================================================
# detect system architecture, assign $architecture : linux | linux64, return 1 on unknown architecture
f__architecture(){
case "$(uname -m)" in
@ -125,8 +122,6 @@ f__root(){
}
#### fonctions script ==================================================
# install du script dans le système
fscript_install(){
# si script inexistant ou inaccessible en écriture, ou si cronAnacron non installé: root requis
@ -251,6 +246,8 @@ cat << 'EOF'
getFirefox -nightly : désinstallation Firefox Nightly
getFirefox -esr : désinstallation Firefox ESR
----
getFirefox u-canal : profil pour un nouvel utilisateur (u-latest, u-beta...)
----
getFirefox version : version en ligne Firefox Release & ESR
getFirefox upgrade : mise à jour forcée du script
----
@ -292,59 +289,76 @@ ffx_versionFF(){
# création lanceur.desktop
ffx_lanceur_desktop(){
rm -f /usr/share/applications/firefox-"$product".desktop
cat << "EOF" >> /usr/share/applications/firefox-"$product".desktop
#!/usr/bin/env xdg-open
[Desktop Entry]
EOF
echo "Name=Firefox $product" >> /usr/share/applications/firefox-"$product".desktop
echo "Name[fr]=Firefox $product" >> /usr/share/applications/firefox-"$product".desktop
echo "X-GNOME-FullName=Firefox-$product Web Browser" >> /usr/share/applications/firefox-"$product".desktop
echo "X-GNOME-FullName[fr]=Firefox-$product Navigateur Web" >> /usr/share/applications/firefox-"$product".desktop
echo "StartupWMClass=Firefox-$product" >> /usr/share/applications/firefox-"$product".desktop
echo "Exec=/usr/bin/firefox-$product %u" >> /usr/share/applications/firefox-"$product".desktop
echo "Icon=$dirInstall$product/browser/icons/mozicon128.png" >> /usr/share/applications/firefox-"$product".desktop
cat << "EOF" >> /usr/share/applications/firefox-"$product".desktop
Comment=Browse the World Wide Web
Comment[fr]=Naviguer sur Internet
GenericName=Web Browser
GenericName[fr]=Navigateur Web
Terminal=false
X-MultipleArgs=false
Type=Application
Categories=Network;WebBrowser;
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;
StartupNotify=true
EOF
rm -f /usr/share/applications/firefox-"$product".desktop #effacement/création
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"
}
# sauvegarde profil, uniquement si profil default et latest ou esr
ffx_profileCopy(){
if [ "$product" != "latest" ] && [ "$product" != "esr" ]; then return 0; fi
profilDefault="$(grep -r '\.default' /home/$user_/.mozilla/firefox/profiles.ini | sed 's/Path=//')"
if [ $profilDefault ] && [ ! -d "/home/$user_/.mozilla/firefox/latest" ] || [ ! -d "/home/$user_/.mozilla/firefox/esr" ]; then
cp -R "/home/$user_/.mozilla/firefox/$profilDefault"/* "/home/$user_/.mozilla/firefox/$product/"
fi
}
# traitement de profile.ini
ffx_profileIni(){
fileProfil="/home/$user_/.mozilla/firefox/profiles.ini"
#si profil existant, sortir
if [ "$(grep -rc Name=$product $fileProfil)" != 0 ]; then return; fi
# traitement de profile.ini, inscription
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]+\]' $fileProfil)"
#création profil
echo "" >> "$fileProfil"
echo "[Profile$nbProfiles]" >> "$fileProfil"
echo "Name=$product" >> "$fileProfil"
echo "IsRelative=1" >> "$fileProfil"
echo "Path=$product" >> "$fileProfil"
nbProfiles="$(grep -rEc '\[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
if [ "$product" == "latest" ] || [ "$product" == "esr" ]; then
sed -i 's/Default=1//' "$fileProfil"
echo "Default=1" >> "$fileProfil"
else echo "" >> "$fileProfil"; fi
sed -i 's/Default=1//' "$fileProfileIni"
echo "Default=1" >> "$fileProfileIni"
else echo "" >> "$fileProfileIni"; fi
}
# traitement utilisateur
ffx_profilUser(){
[ "$1" == "user" ] && [ -x "/usr/bin/firefox-$product" ] || f__error "firefox $product n'est pas installé" " il faut donc utiliser l'installation et pas l'ajout d'un nouveau profil"
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
if [ -w "$fileProfileIni" ]; then
# recherche éventuel profil tuvwxyz.default dans profile.ini
profileDefault="$(grep -r '\.default' $fileProfileIni | sed 's/Path=//')"
# si profileDefault & répertoire profileDefault & product latest ou esr puis si répertoire latest ou esr non déjà existant
if [ "$profileDefault" ] && [ -d "$dirProfil/$profileDefault" ] && [ "$product" == "latest" ] || [ "$product" == "esr" ]; then
if [ ! -d "$dirProfil/latest" ] || [ ! -d "$dirProfil/esr" ]; then
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"
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
ffx_lanceur_desktop
f__info "profil $product configuré pour $user_"
}
# calcul url téléchargement, assigne $recup_url
@ -366,22 +380,22 @@ 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
dirTemp="/tmp/$script-$RANDOM/"
mkdir -p "$dirTemp"
# 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"
# décompression
f__info "décompression..."
tar -xaf "$dirTemp$file" -C "$dirTemp"
f__info "installation..."
ffx_profilUser # traitement user
# on déplace le répertoire firefox dans le répertoire installation
rm -rf "$dirInstall$product"/ # effacement éventuel répertoire existant: "vraie" install
mkdir -p "$dirInstall$product"/
@ -389,34 +403,27 @@ ffx_install(){
chown -R "$user_": "$dirInstall$product"/
chmod -R g+wrs,a+r "$dirInstall$product"/
rm -rf "$dirTemp"
mkdir -p "/home/$user_/.mozilla/firefox/$product"
ffx_profileCopy
chown -R "$user_": "/home/$user_/.mozilla/firefox/$product/"
chmod g-rx,o-rx "/home/$user_/.mozilla/firefox/$product/"
ffx_profileIni
ffx_lanceur_desktop
# 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"
ln -sf "$dirInstall$product"/browser/chrome/icons/default/default48.png /usr/share/pixmaps/firefox-"$product".png
# lien dans /usr/bin pour latest en tant que firefox
# lien dans /usr/bin pour latest ou esr en tant que firefox
if [ "$product" == "latest" ]; then ln -sf "/usr/bin/firefox-latest" "/usr/bin/firefox"
elif [ "$product" == "esr" ]; then ln -sf "/usr/bin/firefox-esr" "/usr/bin/firefox"; fi
# lien icone Firefox
ln -sf "$dirInstall$product"/browser/chrome/icons/default/default48.png /usr/share/pixmaps/firefox-"$product".png
# # alternatives, trop intrusif pour plusieurs versions simultanées?
# update-alternatives --quiet --install /usr/bin/firefox-"$product" x-www-browser "$dirInstall$product"/firefox 100
f__info "$GREEN""Firefox-$product installé."
# # alternatives, à traiter
# update-alternatives --quiet --install /usr/bin/firefox-"$product" x-www-browser "$dirInstall$product"/firefox 100
}
# désinstallation de firefox
ffx_remove(){
f__root || f__error "vous devez être ROOT pour désinstaller"
ffx_godzilla
if [ ! -e /usr/share/applications/firefox-"$product".desktop ]; then
# 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 0
fi
@ -427,18 +434,17 @@ ffx_remove(){
# suppression lanceurs
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
if [ "$product" == "latest" ]; then unlink "/usr/bin/firefox" &>/dev/null
elif [ "$product" == "esr" ]; then unlink "/usr/bin/firefox" &>/dev/null; fi
unlink "/usr/bin/firefox-$product" &>/dev/null
# suppression alternatives si existantes
if update-alternatives --display x-www-browser &>/dev/null; then
update-alternatives --display x-www-browser | grep firefox-"$product" &>/dev/null && update-alternatives --quiet --remove x-www-browser /opt/firefox/firefox-"$product"
fi
f__info "$GREEN" "Firefox-$product désinstallé."
f__info "$GREEN" "Firefox-$product désinstallé."
}
@ -475,6 +481,9 @@ case "$1" in
-latest | -esr | -dev | -beta | -nightly )
product="$(echo $1 | sed 's/-//')"
ffx_remove ;; # désinstallation plugin
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_help ;; # affichage help par défaut
esac

View File

@ -2,11 +2,14 @@
## todo
* plus d'architecture? (arm)?
* voir alternatives par ordre croissant, latest ou esr sinon beta sinon nightly (dev out)
* améliorer les installations pour autres users
* voir alternatives par ordre croissant, latest ou esr sinon beta sinon nightly (hors dev)
## 0.6.0 20/07/17
* mieux: gestion profile.ini si Firefox jamais installé
* mieux: installation profil autres utilisateurs
## 0.5.5 20/07/17
* fix bug: détection profil existant dans profile.ini
@ -14,7 +17,7 @@
* mieux: developer edition. malgré sa gestion autonome du profil, fonctionnement du script non modifié
si jamais changement futur
* mieux version en ligne beta & nightly
* comestique
* costique
## 0.5.0 19/07/17