Skip to content

Commit df8d264

Browse files
committed
Add vdr-addon-lifeguard
1 parent 83a0d95 commit df8d264

File tree

5 files changed

+112
-2
lines changed

5 files changed

+112
-2
lines changed

vdr-addon-lifeguard/PKGBUILD

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Maintainer: Christopher Reimer <vdr4arch[at]creimer[dot]net>
2+
pkgname=vdr-addon-lifeguard
3+
pkgver=0.0.4
4+
pkgrel=1
5+
pkgdesc="check whether vdr should shutdown the machine"
6+
url="http://e-tobi.net/vdr-experimental/pool-squeeze/source/addons"
7+
arch=('any')
8+
license=('GPL2')
9+
depends=('bash')
10+
optdepends=('samba: To check active samba connections'
11+
'afpfs-ng: To check active AFP connections')
12+
source=("http://e-tobi.net/vdr-experimental/pool-squeeze/source/addons/vdr-addon-lifeguard_0.0.4.tar.gz"
13+
"lifeguard-use_ss_instead_of_netstat.diff")
14+
backup=('etc/vdr/lifeguard.conf')
15+
md5sums=('9494c1b691256452ead283f59956ebd4'
16+
'de99fdd8d1662150408200dcf095519f')
17+
18+
prepare() {
19+
cd "$srcdir/$pkgname-$pkgver"
20+
patch -p1 -i "$srcdir/lifeguard-use_ss_instead_of_netstat.diff"
21+
}
22+
23+
package() {
24+
cd "$srcdir/$pkgname-$pkgver"
25+
install -Dm755 "lifeguard.conf" "${pkgdir}/etc/vdr/lifeguard.conf"
26+
install -Dm644 "S91.lifeguard" "${pkgdir}/usr/share/vdr/shutdown-hooks/S91.lifeguard"
27+
install -Dm644 "vdr-addon-lifeguard.1" "${pkgdir}/usr/share/man/man1/vdr-addon-lifeguard.1"
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
diff -ruN vdr-addon-lifeguard-0.0.4/lifeguard.conf vdr-addon-lifeguard-0.0.4.patched/lifeguard.conf
2+
--- vdr-addon-lifeguard-0.0.4/lifeguard.conf 2010-10-02 02:38:45.000000000 +0200
3+
+++ vdr-addon-lifeguard-0.0.4.patched/lifeguard.conf 2013-08-07 19:34:19.579593330 +0200
4+
@@ -6,7 +6,7 @@
5+
6+
# standard entries
7+
usr
8+
-cmd aptitude Aptitude
9+
+cmd pacman Pacman
10+
tcp ssh SSH
11+
tcp nfs NFS\ Mount
12+
tcp ftp FTP
13+
diff -ruN vdr-addon-lifeguard-0.0.4/S91.lifeguard vdr-addon-lifeguard-0.0.4.patched/S91.lifeguard
14+
--- vdr-addon-lifeguard-0.0.4/S91.lifeguard 2010-10-02 02:38:45.000000000 +0200
15+
+++ vdr-addon-lifeguard-0.0.4.patched/S91.lifeguard 2013-08-07 19:34:05.217094413 +0200
16+
@@ -1,4 +1,4 @@
17+
-#! /bin/sh
18+
+#! /bin/bash
19+
#
20+
# Given the types and search patterns in the configuration file, determine
21+
# whether there are any processes or network connections that should
22+
@@ -23,7 +23,7 @@
23+
;;
24+
usr)
25+
# users logged into the system
26+
- [ ${PATTERN:=".*"} ]
27+
+ PATTERN=${PATTERN:=".*"}
28+
if [ $(users | grep -cE "\b$PATTERN\b") -gt 0 ]; then
29+
REASON=${DESCRIPTION:-"active user"}
30+
break
31+
@@ -38,7 +38,7 @@
32+
# - it uses language specific search patterns that will fail with localized versions of ping
33+
# - ping is slow if the specified host does not answer
34+
#
35+
- [ ${PATTERN:="."} ]
36+
+ PATTERN=${PATTERN:="."}
37+
TEMP=mktemp
38+
ping -c 1 -q $PATTERN >& $TEMP
39+
if [ $(grep -c "unknown host" $TEMP) -eq 0 ] && [ $(grep -e "transmitted.*received" $TEMP | cut -d "," -f 2 | cut -d " " -f 2) -gt 0 ]; then
40+
@@ -60,7 +60,7 @@
41+
tcp)
42+
# network connections
43+
# test only the local ports of tcp connections
44+
- 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
45+
+ if [ $(ss -t -o state established | tail -n +2 | awk '{print $3}' | grep -cE ":$PATTERN\b") -gt 0 ]; then
46+
REASON=${DESCRIPTION:-"$PATTERN"}
47+
break
48+
fi
49+
diff -ruN vdr-addon-lifeguard-0.0.4/vdr-addon-lifeguard.1 vdr-addon-lifeguard-0.0.4.patched/vdr-addon-lifeguard.1
50+
--- vdr-addon-lifeguard-0.0.4/vdr-addon-lifeguard.1 2010-10-02 02:38:45.000000000 +0200
51+
+++ vdr-addon-lifeguard-0.0.4.patched/vdr-addon-lifeguard.1 2013-08-07 19:35:17.879538766 +0200
52+
@@ -82,10 +82,9 @@
53+
shutdown is cancelled. If no description is specified, the pattern or a predefind explanation will be used instead.
54+
55+
.SH FILES
56+
-/etc/vdr/lifeguard.conf, /usr/share/vdr/S91.lifeguard
57+
+/etc/vdr/lifeguard.conf, /usr/share/vdr/shutdown-hooks/S91.lifeguard
58+
.SH SEE ALSO
59+
-.BR vdr (1),
60+
-.BR /usr/share/doc/vdr/README.Debian
61+
+.BR vdr (1)
62+
.br
63+
.SH AUTHOR
64+
vdr-addon-lifeguard and this manpage were written by Malte Forkel <[email protected]>, for the Debian project (but may be used by others).

vdr/PKGBUILD

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Maintainer: Christopher Reimer <vdr4arch[at]creimer[dot]net>
22
pkgname=vdr
33
pkgver=2.0.2
4-
pkgrel=2
4+
pkgrel=3
55
pkgdesc="'open' digital satellite receiver and timer controlled video disk recorder"
66
url="http://tvdr.de/"
77
arch=('x86_64' 'i686')
@@ -27,7 +27,7 @@ source=("ftp://ftp.tvdr.de/vdr/${pkgname}-${pkgver}.tar.bz2"
2727
md5sums=('5359cae7e14671cc9a3c690d45d8e0a2'
2828
'301c9b9766ed5182b07f1debc79abc21'
2929
'6877c9efd84261c4a0471e657edce52d'
30-
'ef8e11062f58a9eb4016dfbf66bb9044'
30+
'fb1f52d7decba2df9c5d00c70040984a'
3131
'7cad811b4ac5ee6c0b5496d006f1e0ee')
3232

3333
prepare() {

vdr/shutdown.sh

100644100755
+13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
#!/bin/bash
2+
3+
#Run through shutdown-hooks
4+
for file in /usr/share/vdr/shutdown-hooks/*; do
5+
if [ -x $file ]; then
6+
MESSAGE=$($file)
7+
if [ $? != '0' ]; then
8+
MESSAGE=$(echo "$MESSAGE" | sed -rn '0,/ABORT_MESSAGE/s/^ABORT_MESSAGE="?([^"]+).*/\1/p')
9+
svdrpsend MESG "$MESSAGE"
10+
exit 1
11+
fi
12+
fi
13+
done
14+
215
#Sync back system time to hardware time (Maybe VDR has changed it)
316
hwclock --systohc --utc
417

vdr/vdr.install

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ post_install() {
77
mkdir -p var/cache/vdr
88
chown -R vdr:vdr var/cache/vdr
99

10+
#Create shutdown-hooks dir
11+
mkdir -p usr/share/vdr/shutdown-hooks
12+
1013
#Create videodir
1114
mkdir -p srv/vdr/video
1215
chown -R vdr:vdr srv/vdr
@@ -17,6 +20,8 @@ post_install() {
1720
post_upgrade() {
1821
chown -R vdr:vdr var/lib/vdr
1922

23+
mkdir -p usr/share/vdr/shutdown-hooks
24+
2025
chgrp vdr usr/lib/vdr/bin/shutdown-wrapper
2126
chmod u+s usr/lib/vdr/bin/shutdown-wrapper
2227
}

0 commit comments

Comments
 (0)