From 0cabd2182ff51470ac7e332b5649a9bb0a072e40 Mon Sep 17 00:00:00 2001 From: "Patrick Burroughs (Celti)" Date: Fri, 15 Apr 2016 16:02:19 -0700 Subject: [PATCH 1/2] Add a systemd timer for cron-pacmatic --- PKGBUILD | 12 +++++++----- pacmatic.1 | 6 +++++- pacmatic@.service | 6 ++++++ pacmatic@.timer | 8 ++++++++ 4 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 pacmatic@.service create mode 100644 pacmatic@.timer diff --git a/PKGBUILD b/PKGBUILD index 1b01af8..600d7c7 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,7 +1,7 @@ # $Id: PKGBUILD 100043 2013-10-31 15:45:57Z kkeen $ # Maintainer: Kyle Keen pkgname=pacmatic -pkgver=20141006 +pkgver=20160415 pkgrel=1 pkgdesc="A pacman wrapper to avoid bricking your system and such other surprises." arch=('any') @@ -19,9 +19,11 @@ md5sums=('1fe11adaa39aae9d3146ddbc3808eb23' package() { cd "$srcdir/$pkgname" - install -Dm0755 pacmatic "$pkgdir/usr/bin/pacmatic" - install -Dm0755 cron-pacmatic "$pkgdir/usr/bin/cron-pacmatic" - install -Dm0644 pacmatic.1 "$pkgdir/usr/share/man/man1/pacmatic.1" - install -Dm0644 ../_pacmatic "$pkgdir/usr/share/zsh/site-functions/_pacmatic" + install -Dm0755 pacmatic "$pkgdir/usr/bin/pacmatic" + install -Dm0755 cron-pacmatic "$pkgdir/usr/bin/cron-pacmatic" + install -Dm0644 pacmatic.1 "$pkgdir/usr/share/man/man1/pacmatic.1" + install -Dm0644 ../_pacmatic "$pkgdir/usr/share/zsh/site-functions/_pacmatic" + install -Dm0644 pacmatic@.service "$pkgdir/usr/lib/systemd/system/pacmatic@.service" + install -Dm0644 pacmatic@.timer "$pkgdir/usr/lib/systemd/system/pacmatic@.timer" } diff --git a/pacmatic.1 b/pacmatic.1 index 10c6d89..c2a445d 100644 --- a/pacmatic.1 +++ b/pacmatic.1 @@ -58,7 +58,11 @@ In case you want even higher levels of automation, there is a .Nm cron-pacmatic script. This script can be run periodically and will email you a summary of .Nm -output. +output. The +.Nm pacmatic@.timer +systemd unit is provided to schedule it. Enable it as +.Ic pacmatic@ Ns Em your\ex40mail.tld Ns Ic .timer +(with escaping). .Pp .Sh AUTHORS .An -nosplit diff --git a/pacmatic@.service b/pacmatic@.service new file mode 100644 index 0000000..eb68a7a --- /dev/null +++ b/pacmatic@.service @@ -0,0 +1,6 @@ +[Unit] +Description=Email list of pending updates to %I + +[Service] +Type=oneshot +ExecStart=/usr/bin/cron-pacmatic %I diff --git a/pacmatic@.timer b/pacmatic@.timer new file mode 100644 index 0000000..1dc0224 --- /dev/null +++ b/pacmatic@.timer @@ -0,0 +1,8 @@ +[Unit] +Description=Email list of pending updates to %I timer + +[Timer] +OnCalendar=daily UTC + +[Install] +WantedBy=multi-user.target From 702a241fea33667e84020b87d782cb3cc5adda4e Mon Sep 17 00:00:00 2001 From: "Patrick Burroughs (Celti)" Date: Fri, 15 Apr 2016 19:53:56 -0700 Subject: [PATCH 2/2] Enable batch mode for mail By default, s-nail mail sends mail asynchronously. If running within a systemd unit, cron-pacmatic will exit before the message is finished sending and systemd will reap the entire control group, killing the message. Enabling batch mode prevents this issue. --- cron-pacmatic | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cron-pacmatic b/cron-pacmatic index 6d37fec..a719f4c 100755 --- a/cron-pacmatic +++ b/cron-pacmatic @@ -36,5 +36,5 @@ if [[ -n $packages ]]; then echo "Recent ML chatter: $mail_counts" >> $mail_body echo "Pacman updates: $packages" >> $mail_body cat $mail_body |\ - mail -s "Updates available on $(hostname)" $1 + mail -# -s "Updates available on $(hostname)" $1 fi