1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/etherpad_mypads_ynh.git synced 2024-09-03 18:36:09 +02:00

Update _common.sh

This commit is contained in:
ericgaspar 2021-01-20 08:35:19 +01:00
parent 73fbbcb01f
commit f5117015c9
No known key found for this signature in database
GPG key ID: 574F281483054D44

View file

@ -4,28 +4,6 @@
# PERSONAL HELPERS
#=================================================
#=================================================
# BACKUP
#=================================================
HUMAN_SIZE () { # Transforme une taille en Ko en une taille lisible pour un humain
human=$(numfmt --to=iec --from-unit=1K $1)
echo $human
}
CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant
file_to_analyse=$1
backup_size=$(du --summarize "$file_to_analyse" | cut -f1)
free_space=$(df --output=avail "/home/yunohost.backup" | sed 1d)
if [ $free_space -le $backup_size ]
then
ynh_print_err "Espace insuffisant pour sauvegarder $file_to_analyse."
ynh_print_err "Espace disponible : $(HUMAN_SIZE $free_space)"
ynh_die "Espace nécessaire : $(HUMAN_SIZE $backup_size)"
fi
}
#=================================================
# FUTUR OFFICIAL HELPERS
#=================================================