blob: f33b1ee044c156efb0104a31ec56c720b519e527 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
#!/sbin/runscript
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-dns/ez-ipupdate/files/ez-ipupdate.initd,v 1.4 2013/10/13 16:00:04 pacho Exp $
extra_commands="update"
depend() {
need net
after rp-pppoe
}
getconfig() { # 0: no daemon / 1: daemon
local CONF NAME LIST=""
for CONF in /etc/ez-ipupdate/*.conf; do
if [ -f "${CONF}" ]; then
# Don't run configurations that are (not) daemons
grep -q '^[[:space:]]*daemon' "${CONF}"; [ $? -eq $1 ] && continue
# Don't run configurations that run in the foreground
grep -q '^[[:space:]]*foreground' "${CONF}" && continue
# add config to list
NAME="${CONF##*/}"
LIST="${LIST} ${NAME%.*}"
fi
done
echo ${LIST}
}
start() {
local NAME LIST=$(getconfig 1)
if [ -z "${LIST}" ]; then
eerror "You need at least one config file in /etc/ez-ipupdate"
eerror "containing the 'daemon' keyword and no 'foreground' keyword."
return 1
fi
if [ ! -d /var/run/ez-ipupdate ]; then
mkdir -p /var/run/ez-ipupdate && chown ez-ipupd:ez-ipupd /var/run/ez-ipupdate
fi
for NAME in ${LIST}; do
local CONFIG="/etc/ez-ipupdate/${NAME}.conf"
local PIDFILE="/var/run/ez-ipupdate/${NAME}.pid"
local CACHEFILE="/var/cache/ez-ipupdate/${NAME}.cache"
ebegin "Starting ez-ipupdate (${NAME})"
start-stop-daemon -p "${PIDFILE}" --start --quiet --exec /usr/sbin/ez-ipupdate \
--chuid ez-ipupd -- -c "${CONFIG}" -F "${PIDFILE}" -b "${CACHEFILE}"
eend $?
done
return 0 # do not fail
}
stop() {
local PIDFILE NAME
for PIDFILE in /var/run/ez-ipupdate/*.pid; do
if [ -f "${PIDFILE}" ]; then
NAME="${PIDFILE##*/}"
ebegin "Stopping ez-ipupdate (${NAME%.*})"
start-stop-daemon --stop --signal QUIT --quiet --pidfile "${PIDFILE}"
eend $? || rm -f "${PIDFILE}"
else
eerror "No running ez-ipupdate process"
fi
done
return 0 # do not fail
}
update() {
local NAME TEXT LIST=$(getconfig 0)
if [ -z "${LIST}" ]; then
eerror "You need at least one config file in /etc/ez-ipupdate"
eerror "containing no 'daemon' and 'foreground' keyword."
return 1
fi
for NAME in ${LIST}; do
local CONFIG="/etc/ez-ipupdate/${NAME}.conf"
local CACHEFILE="/var/cache/ez-ipupdate/${NAME}.cache"
ebegin "Running ez-ipupdate (${NAME})"
TEXT=$(/usr/sbin/ez-ipupdate -q -R ez-ipupd -c "${CONFIG}" -b "${CACHEFILE}" 2>&1)
if eend $?; then
if [ -n "${TEXT}" ]; then
echo "${TEXT}" | while read line; do einfo " $line"; done
fi
else
if [ -n "${TEXT}" ]; then
echo "${TEXT}" | while read line; do eerror " $line"; done
fi
fi
done
return 0 # do not fail
}
|