Add systemd config for running as a service

This commit is contained in:
Adam Goldsmith 2019-11-09 15:09:54 -05:00
parent 2b894d3cc9
commit 659459ddd3
4 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,9 @@
[Unit]
Description=Update HID door controls
OnFailure=status-email-admin@%n.service
[Service]
User=adam
Type=oneshot
WorkingDirectory=/home/adam/hidDoorWriter/
ExecStart=/home/adam/hidDoorWriter/doorUpdater.py

View File

@ -0,0 +1,9 @@
[Unit]
Description=Hourly HID door control update
[Timer]
OnCalendar=*:0/15
Persistent=true
[Install]
WantedBy=timers.target

View File

@ -0,0 +1,8 @@
[Unit]
Description=status email for %i to sysadmin addresses
[Service]
Type=oneshot
ExecStart=/usr/local/bin/systemd-email "cms-errors@adamgoldsmith.name, steve@stevegoldsmith.com" %i
User=nobody
Group=systemd-journal

11
systemd/systemd-email Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
/usr/sbin/sendmail -t <<ERRMAIL
To: $1
From: systemd <root@$HOSTNAME>
Subject: $2 failed on $(hostname)
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=UTF-8
$(systemctl status --full "$2")
ERRMAIL