gestion du choix "aucun choix"

erreur des tests du profil explicites
déplacement de zenity progress sur borg create (testé)
This commit is contained in:
Djan GICQUEL 2021-03-07 15:42:18 +01:00
parent 5e6ca08966
commit 72a5126345
1 changed files with 46 additions and 40 deletions

View File

@ -1,5 +1,11 @@
#! /bin/bash #! /bin/bash
which zenity
if [ "$?" != "0" ]; then
echo "Zenity n'est pas installé.";exit
exit
fi
# META VARIABLES # META VARIABLES
################################################################################# #################################################################################
export BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=yes export BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=yes
@ -8,54 +14,51 @@ export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
# FONCTIONS # FONCTIONS
################################################################################# #################################################################################
TestBorgRepo () { TestBorgRepo () {
if [ ! -f "config" ]; then if [ ! -f "config" ]; then
TestBorgErr=1 TestBorgErr=1
infoerr=$(echo "Impossible de trouver le fichier de configuration borg.") infoerr=$(echo "Impossible de trouver le fichier de configuration borg.")
zenity --width=500 --error --text="$infoerr" zenity --width=500 --error --text="$infoerr"
exit exit
fi fi
if [ ! -d "data" ]; then if [ ! -d "data" ]; then
TestBorgErr=1 TestBorgErr=1
infoerr=$(echo "Impossible de trouver le fichier de configuration borg.") infoerr=$(echo "Impossible de trouver le fichier de configuration borg.")
zenity --width=500 --error --text="$infoerr" zenity --width=500 --error --text="$infoerr"
exit exit
fi fi
if [ -d "lock.exclusive" ]; then if [ -d "lock.exclusive" ]; then
TestBorgErr=1 TestBorgErr=1
infoerr=$(echo "Le dépôt est bloqué, une opération est peut-être en cours") infoerr=$(echo "Le dépôt est bloqué, une opération est peut-être en cours")
zenity --width=500 --error --text="$infoerr" zenity --width=500 --error --text="$infoerr"
exit exit
fi fi
} }
bobainfoa () { bobainfoa () {
TestBorgRepo TestBorgRepo
borg info ./::$borg_repo borg info ./::$borg_repo
} }
DossierPresent () { DossierPresent () {
if [ ! -d "$1" ]; then if [ ! -d "$1" ]; then
inforerror=$(echo "Erreur, le dossier $1 est absent.\nFin du script.") inforerror=$(echo "Erreur, le dossier $1 est absent.\nFin du script.")
zenity --width=500 --error --text="$inforerror" zenity --width=500 --error --text="$inforerror"
exit exit
fi fi
} }
SauvegardeBorg () { SauvegardeBorg () {
DossierPresent $borg_repo DossierPresent $borg_repo
DossierPresent $borg_dir
zenity --width=500 --info --text=" zenity --width=500 --height=600 --info --text="$(cd $dossierprofil && cat $fichierprofil)"
Nom du dépôt : $borg_repo\n\
Nom archive : $borg_archive\n\
Compression : $borg_compress\n\
"
borg create $borg_excludes $borg_compress $borg_repo::$borg_archive $borg_dir | zenity --width=400 --progress --pulsate --auto-close --title="Sauvegarde en cours..." borg create $borg_excludes $borg_compress $borg_repo::$borg_archive $borg_dir | zenity --width=400 --progress --pulsate --auto-close --title="Sauvegarde en cours..."
sync | zenity --width=400 --progress --pulsate --auto-close --title="Syncronisation des écritures..." sync | zenity --width=400 --progress --pulsate --auto-close --title="Synchronisation des écritures..."
zenity --notification --text "Sauvegarde $nomsauvegarde terminée" zenity --notification --text "Sauvegarde $nomsauvegarde terminée"
zenity --width=300 --info --text "Sauvegarde $nomsauvegarde terminée" zenity --width=300 --info --text "Sauvegarde $nomsauvegarde terminée"
} }
# Profils et tests # Profils et tests
@ -70,11 +73,11 @@ else
fi fi
if [ "$nomsauvegarde" = "" ]; then if [ "$nomsauvegarde" = "" ]; then
infoerr=$(echo "Profil non défini ou incomplet.") infoerr=$(echo "Nom de sauvegarde non défini.")
zenity --width=200 --error --text="$infoerr" zenity --width=200 --error --text="$infoerr"
exit exit
elif [ "$borg_repo" = "" ]; then elif [ "$borg_repo" = "" ]; then
infoerr=$(echo "Profil non défini ou incomplet.") infoerr=$(echo "Variable \$borg_repo absente")
zenity --width=200 --error --text="$infoerr" zenity --width=200 --error --text="$infoerr"
exit exit
fi fi
@ -100,7 +103,7 @@ info_sauvegarde\n\
info_depot\n\ info_depot\n\
afficher_variables_profil\n\ afficher_variables_profil\n\
QUITTER\ QUITTER\
" | zenity --list --height=400 --width=400 --title "BORG GUI" --column "Dépôt : $nomsauvegarde") " | zenity --list --height=400 --width=400 --title "BORG GUI" --column "Nom : $nomsauvegarde")
if [ "$choixmenu" = "creer_sauvegarde" ] ;then if [ "$choixmenu" = "creer_sauvegarde" ] ;then
TestBorgRepo TestBorgRepo
@ -120,7 +123,7 @@ elif [ "$choixmenu" = "demonter_sauvegarde" ];then
elif [ "$choixmenu" = "supprimmer_sauvegarde" ];then elif [ "$choixmenu" = "supprimmer_sauvegarde" ];then
borg_archive=$(borg list --short $borg_repo | zenity --height=500 --list --title "Listes des archives" --column "Archive") borg_archive=$(borg list --short $borg_repo | zenity --height=500 --list --title "Listes des archives" --column "Archive")
borg delete $borg_repo::$borg_archive | zenity --width=400 --progress --pulsate --auto-close --title="Suppression en cours" borg delete $borg_repo::$borg_archive | zenity --width=400 --progress --pulsate --auto-close --title="Suppression en cours..."
zenity --width=200 --info --text="Suppresion terminée" zenity --width=200 --info --text="Suppresion terminée"
elif [ "$choixmenu" = "info_sauvegarde" ];then elif [ "$choixmenu" = "info_sauvegarde" ];then
@ -134,6 +137,9 @@ elif [ "$choixmenu" = "info_depot" ];then
elif [ "$choixmenu" = "afficher_variables_profil" ];then elif [ "$choixmenu" = "afficher_variables_profil" ];then
info=$(cd $dossierprofil && cat $fichierprofil) info=$(cd $dossierprofil && cat $fichierprofil)
zenity --width=500 --info --text="$info" zenity --width=500 --height=600 --info --text="$info"
elif [ "$choixmenu" = "" ];then
zenity --width=500 --info --text="Aucun choix, retour au menu."
fi fi
done done