From cf123d2a166d297712ab7b7221af999a62643f98 Mon Sep 17 00:00:00 2001 From: nbd Date: Wed, 4 Oct 2006 20:05:48 +0000 Subject: add new rc.common for standardized init scripts, convert existing init scripts git-svn-id: svn://svn.openwrt.org/openwrt/branches/buildroot-ng/openwrt@4915 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/dnsmasq/files/dnsmasq.init | 107 ++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 50 deletions(-) (limited to 'package/dnsmasq/files/dnsmasq.init') diff --git a/package/dnsmasq/files/dnsmasq.init b/package/dnsmasq/files/dnsmasq.init index cbbee02ce..8ac0ab638 100644 --- a/package/dnsmasq/files/dnsmasq.init +++ b/package/dnsmasq/files/dnsmasq.init @@ -1,50 +1,57 @@ -#!/bin/sh -. /etc/functions.sh -include /lib/network -scan_interfaces - -# The following is to automatically configure the DHCP settings -# based on config settings. Feel free to replace all this crap -# with a simple "dnsmasq" and manage everything via the -# /etc/dnsmasq.conf config file - -[ -f /etc/dnsmasq.conf ] || exit - -args="" -iface=lan -config_get ifname "$iface" ifname -config_get proto "$iface" proto - -[ "$proto" = static ] && dhcp_enable="${dhcp_enable:-1}" -dhcp_start="${dhcp_start:-100}" -dhcp_num="${dhcp_num:-50}" -dhcp_lease="${dhcp_lease:-12h}" - -# if dhcp_enable is unset and there is a dhcp server on the network already, default to dhcp_enable=0 -[ -z "$dhcp_enable" ] && udhcpc -n -q -R -s /bin/true -i $ifname >&- && dhcp_enable="${dhcp_enable:-0}" - -# dhcp_enable=0 disables the dhcp server -( - [ -z "$dhcp_enable" -o "$dhcp_enable" -eq 1 ] && { - # no existing DHCP server? - - # calculate settings - config_get ipaddr "$iface" ipaddr - config_get netmask "$iface" netmask - eval $(ipcalc $ipaddr $netmask ${dhcp_start:-100} ${dhcp_num:-150}) - - # and pass the args via config parser defines - echo "${dhcp_enable:+@define dhcp_enable 1}" - echo "@define netmask $NETMASK" - echo "@define start $START" - echo "@define end $END" - echo "@define lease ${dhcp_lease:-12h}" - } - - # ignore requests from wan interface - config_get wan_proto wan proto - config_get wan_ifname wan ifname - [ -z "$wan_proto" -o "$wan_proto" = "none" ] || echo "@define wan_ifname $wan_ifname" - - cat /etc/dnsmasq.conf -) | awk -f /usr/lib/parse-config.awk | dnsmasq -C /proc/self/fd/0 +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +start() { + include /lib/network + scan_interfaces + + # The following is to automatically configure the DHCP settings + # based on config settings. Feel free to replace all this crap + # with a simple "dnsmasq" and manage everything via the + # /etc/dnsmasq.conf config file + + [ -f /etc/dnsmasq.conf ] || exit + + args="" + iface=lan + config_get ifname "$iface" ifname + config_get proto "$iface" proto + + [ "$proto" = static ] && dhcp_enable="${dhcp_enable:-1}" + dhcp_start="${dhcp_start:-100}" + dhcp_num="${dhcp_num:-50}" + dhcp_lease="${dhcp_lease:-12h}" + + # if dhcp_enable is unset and there is a dhcp server on the network already, default to dhcp_enable=0 + [ -z "$dhcp_enable" ] && udhcpc -n -q -R -s /bin/true -i $ifname >&- && dhcp_enable="${dhcp_enable:-0}" + + # dhcp_enable=0 disables the dhcp server + ( + [ -z "$dhcp_enable" -o "$dhcp_enable" -eq 1 ] && { + # no existing DHCP server? + + # calculate settings + config_get ipaddr "$iface" ipaddr + config_get netmask "$iface" netmask + eval $(ipcalc $ipaddr $netmask ${dhcp_start:-100} ${dhcp_num:-150}) + + # and pass the args via config parser defines + echo "${dhcp_enable:+@define dhcp_enable 1}" + echo "@define netmask $NETMASK" + echo "@define start $START" + echo "@define end $END" + echo "@define lease ${dhcp_lease:-12h}" + } + + # ignore requests from wan interface + config_get wan_proto wan proto + config_get wan_ifname wan ifname + [ -z "$wan_proto" -o "$wan_proto" = "none" ] || echo "@define wan_ifname $wan_ifname" + + cat /etc/dnsmasq.conf + ) | awk -f /usr/lib/parse-config.awk | dnsmasq -C /proc/self/fd/0 +} + +stop() { + killall dnsmasq +} -- cgit v1.2.3