AutoYADM commit: 2025-06-16 21:20:52
This commit is contained in:
parent
5177886bd2
commit
be7b577b3b
7 changed files with 67 additions and 0 deletions
47
.config/task/hooks/on-exit-sync.sh
Executable file
47
.config/task/hooks/on-exit-sync.sh
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/bin/sh
|
||||
|
||||
n=0
|
||||
while IFS= read -r _; do
|
||||
n=$((n + 1))
|
||||
done
|
||||
|
||||
if [ "$n" -gt 0 ]; then
|
||||
{
|
||||
lockfile="$HOME/.task/sync_hook.lock"
|
||||
errfile="$HOME/.task/sync_hook.err"
|
||||
lerrfile="$HOME/.task/sync_hook.errl"
|
||||
logfile="$HOME/.task/sync_hook.log"
|
||||
|
||||
flock "$lockfile" sh -c '
|
||||
task sync >>"$1" 2>"$2"
|
||||
status=$?
|
||||
if [ "$status" -ne 0 ]; then
|
||||
echo "Taskwarrior sync failed at $(date)" >>"$2"
|
||||
|
||||
if command -v sendmail >/dev/null 2>&1; then
|
||||
{
|
||||
echo "To: daniel@ficd.ca"
|
||||
echo "From: daniel@ficd.ca"
|
||||
echo "Subject: Taskwarrior Sync Failed on $(hostname)"
|
||||
echo "Date: $(date -R)"
|
||||
echo ""
|
||||
echo "task sync failed at $(date)"
|
||||
echo ""
|
||||
cat "$2"
|
||||
} | sendmail -t
|
||||
fi
|
||||
|
||||
cat "$2" >>"$3"
|
||||
|
||||
if command -v notify-send >/dev/null 2>&1; then
|
||||
notify-send --urgency=critical "taskwarrior sync failed"
|
||||
fi
|
||||
|
||||
exit 1
|
||||
fi
|
||||
' sh "$logfile" "$lerrfile" "$errfile" "$(hostname)"
|
||||
} >/dev/null 2>&1 </dev/null &
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue