aboutsummaryrefslogtreecommitdiffstats
path: root/main/djbdns/dnscache.initd
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2009-07-30 13:07:09 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2009-07-30 13:07:09 +0000
commit4259b276a2df2018458a622e3ceedad38b1c22ec (patch)
tree1aff1fc5f69de536d5b71bb2b76005c6b68f8924 /main/djbdns/dnscache.initd
parentb36359dbd01c71a5b10cc9c95efaff4cc1db57ef (diff)
downloadaports-4259b276a2df2018458a622e3ceedad38b1c22ec.tar.bz2
aports-4259b276a2df2018458a622e3ceedad38b1c22ec.tar.xz
main/dnscache: fix init.d script
fixes #101
Diffstat (limited to 'main/djbdns/dnscache.initd')
-rwxr-xr-xmain/djbdns/dnscache.initd44
1 files changed, 11 insertions, 33 deletions
diff --git a/main/djbdns/dnscache.initd b/main/djbdns/dnscache.initd
index 481022496e..986094a1f0 100755
--- a/main/djbdns/dnscache.initd
+++ b/main/djbdns/dnscache.initd
@@ -3,17 +3,17 @@
# written for alpine linux - NBA April 2007
# -- Statrup variables
-UID=$( grep dnscache /etc/passwd | cut -f3 -d: )
-GID=$( grep dnscache /etc/group | cut -f3 -d: )
ROOT=/etc/dnscache
DAEMON=/usr/bin/dnscache
-VARRUN=/var/run/dnscache
+PIDFILE=/var/run/dnscache.pid
#-----------------------------------------------------------------
# Main program
start() {
+ UID=$( grep dnscache /etc/passwd | cut -f3 -d: )
+ GID=$( grep dnscache /etc/group | cut -f3 -d: )
ebegin "Starting dnscache"
if [ -z "$UID" ] || [ -z "$GID" ]; then
@@ -21,39 +21,17 @@ start() {
return 1
fi
- # if its already running, just report it is
- if [ -e ${VARRUN}.pid ] && [ -d /proc/$( cat ${VARRUN}.pid ) ]; then
- eend 0
- return 0
- fi
-
- (
- export UID GID ROOT
- [ -n "$IPSEND" ] && export IPSEND
- [ -n "$IP" ] && export IP
- [ -n "$HIDETTL" ] && export HIDETTL
- [ -n "$IPSEND" ] && export IPSEND
- [ -n "$CACHESIZE" ] && export CACHESIZE
- [ -n "$FORWARDONLY" ] && export FORWARDONLY
-
- $DAEMON </dev/urandom >/dev/null 2>/dev/null &
- pid=$!
- sleep 1
- # Check if its still running
- if ! [ -d /proc/$pid ]; then
- $DAEMON </dev/urandom
- return 1
- fi
- echo $pid > ${VARRUN}.pid
- eend $?
- return 0
- )
+ start-stop-daemon --start --env "UID=$UID" --env "GID=$GID" \
+ --env "ROOT=$ROOT" --env "IP=$IP" --env "IPSEND=$IPSEND" \
+ --env "HIDETTL=$HIDETTL" --env "CACHESIZE=$CACHESIZE" \
+ --env "FORWARDONLY=$FORWARDONLY" --pidfile $PIDFILE \
+ --background --make-pidfile --exec $DAEMON
+ eend $?
}
stop() {
ebegin "Stopping dnscache"
- start-stop-daemon --stop -m --pidfile ${VARRUN}.pid --oknodo \
- --exec $DAEMON && rm ${VARRUN}.pid
- eend $?
+ start-stop-daemon --stop --pidfile $PIDFILE --exec $DAEMON
+ eend $?
}