summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Reimer2015-08-10 13:46:44 +0200
committerChristopher Reimer2015-08-10 13:46:44 +0200
commit43ada7f59ed6b29ee3dfd5e18bef0090f603c207 (patch)
tree69aa82ae94f2de77588a487012be536911763118
downloadaur-43ada7f59ed6b29ee3dfd5e18bef0090f603c207.tar.gz
Sync from VDR4Arch (https://github.com/VDR4Arch/vdr4arch/commit/7f69ddab9523aff9d6ed3ca4c5b511d9ad07e879)
-rw-r--r--.SRCINFO18
-rw-r--r--PKGBUILD30
-rw-r--r--lifeguard-use_ss_instead_of_netstat.diff64
3 files changed, 112 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..cdc47c12c9d7
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,18 @@
+pkgbase = vdr-addon-lifeguard
+ pkgdesc = check whether vdr should shutdown the machine
+ pkgver = 0.0.4
+ pkgrel = 3
+ url = http://e-tobi.net/vdr-experimental/pool-squeeze/source/addons
+ arch = any
+ license = GPL2
+ depends = bash
+ optdepends = samba: To check active samba connections
+ optdepends = afpfs-ng: To check active AFP connections
+ backup = etc/vdr/lifeguard.conf
+ source = http://e-tobi.net/vdr-experimental/pool-squeeze/source/addons/vdr-addon-lifeguard_0.0.4.tar.gz
+ source = lifeguard-use_ss_instead_of_netstat.diff
+ md5sums = 9494c1b691256452ead283f59956ebd4
+ md5sums = de99fdd8d1662150408200dcf095519f
+
+pkgname = vdr-addon-lifeguard
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..2350f59acdd1
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,30 @@
+# This PKGBUILD is part of the VDR4Arch project [https://github.com/vdr4arch]
+
+# Maintainer: Christopher Reimer <mail+vdr4arch[at]c-reimer[dot]de>
+pkgname=vdr-addon-lifeguard
+pkgver=0.0.4
+pkgrel=3
+pkgdesc="check whether vdr should shutdown the machine"
+url="http://e-tobi.net/vdr-experimental/pool-squeeze/source/addons"
+arch=('any')
+license=('GPL2')
+depends=('bash')
+optdepends=('samba: To check active samba connections'
+ 'afpfs-ng: To check active AFP connections')
+source=("http://e-tobi.net/vdr-experimental/pool-squeeze/source/addons/vdr-addon-lifeguard_0.0.4.tar.gz"
+ "lifeguard-use_ss_instead_of_netstat.diff")
+backup=('etc/vdr/lifeguard.conf')
+md5sums=('9494c1b691256452ead283f59956ebd4'
+ 'de99fdd8d1662150408200dcf095519f')
+
+prepare() {
+ cd "$srcdir/$pkgname-$pkgver"
+ patch -p1 -i "$srcdir/lifeguard-use_ss_instead_of_netstat.diff"
+}
+
+package() {
+ cd "$srcdir/$pkgname-$pkgver"
+ install -Dm755 "S91.lifeguard" "${pkgdir}/usr/lib/vdr/shutdown-hooks/S91.lifeguard"
+ install -Dm644 "lifeguard.conf" "${pkgdir}/etc/vdr/lifeguard.conf"
+ install -Dm644 "vdr-addon-lifeguard.1" "${pkgdir}/usr/share/man/man1/vdr-addon-lifeguard.1"
+}
diff --git a/lifeguard-use_ss_instead_of_netstat.diff b/lifeguard-use_ss_instead_of_netstat.diff
new file mode 100644
index 000000000000..d08ee4750273
--- /dev/null
+++ b/lifeguard-use_ss_instead_of_netstat.diff
@@ -0,0 +1,64 @@
+diff -ruN vdr-addon-lifeguard-0.0.4/lifeguard.conf vdr-addon-lifeguard-0.0.4.patched/lifeguard.conf
+--- vdr-addon-lifeguard-0.0.4/lifeguard.conf 2010-10-02 02:38:45.000000000 +0200
++++ vdr-addon-lifeguard-0.0.4.patched/lifeguard.conf 2013-08-07 19:34:19.579593330 +0200
+@@ -6,7 +6,7 @@
+
+ # standard entries
+ usr
+-cmd aptitude Aptitude
++cmd pacman Pacman
+ tcp ssh SSH
+ tcp nfs NFS\ Mount
+ tcp ftp FTP
+diff -ruN vdr-addon-lifeguard-0.0.4/S91.lifeguard vdr-addon-lifeguard-0.0.4.patched/S91.lifeguard
+--- vdr-addon-lifeguard-0.0.4/S91.lifeguard 2010-10-02 02:38:45.000000000 +0200
++++ vdr-addon-lifeguard-0.0.4.patched/S91.lifeguard 2013-08-07 19:34:05.217094413 +0200
+@@ -1,4 +1,4 @@
+-#! /bin/sh
++#! /bin/bash
+ #
+ # Given the types and search patterns in the configuration file, determine
+ # whether there are any processes or network connections that should
+@@ -23,7 +23,7 @@
+ ;;
+ usr)
+ # users logged into the system
+- [ ${PATTERN:=".*"} ]
++ PATTERN=${PATTERN:=".*"}
+ if [ $(users | grep -cE "\b$PATTERN\b") -gt 0 ]; then
+ REASON=${DESCRIPTION:-"active user"}
+ break
+@@ -38,7 +38,7 @@
+ # - it uses language specific search patterns that will fail with localized versions of ping
+ # - ping is slow if the specified host does not answer
+ #
+- [ ${PATTERN:="."} ]
++ PATTERN=${PATTERN:="."}
+ TEMP=mktemp
+ ping -c 1 -q $PATTERN >& $TEMP
+ if [ $(grep -c "unknown host" $TEMP) -eq 0 ] && [ $(grep -e "transmitted.*received" $TEMP | cut -d "," -f 2 | cut -d " " -f 2) -gt 0 ]; then
+@@ -60,7 +60,7 @@
+ tcp)
+ # network connections
+ # test only the local ports of tcp connections
+- if [ $(netstat -t | grep -e "^tcp" | grep -ve "CLOSE_WAIT[ \t]*$" | sed -re "s/ +/ /g" | cut -d " " -f 4 | grep -cE ":$PATTERN\b") -gt 0 ]; then
++ if [ $(ss -t -o state established | tail -n +2 | awk '{print $3}' | grep -cE ":$PATTERN\b") -gt 0 ]; then
+ REASON=${DESCRIPTION:-"$PATTERN"}
+ break
+ fi
+diff -ruN vdr-addon-lifeguard-0.0.4/vdr-addon-lifeguard.1 vdr-addon-lifeguard-0.0.4.patched/vdr-addon-lifeguard.1
+--- vdr-addon-lifeguard-0.0.4/vdr-addon-lifeguard.1 2010-10-02 02:38:45.000000000 +0200
++++ vdr-addon-lifeguard-0.0.4.patched/vdr-addon-lifeguard.1 2013-08-07 19:35:17.879538766 +0200
+@@ -82,10 +82,9 @@
+ shutdown is cancelled. If no description is specified, the pattern or a predefind explanation will be used instead.
+
+ .SH FILES
+-/etc/vdr/lifeguard.conf, /usr/share/vdr/S91.lifeguard
++/etc/vdr/lifeguard.conf, /usr/share/vdr/shutdown-hooks/S91.lifeguard
+ .SH SEE ALSO
+-.BR vdr (1),
+-.BR /usr/share/doc/vdr/README.Debian
++.BR vdr (1)
+ .br
+ .SH AUTHOR
+ vdr-addon-lifeguard and this manpage were written by Malte Forkel <malte.forkel@berlin.de>, for the Debian project (but may be used by others).