From 659459ddd335266915d1f517a1080dd93ddb6089 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Sat, 9 Nov 2019 15:09:54 -0500 Subject: [PATCH] Add systemd config for running as a service --- systemd/doorUpdater.service | 9 +++++++++ systemd/doorUpdater.timer | 9 +++++++++ systemd/status-email-admin@.service | 8 ++++++++ systemd/systemd-email | 11 +++++++++++ 4 files changed, 37 insertions(+) create mode 100644 systemd/doorUpdater.service create mode 100644 systemd/doorUpdater.timer create mode 100644 systemd/status-email-admin@.service create mode 100755 systemd/systemd-email diff --git a/systemd/doorUpdater.service b/systemd/doorUpdater.service new file mode 100644 index 0000000..4287ec3 --- /dev/null +++ b/systemd/doorUpdater.service @@ -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 diff --git a/systemd/doorUpdater.timer b/systemd/doorUpdater.timer new file mode 100644 index 0000000..6575595 --- /dev/null +++ b/systemd/doorUpdater.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Hourly HID door control update + +[Timer] +OnCalendar=*:0/15 +Persistent=true + +[Install] +WantedBy=timers.target diff --git a/systemd/status-email-admin@.service b/systemd/status-email-admin@.service new file mode 100644 index 0000000..f50778f --- /dev/null +++ b/systemd/status-email-admin@.service @@ -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 \ No newline at end of file diff --git a/systemd/systemd-email b/systemd/systemd-email new file mode 100755 index 0000000..610daa4 --- /dev/null +++ b/systemd/systemd-email @@ -0,0 +1,11 @@ +#!/bin/bash + +/usr/sbin/sendmail -t < +Subject: $2 failed on $(hostname) +Content-Transfer-Encoding: 8bit +Content-Type: text/plain; charset=UTF-8 + +$(systemctl status --full "$2") +ERRMAIL