2
# Copyright (c) 2001 J�rg Mayer
3
# based on /etc/init.d/skeleton which is
4
# Copyright (c) 1995-2000 SuSE GmbH Nuernberg, Germany.
7
# Author: J�rg Mayer <jmayer@loplof.de>
11
# and symbolic its link
15
# System startup script for the nessus backend nessusd
19
# Required-Start: $network $remote_fs $syslog
20
# Required-Stop: $remote_fs $syslog
22
# Default-Stop: 0 1 2 6
23
# Description: This script starts your DNS caching server
29
# Determine the base and follow a runlevel link name.
31
link=${base#*[SK][0-9][0-9]}
33
# Force execution if not called by a runlevel directory.
34
test $link = $base && START_DNSMASQ=yes
35
test "$START_DNSMASQ" = yes || exit 0
37
DNSMASQ=/usr/sbin/dnsmasq
38
test -x $DNSMASQ || exit 5
40
# Shell functions sourced from /etc/rc.status:
41
# rc_check check and set local and overall rc status
42
# rc_status check and set local and overall rc status
43
# rc_status -v ditto but be verbose in local rc status
44
# rc_status -v -r ditto and clear the local rc status
45
# rc_failed set local and overall rc status to failed
46
# rc_failed <num> set local and overall rc status to <num><num>
47
# rc_reset clear local rc status (overall remains)
48
# rc_exit exit appropriate to overall rc status
51
# First reset status of this service
54
# Return values acc. to LSB for all commands but status:
56
# 1 - generic or unspecified error
57
# 2 - invalid or excess argument(s)
58
# 3 - unimplemented feature (e.g. "reload")
59
# 4 - insufficient privilege
60
# 5 - program is not installed
61
# 6 - program is not configured
62
# 7 - program is not running
64
# Note that starting an already running service, stopping
65
# or restarting a not-running service as well as the restart
66
# with force-reload (in case signalling is not supported) are
67
# considered a success.
72
# change this line if you want dnsmasq to serve an MX record for
73
# the host it is running on.
75
# change this line if you want dns to get its upstream servers
76
# from somewhere other that /etc/resolv.conf
78
# change this if you want dnsmasq to cache any "hostname" or
79
# "client-hostname" from a dhcpd's lease file
80
DHCP_LEASE="/var/lib/dhcp/dhcpd.leases"
81
DOMAIN_SUFFIX=`dnsdomainname`
85
if [ ! -z "${MAILHOSTNAME}" ]; then
86
OPTIONS="$OPTIONS -m $MAILHOSTNAME"
89
if [ ! -z "${RESOLV_CONF}" ]; then
90
OPTIONS="$OPTIONS -r $RESOLV_CONF"
93
if [ ! -z "${DHCP_LEASE}" ]; then
94
OPTIONS="$OPTIONS -l $DHCP_LEASE"
97
if [ ! -z "${DOMAIN_SUFFIX}" ]; then
98
OPTIONS="$OPTIONS -s $DOMAIN_SUFFIX"
103
echo -n "Starting dnsmasq"
104
## Start daemon with startproc(8). If this fails
105
## the echo return value is set appropriate.
107
# NOTE: startproc returns 0, even if service is
108
# already running to match LSB spec.
109
startproc $DNSMASQ $OPTIONS
111
# Remember status and be verbose
115
echo -n "Shutting down dnsmasq"
116
## Stop daemon with killproc(8) and if this fails
117
## set echo the echo return value.
119
killproc -TERM $DNSMASQ
121
# Remember status and be verbose
125
## Stop the service and if this succeeds (i.e. the
126
## service was running before), start it again.
127
## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
128
$0 status >/dev/null && $0 restart
130
# Remember status and be quiet
134
## Stop the service and regardless of whether it was
135
## running or not, start it again.
139
# Remember status and be quiet
143
## Signal the daemon to reload its config.
145
echo -n "Reload service dnsmasq"
146
killproc -HUP $DNSMASQ
147
#touch /var/run/dnsmasq.pid
151
## Like force-reload, but if daemon does not support
152
## signalling, do nothing (!)
154
echo -n "Reload service dnsmasq"
155
killproc -HUP $DNSMASQ
156
#touch /var/run/dnsmasq.pid
160
echo -n "Checking for dnsmasq: "
161
## Check status with checkproc(8), if process is running
162
## checkproc will return with exit status 0.
164
# Status has a slightly different for the status command:
165
# 0 - service running
166
# 1 - service dead, but /var/run/ pid file exists
167
# 2 - service dead, but /var/lock/ lock file exists
168
# 3 - service not running
170
# NOTE: checkproc returns LSB compliant status values.
175
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
181
###########################################################################
185
## The stuff from the RedHat startup script
186
## I keep it for the moment because I haven't checked
187
## the stuff with the lock/subsys/ file yet. JM
191
# See how we were called.
194
echo -n "Starting dnsmasq: "
195
daemon dnsmasq $OPTIONS
198
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/dnsmasq
201
if test "x`pidof dnsmasq`" != x; then
202
echo -n "Shutting down dnsmasq: "
207
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/dnsmasq /var/run/dnsmasq.pid
219
if test "x`/sbin/pidof dnsmasq`" != x; then
226
echo "Usage: $0 {start|stop|restart|reload|condrestart|status}"