1#!/bin/sh 2# 3# Startup script for the DNS caching server 4# 5# chkconfig: 2345 99 01 6# description: This script starts your DNS caching server 7# processname: dnsmasq 8# pidfile: /var/run/dnsmasq.pid 9 10# Source function library. 11. /etc/rc.d/init.d/functions 12 13# Source networking configuration. 14. /etc/sysconfig/network 15 16# Check that networking is up. 17[ ${NETWORKING} = "no" ] && exit 0 18 19dnsmasq=/usr/sbin/dnsmasq 20[ -f $dnsmasq ] || exit 0 21 22# change this line if you want dnsmasq to serve an MX record for 23# the host it is running on. 24MAILHOSTNAME="" 25# change this line if you want dns to get its upstream servers from 26# somewhere other that /etc/resolv.conf 27RESOLV_CONF="" 28# change this if you want dnsmasq to cache any "hostname" or "client-hostname" from 29# a dhcpd's lease file 30DHCP_LEASE="/var/lib/dhcp/dhcpd.leases" 31DOMAIN_SUFFIX=`dnsdomainname` 32 33OPTIONS="" 34 35if [ ! -z "${MAILHOSTNAME}" ]; then 36 OPTIONS="$OPTIONS -m $MAILHOSTNAME" 37fi 38 39if [ ! -z "${RESOLV_CONF}" ]; then 40 OPTIONS="$OPTIONS -r $RESOLV_CONF" 41fi 42 43if [ ! -z "${DHCP_LEASE}" ]; then 44 OPTIONS="$OPTIONS -l $DHCP_LEASE" 45fi 46 47if [ ! -z "${DOMAIN_SUFFIX}" ]; then 48 OPTIONS="$OPTIONS -s $DOMAIN_SUFFIX" 49fi 50 51RETVAL=0 52 53# See how we were called. 54case "$1" in 55 start) 56 echo -n "Starting dnsmasq: " 57 daemon $dnsmasq $OPTIONS 58 RETVAL=$? 59 echo 60 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dnsmasq 61 ;; 62 stop) 63 if test "x`pidof dnsmasq`" != x; then 64 echo -n "Shutting down dnsmasq: " 65 killproc dnsmasq 66 fi 67 RETVAL=$? 68 echo 69 [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/dnsmasq /var/run/dnsmasq.pid 70 ;; 71 status) 72 status dnsmasq 73 RETVAL=$? 74 ;; 75 restart|reload) 76 $0 stop 77 $0 start 78 RETVAL=$? 79 ;; 80 condrestart) 81 if test "x`/sbin/pidof dnsmasq`" != x; then 82 $0 stop 83 $0 start 84 RETVAL=$? 85 fi 86 ;; 87 *) 88 echo "Usage: $0 {start|stop|restart|reload|condrestart|status}" 89 exit 1 90esac 91 92exit $RETVAL 93 94