#!/bin/sh DAEMON=dnsmasq PID_FILE=/var/run/$DAEMON/$DAEMON.pid . /etc/init.d/modlibrc DAEMON_USER=nobody DAEMON_GROUP=nobody [ "$(/etc/init.d/rc.multid status)" != "running" -o "$DNSMASQ_MULTID_RESTART" != "yes" ] && nomultid=y config() { modlib_config } start() { [ "$nomultid" != "y" ] && /etc/init.d/rc.multid stop >/dev/null local OPTIONS="--pid-file=$PID_FILE $DNSMASQ_OPTIONS" [ "$DNSMASQ_DNS_PORT" ] && OPTIONS="$OPTIONS -p $DNSMASQ_DNS_PORT" modlib_startdaemon $DAEMON $OPTIONS [ "$nomultid" != "y" ] && /etc/init.d/rc.multid start >/dev/null if [ ! -L "/var/flash/multid.leases" -a "$DNSMASQ_DHCP" = "yes" ]; then rm -f /var/flash/multid.leases touch /var/tmp/multid.leases ln -s /var/tmp/multid.leases /var/flash/multid.leases fi # this could pose problems when a client comes too fast local lease for lease in /var/tmp/multid.leases /var/tmp/dnsmasq.leases; do if [ -f $lease ]; then chmod 0664 $lease chown root:nobody $lease fi done } stop() { [ "$nomultid" != "y" ] && /etc/init.d/rc.multid stop >/dev/null kill $(cat $PID_FILE) 2> /dev/null [ "$nomultid" != "y" ] && /etc/init.d/rc.multid start >/dev/null if [ -L "/var/flash/multid.leases" ]; then major=$(grep tffs /proc/devices) rm -f /var/flash/multid.leases mknod /var/flash/multid.leases c ${major%%tffs} $((0x70)) fi } case $1 in ""|load|multid) if [ "$1" == "multid" ]; then [ "$DNSMASQ_WRAPPER" != "yes" ] && exit else [ "$DNSMASQ_WRAPPER" == "yes" ] && exit fi mkdir -p "/tmp/flash/${DAEMON}" [ -r "/tmp/flash/${DAEMON}.extra" ] && mv "/tmp/flash/${DAEMON}.extra" "/tmp/flash/${DAEMON}/${DAEMON}.extra" modreg cgi 'dnsmasq' 'Dnsmasq' modreg daemon $DAEMON modreg file dnsmasq extra 'extra' 0 dnsmasq_extra modlib_addgroup $DAEMON_GROUP modlib_adduser $DAEMON_USER -s /bin/false -D -S -H -G $DAEMON_GROUP -g $DAEMON_GROUP mkdir -p ${PID_FILE%/*} chown $DAEMON_USER:$DAEMON_GROUP ${PID_FILE%/*} modlib_start $DNSMASQ_ENABLED ;; unload) modunreg file dnsmasq modunreg daemon $DAEMON modunreg cgi dnsmasq modlib_stop ;; start) modlib_start ;; stop) modlib_stop ;; restart) modlib_check_running && nomultid=y modlib_restart ;; status) modlib_status ;; *) echo "Usage: $0 [load|unload|start|stop|restart|status]" 1>&2 exit 1 ;; esac exit 0