shellchecking

This commit is contained in:
Jonas Forsberg
2020-10-13 09:13:20 +02:00
parent a4bbc226f2
commit 8faaf0922a
4 changed files with 25 additions and 12 deletions

View File

@@ -2,13 +2,13 @@
[[ ! -f "$HOME/.borgbackup.env" ]] && printf "\$HOME/.borgbackup.env doesn't exist!\n" && exit 1
if [[ "$(stat -c %A $HOME/.borgbackup.env)" != "-rw-------" ]]; then
if [[ "$(stat -c "$HOME/.borgbackup.env")" != "-rw-------" ]]; then
printf "WARNING!!!! \$HOME/.borgbackup.env has the wrong permissions!\n"
printf "\nrun : chmod 0600 \$HOME/.borgbackup.env\n"
exit 1
fi
source "$HOME/.borgbackup.env"
source "${HOME}/.borgbackup.env"
# some helpers and error handling:
@@ -78,3 +78,16 @@ borg prune \
--keep-monthly 6 \
prune_exit=$?
# use highest exit code as global exit code
global_exit=$(( backup_exit > prune_exit ? backup_exit : prune_exit ))
if [ ${global_exit} -eq 0 ]; then
info "Backup and Prune finished successfully"
elif [ ${global_exit} -eq 1 ]; then
info "Backup and/or Prune finished with warnings"
else
info "Backup and/or Prune finished with errors"
fi
exit ${global_exit}