aboutsummaryrefslogtreecommitdiffstats
path: root/main/djbdns/dnscache.initd
blob: 37d9d9ba73a4e2868d2ba56292047c8e5563a9cd (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
#!/sbin/runscript
# control n instances of dnscache, without daemontools
# written for alpine linux - NBA April 2007

# -- Statrup variables 
ROOT=/etc/dnscache
DAEMON=/usr/bin/dnscache
PIDFILE=/var/run/dnscache.pid

depend() {
	need net
	after firewall
	provide dns
}

#-----------------------------------------------------------------
# Main program

start() {
	UID=$(id -u dnscache)
	GID=$(id -g dnscache)
	
	ebegin "Starting dnscache"
	if [ -z "$UID" ] || [ -z "$GID" ]; then
		eend 1 "dnscache user or group missing"
		return 1
	fi

	OPTS=""
	[ "$FORWARDONLY" ] && OPTS="$OPTS --env FORWARDONLY=$FORWARDONLY"
	[ "$HIDETTL" ] && OPTS="$OPTS --env HIDETTL=$HIDETTL"
	[ "$CACHESIZE" ] && OPTS="$OPTS --env CACHESIZE=$CACHESIZE"
	
	start-stop-daemon --start --env "UID=$UID" --env "GID=$GID" \
		--env "ROOT=$ROOT" --env "IP=$IP" --env "IPSEND=$IPSEND" \
		$OPTS --pidfile $PIDFILE \
		--background --make-pidfile --exec $DAEMON -- < /dev/urandom
	eend $?
}

stop() {
	ebegin "Stopping dnscache"
        start-stop-daemon --stop --pidfile $PIDFILE --exec $DAEMON
        eend $?
}