add bundle:systemd-timers

This commit is contained in:
Franzi 2022-02-06 13:39:52 +01:00
parent 2a3a26c333
commit 0599c4dae0
Signed by: kunsi
GPG key ID: 12E3D2136B818350
7 changed files with 145 additions and 0 deletions

View file

@ -0,0 +1,24 @@
#!/bin/sh
if [[ -z "$1" ]]
then
echo "Usage: $0 <timer>"
exit 3
fi
if ! [[ -f "/var/lib/systemd-timer-monitored/$1" ]]
then
echo "No status file found"
exit 3
fi
exitcode="$(cat "/var/lib/systemd-timer-monitored/$1")"
echo "Last timer run exited $exitcode"
if [[ $exitcode -ne 0 ]]
then
exit 2
else
exit 0
fi

View file

@ -0,0 +1,10 @@
#!/bin/sh
timer="$1"
shift
# Simple wrapper script that stores the exit code of a command into a file
"$@"
exitcode=$?
echo "$exitcode" > "/var/lib/systemd-timer-monitored/$timer"

View file

@ -0,0 +1,15 @@
[Unit]
Description=Service for Timer ${timer}
After=network.target
% if config.get('requires', ''):
Requires=${config['requires']}
% endif
[Service]
User=${config.get('user', 'root')}
Group=${config.get('group', config.get('user', 'root'))}
% for k, v in sorted(config.get('environment', {}).items()):
Environment=${k}=${v}
% endfor
WorkingDirectory=${config.get('pwd', '/')}
ExecStart=/usr/local/sbin/systemd-timer-monitored ${timer} ${config['command']}

View file

@ -0,0 +1,13 @@
[Unit]
Description=Timer for Service ${timer}
[Timer]
OnCalendar=${config['when']}
% if config.get('persistent', True):
Persistent=true
% else:
Persistent=false
% endif
[Install]
WantedBy=timers.target