getXfox 4.6.0

This commit is contained in:
kyodev 2017-12-26 07:43:52 +01:00
parent 687d1ee614
commit 704579e8f0
2 changed files with 116 additions and 102 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
version=4.5.0
date="25/12/2017"
version=4.6.0b
date="26/12/2017"
projet="simpledeb"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
script="getXfox"
@ -73,16 +73,16 @@ f__error(){ # 18/12/2017
exit 1
}
# affichage des paramètres en bleu, si $1=raw pas de ligne vide à la fin, si $1=log alors uniquement $2 logué
f__info(){ # 18/12/2017
# affichage en bleu, si $1=raw pas de ligne vide à la fin, si $1=log alors uniquement $2 logué, combiné: $1="log:raw"
f__info(){ # 26/12/2017
local depart=1 i
[[ "$1" == "raw" || "$1" == "log" ]] && depart=2
[ "$1" == "log" ] && f__log "$(sed -E 's/\\t//;s/\\n// ' <<< $2 | xargs )"
[[ "$1" =~ "raw" || "$1" =~ "log" ]] && depart=2
[[ "$1" =~ "log" ]] && f__log "$(sed -E 's/\\t//;s/\\n// ' <<< $2 | xargs )"
for (( i=$depart ; i<=$# ; i++ )); do
echo -e " $BLUE${!i}$STD"
done
[ "$1" == raw ] || echo
[[ "$1" =~ raw ]] || echo
}
# log spécifique, fichier log limité à 10000 octets, $1 message à loguer
@ -269,7 +269,7 @@ EOF
}
# affichage help
f_help(){ # 23/12/2017
f_help(){ # 26/12/2017
local ih help=(
" ----------------------------------------------------------------------"
" softs possibles:$GREEN tor, wfx $BLUE(Tor Browser, Waterfox)$STD"
@ -281,8 +281,8 @@ f_help(){ # 23/12/2017
" "
" $BLUE$script m-$STD$GREEN""soft$STD : installation de <soft> à partir d'une archive téléchargée $RED""m$STD""anuellement $RED(root)$STD"
" $BLUE$script r-$STD$GREEN""soft$STD : désinstallation ($RED""r$STD""emove) de <soft> $RED(root)$STD"
" $BLUE$script s-$STD$GREEN""soft$STD : soft comme défaut du $RED""s$STD""ystème (update-alternatives) $RED(root)$STD"
" $BLUE$script u-$STD$GREEN""soft$STD : ajouter un profil pour l'$RED""u$STD""tilisateur en cours"
" $BLUE$script u-$STD$GREEN""soft$STD : profil pour l'$RED""u$STD""tilisateur en cours et comme défaut système $RED(root)$STD"
" (Tor Browser n'est pas cpncerné par le profil)"
" "
" $BLUE$script p-$STD$GREEN""soft$STD : $RED""p$STD""ersonnalisation sur <soft> de user.js & userChrome.css"
" $BLUE$script pr-$STD$GREEN""soft$STD : suppression des $RED""p$STD""ersonnalisations ($RED""r$STD""emove) sur <soft>"
@ -298,7 +298,6 @@ f_help(){ # 23/12/2017
" $BLUE$script -v$STD, --version : versions du script"
)
# echo -n "$BLUE"
IFS=$'\n'
for ih in ${help[@]}; do
echo -e "$ih"
@ -307,37 +306,10 @@ f_help(){ # 23/12/2017
echo -e "\n$STD plus d'infos: $YELLOW$url_notice\n$STD"
}
# alternatives, $1=soft wfx|tor [$2=cible lanceur /usr/bin $3=no_set]
f_update_alternatives(){ # 23/12/2017
local soft="$1" dirSoft
dirSoft="dirInstall${soft^}" # dirInstall + soft avec lettre 1 en majuscule
if [ "$EUID" -ne 0 ]; then
f__info "vous devez être$RED ROOT$BLUE pour configurer $soft comme défaut dans le système"
f__sudo "exec $0 s-$soft"
return $?
fi
if [ ! -d "${!dirSoft}" ]; then # référence à la variable $dirInstallSoft
f__info "$soft n'est pas installé"
return 1
fi
# update-alternatives
if type -p "update-alternatives" &>/dev/null ; then # update-alternatives existe?
update-alternatives --quiet --install $( type -p x-www-browser 2>/dev/null ) 'x-www-browser' "$2" 100 # nouvelle alternative
update-alternatives --quiet --install $( type -p gnome-www-browser 2>/dev/null ) 'gnome-www-browser' "$2" 100 # nouvelle alternative
if [ "$3" != "no_set" ]; then
update-alternatives --quiet --set 'x-www-browser' "$2" # si le priorité n'est pas suffisante
update-alternatives --quiet --set 'gnome-www-browser' "$2" # si le priorité n'est pas suffisante
fi
fi
f__info " - alternatives installées pour $soft"
}
# assigne $ver_tor_online, $ver_tor_install, [$1=quiet]
f_tor_get_version(){ # 25/12/2017
local recup_url="https://www.torproject.org/projects/torbrowser.html.en"
local fileTmp="/tmp/$script-getVersion_tor" appli="Tor browser"
local fileTmp="/tmp/$script-getVersion_tor" appli="Tor Browser"
x_tor_get_version=1
# version online
@ -360,8 +332,8 @@ f_tor_get_version(){ # 25/12/2017
}
# installation, [$1='manuel', $2 archive]
f_tor_install(){ # 25/12/2017
local fileDesktop="/usr/share/applications/tor-browser.desktop" appli="Tor browser"
f_tor_install(){ # 26/12/2017
local fileDesktop="/usr/share/applications/tor-browser.desktop" appli="Tor Browser"
local verArchive fileTemp archi recup_urlTor dirTemp="/tmp/$script-install_tor"
if [ "$EUID" -ne 0 ]; then
@ -414,7 +386,7 @@ f_tor_install(){ # 25/12/2017
echo "exec $dirInstallTor/Browser/start-tor-browser --detach" >> "/usr/bin/tor-browser"
chmod a+x "/usr/bin/tor-browser"
# update-alternatives
f_update_alternatives "tor" "/usr/bin/tor-browser" no_set
f_w_config_system "tor" "/usr/bin/tor-browser" no_set
if [ "$1" == "manuel" ]; then
f__info "log" "archive $appli $verArchive installée"
@ -433,7 +405,7 @@ f_tor_install_manuel(){ # 23/12/2017
# création lanceur desktop
f_tor_lanceur_desktop(){ # 25/12/2017
local appli="Tor browser"
local appli="Tor Browser"
echo "[Desktop Entry]" > "$fileDesktop"
echo "Name=Tor Browser" >> "$fileDesktop"
@ -460,7 +432,7 @@ f_tor_lanceur_desktop(){ # 25/12/2017
# version personnalisation en ligne, [$1=quiet], assigne $perso_tor_afaire
f_tor_pers_get_version(){ # 24/12/2017
local verPersEnPlace verPersOnline personnalisationATraiter appli="Tor browser"
local verPersEnPlace verPersOnline personnalisationATraiter appli="Tor Browser"
x_tor_pers_get_version=1
if [ -e "$profilTor/personnalisation" ]; then
@ -481,7 +453,7 @@ f_tor_pers_get_version(){ # 24/12/2017
# recup userTor.js et chrome/userChrome.css
f_tor_pers_install(){ # 25/12/2017
local verPersTorDL dirTemp="/tmp/$script-persInstall_tor" appli="Tor browser"
local verPersTorDL dirTemp="/tmp/$script-persInstall_tor" appli="Tor Browser"
if [ ! -d "$dirProfilTor/" ]; then #
f__info "profil $appli inexistant"
@ -513,7 +485,7 @@ f_tor_pers_install(){ # 25/12/2017
# supprime personnalisation pour Tor Browser
f_tor_pers_remove(){ # 23/12/2017
local appli="Tor browser"
local appli="Tor Browser"
if [ ! -e "$profilTor/personnalisation" ]; then
f__info "personnalisation inexistante pour $appli"
@ -537,7 +509,7 @@ f_tor_pers_upgrade(){ # 23/12/2017
# désinstallation
f_tor_remove(){ # 23/12/2017
local fileDesktop="/usr/share/applications/tor-browser.desktop" appli="Tor browser"
local fileDesktop="/usr/share/applications/tor-browser.desktop" appli="Tor Browser"
if [ "$EUID" -ne 0 ]; then
f__info "vous devez être$RED ROOT$BLUE pour désinstaller $appli"
@ -565,6 +537,69 @@ f_tor_remove(){ # 23/12/2017
f__info "log" "$appli désinstallé"
}
# alternatives, $1=soft wfx|tor [$2=cible lanceur /usr/bin $3=no_set]
f_w_config_system(){ # 26/12/2017
local soft="$1" dirSoft
dirSoft="dirInstall${soft^}" # dirInstall + soft avec lettre 1 en majuscule (nom d'une variable)
if [ "$EUID" -ne 0 ]; then
f__info "vous devez être$RED ROOT$BLUE pour configurer $soft comme défaut dans le système"
f__sudo "exec $0 s-$soft"
return $?
fi
if [ ! -d "${!dirSoft}" ]; then # référence à la variable $dirInstallSoft
f__info "$soft n'est pas installé"
return 1
fi
# update-alternatives
if type -p "update-alternatives" &>/dev/null ; then # update-alternatives existe?
update-alternatives --quiet --install $( type -p x-www-browser 2>/dev/null ) 'x-www-browser' "$2" 100 # nouvelle alternative
update-alternatives --quiet --install $( type -p gnome-www-browser 2>/dev/null ) 'gnome-www-browser' "$2" 100 # nouvelle alternative
if [ "$3" != "no_set" ]; then # pas de sélection pour tor
update-alternatives --quiet --set 'x-www-browser' "$2" # si le priorité n'est pas suffisante
update-alternatives --quiet --set 'gnome-www-browser' "$2" # si le priorité n'est pas suffisante
fi
fi
[ "$3" != "no_set" ] && f__info "log:raw" "$soft est le défaut système"
}
# traitement utilisateur, [$1='user'] si appel indépendant pour reconfiguration
f_wfx_config_profil(){ # 26/12/2017
local nbProfiles appli="Waterfox"
if [ ! -d "$dirInstallWfx" ] && [ "$1" == "user" ]; then
f__info "$appli n'est pas installé"
return 1
fi
if [ ! -d "$profilWfx" ]; then # pas de répertoire profil
mkdir -p "$profilWfx" # création répertoire
chown -R "$fu_user:" "$profilWfx/" # propriété du répertoire profil à l'user
chmod g-rx,o-rx "$profilWfx/" # droits répertoire
fi
if [ ! -e "$dirProfilWfx/profiles.ini" ]; then # pas de profile.ini
echo -e "[General]\nStartWithLastProfile=1" > "$dirProfilWfx/profiles.ini"
chown "$fu_user:" "$dirProfilWfx/profiles.ini" # propriété du fichier profile.ini à l'user
chmod u+rw,go+r "$dirProfilWfx/profiles.ini" # permissions du fichier profile.ini à l'user
fi
# inscription canal dans profil.ini, à la fin, si inexistant
if ! grep -q "Name=waterfox" "$dirProfilWfx/profiles.ini" ; then
# comptage profils existants
nbProfiles=$( grep -cEs '\[Profile[0-9]+\]' "$dirProfilWfx/profiles.ini" )
# création profil dans profile.ini
echo >> "$dirProfilWfx/profiles.ini"
echo "[Profile$nbProfiles]" >> "$dirProfilWfx/profiles.ini"
echo "Name=waterfox" >> "$dirProfilWfx/profiles.ini"
echo "IsRelative=1" >> "$dirProfilWfx/profiles.ini"
echo "Path=waterfox" >> "$dirProfilWfx/profiles.ini"
echo "Default=1" >> "$dirProfilWfx/profiles.ini"
fi
f__info "log:raw" "profil $appli configuré"
}
# assigne $ver_wfx_online $ver_wfx_install $recup_url_wfx, [$1=quiet]
f_wfx_get_version(){ # 25/12/2017
local fileTmp="/tmp/$script-getVersion_wfx" appli="Waterfox"
@ -592,7 +627,7 @@ f_wfx_get_version(){ # 25/12/2017
}
# installation, [$1='manuel', $2 archive]
f_wfx_install(){ # 25/12/2017
f_wfx_install(){ # 26/12/2017
local fileDesktop="/usr/share/applications/waterfox.desktop" verArchive dirTemp fileTemp
local dirTemp="/tmp/$script-install_wfx" appli="Waterfox"
@ -640,24 +675,30 @@ f_wfx_install(){ # 25/12/2017
chmod -R g+wrs,a+r "$dirInstallWfx/"
rm -rf "$dirTemp/"
# finalisation utilisateur
f_wfx_profil_user
# traitement finaux système
ln -sf "$dirInstallWfx/browser/chrome/icons/default/default48.png" "/usr/share/pixmaps/waterfox.png"
f_wfx_lanceur_desktop
# lanceur dans /usr/bin
echo "#!/bin/sh" > "/usr/bin/waterfox"
echo >> "/usr/bin/waterfox"
echo "exec $dirInstallWfx/waterfox \"\$@\" " >> "/usr/bin/waterfox"
echo "#!/bin/sh" > "/usr/bin/waterfox"
echo >> "/usr/bin/waterfox"
echo "if grep -qE '\-P|\-\-ProfileManager' <<< \"\$@\" ; then " >> "/usr/bin/waterfox"
echo " exec $dirInstallWfx/waterfox -P" >> "/usr/bin/waterfox"
echo " else" >> "/usr/bin/waterfox"
echo " exec $dirInstallWfx/waterfox \"\$@\" " >> "/usr/bin/waterfox"
echo "fi" >> "/usr/bin/waterfox"
chmod a+x "/usr/bin/waterfox"
# update-alternatives
f_update_alternatives "wfx" "/usr/bin/waterfox"
# traitement de profile.ini
f_wfx_config_profil
# alternatives
f_w_config_system "wfx" "/usr/bin/waterfox"
if [ "$1" == "manuel" ]; then
f__info "log" "archive $appli $verArchive installée"
else
f__info "log" "$appli installé $ver_wfx_online"
fi
f__info "raw" "pour récupérer le profil d'un Firefox, lancer la migration avec la commande:"
f__info "raw" "$GREEN waterfox --migration"
f__info "raw" "Récupérer la session firefox:$YELLOW History/Restore Previous Session"
@ -673,7 +714,7 @@ f_wfx_install_manuel(){ # 23/12/2017
}
# création lanceur desktop
f_wfx_lanceur_desktop(){ # 23/12/2017
f_wfx_lanceur_desktop(){ # 26/12/2017
local appli="Waterfox"
echo "[Desktop Entry]" > "$fileDesktop"
@ -683,7 +724,13 @@ f_wfx_lanceur_desktop(){ # 23/12/2017
echo "X-GNOME-FullName[fr]=$appli" >> "$fileDesktop"
echo "StartupWMClass=$appli" >> "$fileDesktop"
echo "Exec=$dirInstallWfx/waterfox" >> "$fileDesktop"
echo "Icon=$dirInstallWfx/browser/chrome/icons/default/default48.png" >> "$fileDesktop"
if [ -e "$dirInstallWfx/browser/icons/mozicon128.png" ]; then
echo "Icon=$dirInstallWfx/browser/icons/mozicon128.png" >> "$fileDesktop"
elif [ -e "$dirInstallWfx/browser/chrome/icons/default/default128.png" ]; then
echo "Icon=$dirInstallWfx/browser/chrome/icons/default/default256.png" >> "$fileDesktop"
else
echo "Icon=$dirInstallWfx/browser/chrome/icons/default/default48.png" >> "$fileDesktop"
fi
echo "Comment=Browse the World Wide Web" >> "$fileDesktop"
echo "Comment[fr]=Naviguer sur Internet" >> "$fileDesktop"
echo "GenericName=Web Browser" >> "$fileDesktop"
@ -773,44 +820,6 @@ f_wfx_pers_upgrade(){ # 23/12/2017
fi
}
# traitement utilisateur, [$1='user'] si appel indépendant pour reconfiguration
f_wfx_profil_user(){ # 25/12/2017
local nbProfiles appli="Waterfox"
if [ ! -d "$dirInstallWfx" ] && [ "$1" == "user" ]; then
f__info "$appli n'est pas installé"
return 1
fi
if [ ! -d "$profilWfx" ]; then # si répertoire profil cible inexistant
mkdir -p "$profilWfx" # création répertoire
chown -R "$fu_user:" "$profilWfx/" # propriété du répertoire profil à l'user
chmod g-rx,o-rx "$profilWfx/" # droits répertoire
fi
if [ ! -e "$dirProfilWfx/profiles.ini" ]; then # si profile.ini inexistant, on crée profile.ini avec entête minimum
echo -e "[General]\nStartWithLastProfile=1" > "$dirProfilWfx/profiles.ini"
chown "$fu_user:" "$dirProfilWfx/profiles.ini" # propriété du fichier profile.ini à l'user
chmod u+rw,go+r "$dirProfilWfx/profiles.ini" # permissions du fichier profile.ini à l'user
fi
# inscription dans profil.ini, si profil pas déjà existant dans profil.ini
if ! grep -q "Name=waterfox" "$dirProfilWfx/profiles.ini" ; then
# comptage profils existants
nbProfiles=$( grep -cEs '\[Profile[0-9]+\]' "$dirProfilWfx/profiles.ini" )
# création profil dans profile.ini
echo >> "$dirProfilWfx/profiles.ini"
echo "[Profile$nbProfiles]" >> "$dirProfilWfx/profiles.ini"
echo "Name=waterfox" >> "$dirProfilWfx/profiles.ini"
echo "IsRelative=1" >> "$dirProfilWfx/profiles.ini"
echo "Path=waterfox" >> "$dirProfilWfx/profiles.ini"
fi
# Default=1 au dernier installé, si besoin autre utiliser u-
sed -i '/Default=1/d' "$dirProfilWfx/profiles.ini" # effacement éventuel Default=existant
echo "Default=1" >> "$dirProfilWfx/profiles.ini" # réinscription
echo "$( uniq $dirProfilWfx/profiles.ini )" > "$dirProfilWfx/profiles.ini" # suppression lignes vides en double
[ "$1" == "user" ] && f__info "log" "profil $appli configuré pour $fu_user"
}
# désinstallation
f_wfx_remove(){ # 23/12/2017
local fileDesktop="/usr/share/applications/waterfox.desktop" appli="Waterfox"
@ -1051,7 +1060,7 @@ script_logs="/var/log/sdeb_$script.log"
url_script="https://framagit.org/kyodev/kyopages/raw/master/scripts/$script/"
url_notice="https://kyodev.frama.io/kyopages/scripts/$script/"
# paramètres tor browser
# paramètres Tor Browser
dirInstallTor="/opt/usr/share/tor-browser"
dirProfilTor="$dirInstallTor/Browser/TorBrowser/Data/Browser" # emplacement profiles.ini
profilTor="$dirProfilTor/profile.default" # profil utilisé
@ -1112,7 +1121,7 @@ for j in $options; do
f_tor_remove
exit ;;
s-tor )
f_update_alternatives "tor" "/usr/bin/tor-browser" # update alternatives
f_w_config_system "tor" "/usr/bin/tor-browser" # update alternatives
exit ;;
u-tor ) # configurer un profil pour un user
f__info "sans objet, Tor Browser est mono utilisateur"
@ -1135,14 +1144,12 @@ for j in $options; do
f_wfx_pers_remove
exit ;;
u-wfx ) # configurer un profil pour un user
f_wfx_profil_user "user"
f_wfx_config_profil "user"
f_w_config_system "wfx" "/usr/bin/waterfox"
exit ;;
r-wfx ) # désinstallation
f_wfx_remove
exit ;;
s-wfx )
f_update_alternatives "wfx" "/usr/bin/waterfox" # update alternatives
exit ;;
v-wfx ) # version
f_wfx_get_version
f_wfx_pers_get_version

View File

@ -2,10 +2,17 @@
todo, réviser
wfx lanceur option u
desktop icon waterfox
## getXfox 4.6.0 - 26/12/2017
révision: f__info, option combinée raw:log
révision: f_help
remodelage: deux fonctions config_profil, config_system (traitement profil et défaut système)
révision: f_wfx_install, lanceur /usr/bin
révision; f_wfx_lanceur_desktop, chemins icone alternatifs
## getXfox 4.5.0 - 25/12/2017
* cosmétique