added an lock file to exit restarter if restart is already triggered

If you want multiple conditions (if ping is sucessfull, on less than X CPU Usage etc) for the restarter, it will create a lock file now to avoid multiple instances.
This commit is contained in:
Pakobbix 2023-02-14 20:36:17 +01:00 committed by GitHub
parent f9e234915d
commit c9faefa42c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,14 @@ containername=ebesucher
# Variable für die Maximale Nutzung von CPU Cores
CPUcores=
# Überprüfe ob bereits ein restart läuft
if [ -f /tmp/ebesucher_restart.lock ]; then
exit
fi
# Erstelle Lockfile
echo $$ > ebesucher_restart.lock
# Ordner des Skripts
git_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
# Wechsel in den Ordner
@ -41,3 +49,4 @@ elif [[ $ram_avail -ge "5" ]]; then
docker_run "4g" "$CPUSet"
fi
rm -f /tmp/ebesucher_restart.lock