1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/restic_ynh.git synced 2024-09-03 20:16:22 +02:00

feat: Remove backup lock file on interruption

This commit is contained in:
Lionel Coupouchetty-Ramouchetty 2020-02-23 19:20:42 +01:00
parent 9db6bf1f92
commit 42c5eeb9a7

View file

@ -1,5 +1,14 @@
#!/bin/bash #!/bin/bash
LOCK_FILE=/tmp/{{ app }}_backup.lock LOCK_FILE=/tmp/{{ app }}_backup.lock
EXIT_PROPERLY() {
echo -e "\e[91m \e[1m" # Shell in light red bold
echo -e "!!\n Caught an interruption signal, removing lock file...\n!!"
echo -e "\e[22m" # Remove bold
rm $LOCK_FILE
exit 1
}
trap EXIT_PROPERLY 1 2 3 6 15
if [ -f "$LOCK_FILE" ];then if [ -f "$LOCK_FILE" ];then
echo "Backup already launched by process $(grep '.*' $LOCK_FILE), canceling this one" >&2 echo "Backup already launched by process $(grep '.*' $LOCK_FILE), canceling this one" >&2
exit 1 exit 1