mg
e4e84d2218
python zu 3 rest zfs Postfix Co-authored-by: Michael Grote <michael.grote@posteo.de> Reviewed-on: mg/ansible#22 Co-Authored-By: mg <mg@noreply.git.mgrote.net> Co-Committed-By: mg <mg@noreply.git.mgrote.net>
37 lines
793 B
Bash
37 lines
793 B
Bash
#!/bin/bash
|
|
{{ file_header | default () }}
|
|
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
|
|
LOCKDIR=${HOME}/.cache
|
|
# Get an exclusive lock or exit
|
|
function exlock() {
|
|
exec {lock_fd}>${LOCKDIR}/$(basename $0).lock
|
|
flock -nx "$lock_fd"
|
|
if [[ $? == 1 ]]; then
|
|
exit 1
|
|
fi
|
|
}
|
|
# Cleanup lock file and exit
|
|
function unlock() {
|
|
rm "${LOCKDIR}/$(basename $0).lock"
|
|
[[ -n $1 ]] && exit $1
|
|
exit 0
|
|
}
|
|
|
|
|
|
# Damit prueft ob das Script ob es schon laeuft
|
|
exlock
|
|
|
|
(
|
|
echo "--------------------------------------------------"
|
|
echo $(date +%d.%m.%Y-%T) sanoid start
|
|
echo ""
|
|
/usr/local/bin/sanoid --cron --verbose
|
|
echo ""
|
|
echo $(date +%d.%m.%Y-%T) sanoid end
|
|
) >> /var/log/sanoid-cron.log 2>&1 &
|
|
|
|
|
|
|
|
#Hiermit wird die Lockdatei geloescht
|
|
unlock
|