diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2009-07-24 08:01:31 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2009-07-24 08:01:31 +0000 |
commit | b70981b68efcce5256eb11c6cd26ae123b10b6ea (patch) | |
tree | a38be6efae5e2ba15c2e839504632f9b7bfd5f91 /main/djbdns/dnscache.initd | |
parent | 2b4df81538b8398442d5296650905c70341dd8d3 (diff) | |
download | aports-b70981b68efcce5256eb11c6cd26ae123b10b6ea.tar.bz2 aports-b70981b68efcce5256eb11c6cd26ae123b10b6ea.tar.xz |
moved extra/* to main/
and fixed misc build issues
Diffstat (limited to 'main/djbdns/dnscache.initd')
-rwxr-xr-x | main/djbdns/dnscache.initd | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/main/djbdns/dnscache.initd b/main/djbdns/dnscache.initd new file mode 100755 index 000000000..481022496 --- /dev/null +++ b/main/djbdns/dnscache.initd @@ -0,0 +1,59 @@ +#!/sbin/runscript +# control n instances of dnscache, without daemontools +# 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 + + +#----------------------------------------------------------------- +# Main program + +start() { + + ebegin "Starting dnscache" + if [ -z "$UID" ] || [ -z "$GID" ]; then + eend 1 "dnscache user or group missing" + 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 + ) +} + +stop() { + ebegin "Stopping dnscache" + start-stop-daemon --stop -m --pidfile ${VARRUN}.pid --oknodo \ + --exec $DAEMON && rm ${VARRUN}.pid + eend $? +} + |