diff options
author | Alex Mekkering | 2017-07-21 15:11:17 +0200 |
---|---|---|
committer | Alex Mekkering | 2017-07-21 15:11:58 +0200 |
commit | 8be77977d0bac330b2da85194e8b7ac324a941e0 (patch) | |
tree | 9b4ebab347631dbb7876f9b95ce348f57a23498b | |
download | aur-systemd-unit-status-mail.tar.gz |
Initial commit
-rw-r--r-- | .SRCINFO | 15 | ||||
-rw-r--r-- | PKGBUILD | 20 | ||||
-rwxr-xr-x | unit-status-mail | 27 | ||||
-rw-r--r-- | unit-status-mail@.service | 7 |
4 files changed, 69 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..7e20b6ec8a59 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,15 @@ +pkgbase = systemd-unit-status-mail + pkgdesc = Service to mail a systemd's unit status + pkgver = 1.0.0 + pkgrel = 1 + arch = any + license = GPL3 + depends = coreutils + depends = smtp-forwarder + source = unit-status-mail + source = unit-status-mail@.service + sha256sums = f7f5808650bd09d75707059a918f451d7f150ff26e0e64526ed4e9e4ff2a80f1 + sha256sums = 7905bce82e8bbf387358f0360eeac49d6724a06eae0be1b8db5ae4ae8d4c8732 + +pkgname = systemd-unit-status-mail + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..575f950e65e7 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,20 @@ +# Maintainer: Alex Mekkering <amekkering at gmail dot com> + +pkgname=systemd-unit-status-mail + +pkgver=1.0.0 +pkgrel=1 +pkgdesc="Service to mail a systemd's unit status" +arch=(any) +license=('GPL3') +depends=('coreutils' 'smtp-forwarder') +source=('unit-status-mail' + 'unit-status-mail@.service' +) +sha256sums=('f7f5808650bd09d75707059a918f451d7f150ff26e0e64526ed4e9e4ff2a80f1' + '7905bce82e8bbf387358f0360eeac49d6724a06eae0be1b8db5ae4ae8d4c8732') + +package() { + install -D -m 755 "$srcdir/unit-status-mail" "$pkgdir/usr/bin/unit-status-mail" + install -D -m 644 "$srcdir/unit-status-mail@.service" "$pkgdir/usr/lib/systemd/system/unit-status-mail@.service" +} diff --git a/unit-status-mail b/unit-status-mail new file mode 100755 index 000000000000..46fc64381c1c --- /dev/null +++ b/unit-status-mail @@ -0,0 +1,27 @@ +#!/bin/bash +MAILTO="root" +MAILFROM="unit-status-mailer" +UNIT=$1 +DATE=$(date '+%F') + +EXTRA="" +for e in "${@:2}"; do + EXTRA+="$e"$'\n' +done + +UNITSTATUS=$(journalctl -S $DATE -l -n 100000 -u $UNIT) + +sendmail $MAILTO <<ENDOFMAILCONTENT +From:$MAILFROM +To:$MAILTO +Subject:Status mail for unit: $UNIT +Content-Transfer-Encoding: 8bit +Content-Type: text/plain; charset=UTF-8 + +Status report for unit: $UNIT +$EXTRA + +$UNITSTATUS +ENDOFMAILCONTENT + +echo -e "Status mail sent to: $MAILTO for unit: $UNIT" diff --git a/unit-status-mail@.service b/unit-status-mail@.service new file mode 100644 index 000000000000..04ed2342aaf5 --- /dev/null +++ b/unit-status-mail@.service @@ -0,0 +1,7 @@ +[Unit] +Description=Unit Status Mailer Service +After=network.target + +[Service] +Type=simple +ExecStart=/usr/bin/unit-status-mail %i "Hostname: %H" "Machine ID: %m" "Boot ID: %b" |