1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2007-2012 OpenWrt.org
12 BASECONFIGFILE="/var/etc/dnsmasq.conf"
13 BASEHOSTFILE="/tmp/hosts/dhcp"
14 BASETIMESTAMPFILE="/etc/dnsmasq.time"
15 TRUSTANCHORSFILE="/usr/share/dnsmasq/trust-anchors.conf"
16 TIMEVALIDFILE="/var/state/dnsmasqsec"
17 BASEDHCPSTAMPFILE="/var/run/dnsmasq"
22 echo "${value#--}" >> $CONFIGFILE_TMP
27 local hex="${2#0x}" # strip optional "0x" prefix
29 if [ -n "${hex//[0-9a-fA-F]/}" ]; then
30 # is invalid hex literal
34 # convert into host id
37 $(((0x$hex >> 16) % 65536)) \
48 while [ -n "$ip" ]; do
51 res="$(($res + $part))"
52 [ "${ip%.*}" != "$ip" ] && ip="${ip#*.}" || ip=
59 local stamp="${BASEDHCPSTAMPFILE_CFG}.${ifname}.dhcp"
62 [ -s "$stamp" ] && return $(cat "$stamp")
64 # If there's no carrier yet, skip this interface.
65 # The init script will be called again once the link is up
66 case "$(devstatus "$ifname" | jsonfilter -e @.carrier)" in
70 udhcpc -n -q -s /bin/true -t 1 -i "$ifname" >&- && rv=1 || rv=0
74 "found already running DHCP-server on interface '$ifname'" \
75 "refusing to start, use 'option force 1' to override"
82 pidof dnsmasq >/dev/null || \
83 logger -t dnsmasq "$@"
91 config_get_bool _loctmp "$section" "$option" 0
92 [ $_loctmp -gt 0 ] && xappend "$value"
101 config_get _loctmp "$section" "$option" "$default"
102 [ -z "$_loctmp" ] && return 0
103 xappend "$switch=$_loctmp"
107 xappend "--server=$1"
111 xappend "--address=$1"
119 network_get_device ifname "$1" || return
120 xappend "--interface=$ifname"
123 append_notinterface() {
124 network_get_device ifname "$1" || return
125 xappend "--except-interface=$ifname"
129 xappend "--addn-hosts=$1"
132 append_bogusnxdomain() {
133 xappend "--bogus-nxdomain=$1"
136 append_pxe_service() {
137 xappend "--pxe-service=$1"
141 local cfg="$1" func="$2" match_cfg="$3" found_cfg
143 # use entry when no instance entry set, or if it matches
144 config_get found_cfg "$cfg" "instance"
145 if [ -z "$found_cfg" -o "$found_cfg" = "$match_cfg" ]; then
150 dhcp_subscrid_add() {
153 config_get networkid "$cfg" networkid
154 [ -n "$networkid" ] || return 0
156 config_get subscriberid "$cfg" subscriberid
157 [ -n "$subscriberid" ] || return 0
159 xappend "--dhcp-subscrid=$networkid,$subscriberid"
161 config_get_bool force "$cfg" force 0
163 dhcp_option_add "$cfg" "$networkid" "$force"
166 dhcp_remoteid_add() {
169 config_get networkid "$cfg" networkid
170 [ -n "$networkid" ] || return 0
172 config_get remoteid "$cfg" remoteid
173 [ -n "$remoteid" ] || return 0
175 xappend "--dhcp-remoteid=$networkid,$remoteid"
177 config_get_bool force "$cfg" force 0
179 dhcp_option_add "$cfg" "$networkid" "$force"
182 dhcp_circuitid_add() {
185 config_get networkid "$cfg" networkid
186 [ -n "$networkid" ] || return 0
188 config_get circuitid "$cfg" circuitid
189 [ -n "$circuitid" ] || return 0
191 xappend "--dhcp-circuitid=$networkid,$circuitid"
193 config_get_bool force "$cfg" force 0
195 dhcp_option_add "$cfg" "$networkid" "$force"
198 dhcp_userclass_add() {
201 config_get networkid "$cfg" networkid
202 [ -n "$networkid" ] || return 0
204 config_get userclass "$cfg" userclass
205 [ -n "$userclass" ] || return 0
207 xappend "--dhcp-userclass=$networkid,$userclass"
209 config_get_bool force "$cfg" force 0
211 dhcp_option_add "$cfg" "$networkid" "$force"
214 dhcp_vendorclass_add() {
217 config_get networkid "$cfg" networkid
218 [ -n "$networkid" ] || return 0
220 config_get vendorclass "$cfg" vendorclass
221 [ -n "$vendorclass" ] || return 0
223 xappend "--dhcp-vendorclass=$networkid,$vendorclass"
225 config_get_bool force "$cfg" force 0
227 dhcp_option_add "$cfg" "$networkid" "$force"
233 config_get networkid "$cfg" networkid
234 [ -n "$networkid" ] || return 0
236 config_get match "$cfg" match
237 [ -n "$match" ] || return 0
239 xappend "--dhcp-match=$networkid,$match"
241 config_get_bool force "$cfg" force 0
243 dhcp_option_add "$cfg" "$networkid" "$force"
249 config_get_bool force "$cfg" force 0
251 config_get networkid "$cfg" networkid
252 [ -n "$networkid" ] && dhcp_option_add "$cfg" "$networkid" "$force"
254 config_get_bool enable "$cfg" enable 1
255 [ "$enable" = "0" ] && return 0
257 config_get name "$cfg" name
258 config_get ip "$cfg" ip
259 [ -n "$ip" -o -n "$name" ] || return 0
261 config_get_bool dns "$cfg" dns 0
262 [ "$dns" = "1" -a -n "$ip" -a -n "$name" ] && {
263 echo "$ip $name${DOMAIN:+.$DOMAIN}" >> $HOSTFILE
266 config_get mac "$cfg" mac
267 if [ -n "$mac" ]; then
268 # --dhcp-host=00:20:e0:3b:13:af,192.168.0.199,lap
270 for m in $mac; do append macs "$m" ","; done
272 # --dhcp-host=lap,192.168.0.199
273 [ -n "$name" ] || return 0
278 config_get tag "$cfg" tag
280 if [ "$DHCPv6CAPABLE" -eq 1 ]; then
281 config_get duid "$cfg" duid
282 config_get hostid "$cfg" hostid
283 if [ -n "$hostid" ]; then
284 hex_to_hostid hostid "$hostid"
288 config_get_bool broadcast "$cfg" broadcast 0
289 [ "$broadcast" = "0" ] && broadcast=
291 config_get leasetime "$cfg" leasetime
293 xappend "--dhcp-host=$macs${duid:+,id:$duid}${networkid:+,net:$networkid}${broadcast:+,set:needs-broadcast}${tag:+,set:$tag}${ip:+,$ip${hostid:+,[::$hostid]}}${name:+,$name}${leasetime:+,$leasetime}"
301 [ -n "$tag" ] || return 0
303 config_get_bool force "$cfg" force 0
304 [ "$force" = "0" ] && force=
306 config_get option "$cfg" dhcp_option
308 xappend "--dhcp-option${force:+-force}=tag:$tag,$o"
315 config_get networkid "$cfg" networkid
316 [ -n "$networkid" ] || return 0
318 config_get mac "$cfg" mac
319 [ -n "$mac" ] || return 0
321 xappend "--dhcp-mac=$networkid,$mac"
323 dhcp_option_add "$cfg" "$networkid"
329 config_get networkid "$cfg" networkid
331 config_get filename "$cfg" filename
332 [ -n "$filename" ] || return 0
334 config_get servername "$cfg" servername
335 config_get serveraddress "$cfg" serveraddress
337 [ -n "$serveraddress" -a ! -n "$servername" ] && return 0
339 xappend "--dhcp-boot=${networkid:+net:$networkid,}${filename}${servername:+,$servername}${serveraddress:+,$serveraddress}"
341 config_get_bool force "$cfg" force 0
343 dhcp_option_add "$cfg" "$networkid" "$force"
349 config_get net "$cfg" interface
350 [ -n "$net" ] || return 0
352 config_get dhcpv4 "$cfg" dhcpv4
353 [ "$dhcpv4" != "disabled" ] || return 0
355 config_get networkid "$cfg" networkid
356 [ -n "$networkid" ] || networkid="$net"
358 network_get_subnet subnet "$net" || return 0
359 network_get_device ifname "$net" || return 0
360 network_get_protocol proto "$net" || return 0
362 [ "$cachelocal" = "0" ] && network_get_dnsserver dnsserver "$net" && {
363 DNS_SERVERS="$DNS_SERVERS $dnsserver"
366 append_bool "$cfg" ignore "--no-dhcp-interface=$ifname" && return 0
368 # Do not support non-static interfaces for now
369 [ static = "$proto" ] || return 0
371 # Override interface netmask with dhcp config if applicable
372 config_get netmask "$cfg" netmask "${subnet##*/}"
374 #check for an already active dhcp server on the interface, unless 'force' is set
375 config_get_bool force "$cfg" force 0
376 [ $force -gt 0 ] || dhcp_check "$ifname" || return 0
378 config_get start "$cfg" start
379 config_get limit "$cfg" limit
380 config_get leasetime "$cfg" leasetime
381 config_get options "$cfg" options
382 config_get_bool dynamicdhcp "$cfg" dynamicdhcp 1
384 leasetime="${leasetime:-12h}"
385 start="$(dhcp_calc "${start:-100}")"
386 limit="${limit:-150}"
387 [ "$limit" -gt 0 ] && limit=$((limit-1))
388 eval "$(ipcalc.sh "${subnet%%/*}" $netmask $start $limit)"
389 if [ "$dynamicdhcp" = "0" ]; then END="static"; fi
390 xappend "--dhcp-range=$networkid,$START,$END,$NETMASK,$leasetime${options:+ $options}"
392 dhcp_option_add "$cfg" "$networkid"
400 [ "$force" = "0" ] && force=
402 config_get dhcp_option "$cfg" dhcp_option
403 for o in $dhcp_option; do
404 xappend "--dhcp-option${force:+-force}=${networkid:+$networkid,}$o"
411 local ip name names record
413 config_get names "$cfg" name "$2"
414 [ -n "$names" ] || return 0
416 config_get ip "$cfg" ip "$3"
417 [ -n "$ip" ] || return 0
419 for name in $names; do
420 record="${record:+$record }$name"
423 echo "$ip $record" >> $HOSTFILE
429 config_get srv "$cfg" srv
430 [ -n "$srv" ] || return 0
432 config_get target "$cfg" target
433 [ -n "$target" ] || return 0
435 config_get port "$cfg" port
436 [ -n "$port" ] || return 0
438 config_get class "$cfg" class
439 config_get weight "$cfg" weight
441 local service="$srv,$target,$port${class:+,$class${weight:+,$weight}}"
443 xappend "--srv-host=$service"
448 local domain relay pref
450 config_get domain "$cfg" domain
451 [ -n "$domain" ] || return 0
453 config_get relay "$cfg" relay
454 [ -n "$relay" ] || return 0
456 config_get pref "$cfg" pref 0
458 local service="$domain,$relay,$pref"
460 xappend "--mx-host=$service"
467 config_get cname "$cfg" cname
468 [ -n "$cname" ] || return 0
470 config_get target "$cfg" target
471 [ -n "$target" ] || return 0
473 xappend "--cname=${cname},${target}"
476 dhcp_hostrecord_add() {
478 local names addresses record val
480 config_get names "$cfg" name "$2"
481 if [ -z "$names" ]; then
485 config_get addresses "$cfg" ip "$3"
486 if [ -z "$addresses" ]; then
490 for val in $names $addresses; do
491 record="${record:+$record,}$val"
494 xappend "--host-record=$record"
499 local local_addr server_addr interface
501 config_get local_addr "$cfg" local_addr
502 [ -n "$local_addr" ] || return 0
504 config_get server_addr "$cfg" server_addr
505 [ -n "$server_addr" ] || return 0
507 config_get interface "$cfg" interface
508 if [ -z "$interface" ]; then
509 xappend "--dhcp-relay=$local_addr,$server_addr"
511 xappend "--dhcp-relay=$local_addr,$server_addr,$interface"
517 local cfg="$1" disabled
519 config_get_bool disabled "$cfg" disabled 0
520 [ "$disabled" -gt 0 ] && return 0
522 # reset list of DOMAINS and DNS servers (for each dnsmasq instance)
525 CONFIGFILE="${BASECONFIGFILE}.${cfg}"
526 CONFIGFILE_TMP="${CONFIGFILE}.$$"
527 HOSTFILE="${BASEHOSTFILE}.${cfg}"
528 TIMESTAMPFILE="${BASETIMESTAMPFILE}.${cfg}"
529 BASEDHCPSTAMPFILE_CFG="${BASEDHCPSTAMPFILE}.${cfg}"
531 # before we can call xappend
532 mkdir -p /var/run/dnsmasq/
533 mkdir -p $(dirname $CONFIGFILE)
534 mkdir -p $(dirname $HOSTFILE)
535 mkdir -p /var/lib/misc
536 chown dnsmasq:dnsmasq /var/run/dnsmasq
538 [ -f "$TIMESTAMPFILE" ] && rm -f "$TIMESTAMPFILE"
540 echo "# auto-generated config file from /etc/config/dhcp" > $CONFIGFILE_TMP
541 echo "# auto-generated config file from /etc/config/dhcp" > $HOSTFILE
543 # if we did this last, we could override auto-generated config
544 [ -f /etc/dnsmasq.conf ] && {
545 xappend "--conf-file=/etc/dnsmasq.conf"
548 $PROG --version | grep -osqE "^Compile time options:.* DHCPv6( |$)" && DHCPv6CAPABLE=1 || DHCPv6CAPABLE=0
550 append_bool "$cfg" authoritative "--dhcp-authoritative"
551 append_bool "$cfg" nodaemon "--no-daemon"
552 append_bool "$cfg" domainneeded "--domain-needed"
553 append_bool "$cfg" filterwin2k "--filterwin2k"
554 append_bool "$cfg" nohosts "--no-hosts"
555 append_bool "$cfg" nonegcache "--no-negcache"
556 append_bool "$cfg" strictorder "--strict-order"
557 append_bool "$cfg" logqueries "--log-queries=extra"
558 append_bool "$cfg" noresolv "--no-resolv"
559 append_bool "$cfg" localise_queries "--localise-queries"
560 append_bool "$cfg" readethers "--read-ethers"
561 append_bool "$cfg" dbus "--enable-dbus"
562 append_bool "$cfg" boguspriv "--bogus-priv"
563 append_bool "$cfg" expandhosts "--expand-hosts"
564 config_get tftp_root "$cfg" "tftp_root"
565 [ -d "$tftp_root" ] && append_bool "$cfg" enable_tftp "--enable-tftp"
566 append_bool "$cfg" tftp_no_fail "--tftp-no-fail"
567 append_bool "$cfg" nonwildcard "--bind-dynamic"
568 append_bool "$cfg" fqdn "--dhcp-fqdn"
569 append_bool "$cfg" proxydnssec "--proxy-dnssec"
570 append_bool "$cfg" localservice "--local-service"
571 append_bool "$cfg" logdhcp "--log-dhcp"
572 append_bool "$cfg" quietdhcp "--quiet-dhcp"
573 append_bool "$cfg" sequential_ip "--dhcp-sequential-ip"
574 append_bool "$cfg" allservers "--all-servers"
575 append_bool "$cfg" noping "--no-ping"
577 append_parm "$cfg" logfacility "--log-facility"
578 append_parm "$cfg" dhcpscript "--dhcp-script"
579 append_parm "$cfg" cachesize "--cache-size"
580 append_parm "$cfg" dnsforwardmax "--dns-forward-max"
581 append_parm "$cfg" port "--port"
582 append_parm "$cfg" ednspacket_max "--edns-packet-max"
583 append_parm "$cfg" dhcpleasemax "--dhcp-lease-max"
584 append_parm "$cfg" "queryport" "--query-port"
585 append_parm "$cfg" "minport" "--min-port"
586 append_parm "$cfg" "maxport" "--max-port"
587 append_parm "$cfg" "domain" "--domain"
588 append_parm "$cfg" "local" "--server"
589 config_list_foreach "$cfg" "server" append_server
590 config_list_foreach "$cfg" "address" append_address
591 config_list_foreach "$cfg" "ipset" append_ipset
592 config_list_foreach "$cfg" "interface" append_interface
593 config_list_foreach "$cfg" "notinterface" append_notinterface
594 config_list_foreach "$cfg" "addnhosts" append_addnhosts
595 config_list_foreach "$cfg" "bogusnxdomain" append_bogusnxdomain
596 append_parm "$cfg" "leasefile" "--dhcp-leasefile" "/tmp/dhcp.leases"
597 append_parm "$cfg" "resolvfile" "--resolv-file" "/tmp/resolv.conf.auto"
598 append_parm "$cfg" "serversfile" "--servers-file"
599 append_parm "$cfg" "tftp_root" "--tftp-root"
600 append_parm "$cfg" "dhcp_boot" "--dhcp-boot"
601 append_parm "$cfg" "local_ttl" "--local-ttl"
602 append_parm "$cfg" "pxe_prompt" "--pxe-prompt"
603 config_list_foreach "$cfg" "pxe_service" append_pxe_service
604 config_get DOMAIN "$cfg" domain
606 config_get_bool ADD_LOCAL_DOMAIN "$cfg" add_local_domain 1
607 config_get_bool ADD_LOCAL_HOSTNAME "$cfg" add_local_hostname 1
609 config_get_bool readethers "$cfg" readethers
610 [ "$readethers" = "1" -a \! -e "/etc/ethers" ] && touch /etc/ethers
612 config_get resolvfile $cfg resolvfile
613 config_get dhcpscript $cfg dhcpscript
615 config_get leasefile $cfg leasefile "/tmp/dhcp.leases"
616 [ -n "$leasefile" -a \! -e "$leasefile" ] && touch "$leasefile"
617 config_get_bool cachelocal "$cfg" cachelocal 1
619 config_get_bool noresolv "$cfg" noresolv 0
620 if [ "$noresolv" != "1" ]; then
621 config_get resolvfile "$cfg" resolvfile "/tmp/resolv.conf.auto"
622 # So jail doesn't complain if file missing
623 [ -n "$resolvfile" -a \! -e "$resolvfile" ] && touch "$resolvfile"
626 config_get hostsfile "$cfg" dhcphostsfile
627 [ -e "$hostsfile" ] && xappend "--dhcp-hostsfile=$hostsfile"
630 config_get_bool rebind "$cfg" rebind_protection 1
631 [ $rebind -gt 0 ] && {
633 "DNS rebinding protection is active," \
634 "will discard upstream RFC1918 responses!"
635 xappend "--stop-dns-rebind"
637 local rebind_localhost
638 config_get_bool rebind_localhost "$cfg" rebind_localhost 0
639 [ $rebind_localhost -gt 0 ] && {
640 log_once "Allowing 127.0.0.0/8 responses"
641 xappend "--rebind-localhost-ok"
644 append_rebind_domain() {
645 log_once "Allowing RFC1918 responses for domain $1"
646 xappend "--rebind-domain-ok=$1"
649 config_list_foreach "$cfg" rebind_domain append_rebind_domain
652 config_get_bool dnssec "$cfg" dnssec 0
653 [ "$dnssec" -gt 0 ] && {
654 xappend "--conf-file=$TRUSTANCHORSFILE"
656 [ -x /etc/init.d/sysntpd ] && {
657 /etc/init.d/sysntpd enabled
658 [ "$?" -ne 0 -o "$(uci_get system.ntp.enabled)" = "1" ] && {
659 [ -f "$TIMEVALIDFILE" ] || xappend "--dnssec-no-timecheck"
662 append_bool "$cfg" dnsseccheckunsigned "--dnssec-check-unsigned"
665 config_get addmac "$cfg" addmac 0
666 [ "$addmac" != "0" ] && {
667 [ "$addmac" = "1" ] && addmac=
668 xappend "--add-mac${addmac:+="$addmac"}"
671 dhcp_option_add "$cfg" "" 0
673 xappend "--dhcp-broadcast=tag:needs-broadcast"
675 xappend "--addn-hosts=$(dirname $HOSTFILE)"
677 config_get dnsmasqconfdir "$cfg" confdir "/tmp/dnsmasq.d"
678 [ ! -d "$dnsmasqconfdir" ] && mkdir -p $dnsmasqconfdir
679 xappend "--conf-dir=$dnsmasqconfdir"
680 xappend "--user=dnsmasq"
681 xappend "--group=dnsmasq"
682 echo >> $CONFIGFILE_TMP
684 config_get_bool enable_tftp "$cfg" enable_tftp 0
685 [ "$enable_tftp" -gt 0 ] && {
686 config_get tftp_root "$cfg" tftp_root
687 append EXTRA_MOUNT $tftp_root
690 config_foreach filter_dnsmasq host dhcp_host_add "$cfg"
691 echo >> $CONFIGFILE_TMP
692 config_foreach filter_dnsmasq boot dhcp_boot_add "$cfg"
693 config_foreach filter_dnsmasq mac dhcp_mac_add "$cfg"
694 config_foreach filter_dnsmasq tag dhcp_tag_add "$cfg"
695 config_foreach filter_dnsmasq vendorclass dhcp_vendorclass_add "$cfg"
696 config_foreach filter_dnsmasq userclass dhcp_userclass_add "$cfg"
697 config_foreach filter_dnsmasq circuitid dhcp_circuitid_add "$cfg"
698 config_foreach filter_dnsmasq remoteid dhcp_remoteid_add "$cfg"
699 config_foreach filter_dnsmasq subscrid dhcp_subscrid_add "$cfg"
700 config_foreach filter_dnsmasq match dhcp_match_add "$cfg"
701 config_foreach filter_dnsmasq domain dhcp_domain_add "$cfg"
702 config_foreach filter_dnsmasq hostrecord dhcp_hostrecord_add "$cfg"
703 config_foreach filter_dnsmasq relay dhcp_relay_add "$cfg"
706 [ $ADD_LOCAL_HOSTNAME -eq 1 ] && {
707 local lanaddr lanaddr6
708 local ulaprefix="$(uci_get network @globals[0] ula_prefix)"
709 local hostname="$(uci_get system @system[0] hostname Lede)"
711 network_get_ipaddr lanaddr "lan" && {
712 dhcp_domain_add "" "$hostname" "$lanaddr"
715 [ -n "$ulaprefix" ] && network_get_ipaddrs6 lanaddr6 "lan" && {
716 for lanaddr6 in $lanaddr6; do
718 "${ulaprefix%%:/*}"*)
719 dhcp_domain_add "" "$hostname" "$lanaddr6"
726 echo >> $CONFIGFILE_TMP
727 config_foreach filter_dnsmasq srvhost dhcp_srv_add "$cfg"
728 config_foreach filter_dnsmasq mxhost dhcp_mx_add "$cfg"
729 echo >> $CONFIGFILE_TMP
731 config_get odhcpd_is_active odhcpd maindhcp
732 if [ "$odhcpd_is_active" != "1" ]; then
733 config_foreach filter_dnsmasq dhcp dhcp_add "$cfg"
736 echo >> $CONFIGFILE_TMP
737 config_foreach filter_dnsmasq cname dhcp_cname_add "$cfg"
738 echo >> $CONFIGFILE_TMP
740 echo >> $CONFIGFILE_TMP
741 mv -f $CONFIGFILE_TMP $CONFIGFILE
743 [ "$resolvfile" = "/tmp/resolv.conf.auto" ] && {
744 rm -f /tmp/resolv.conf
745 [ $ADD_LOCAL_DOMAIN -eq 1 ] && [ -n "$DOMAIN" ] && {
746 echo "search $DOMAIN" >> /tmp/resolv.conf
748 DNS_SERVERS="$DNS_SERVERS 127.0.0.1"
749 for DNS_SERVER in $DNS_SERVERS ; do
750 echo "nameserver $DNS_SERVER" >> /tmp/resolv.conf
754 procd_open_instance $cfg
755 procd_set_param command $PROG -C $CONFIGFILE -k -x /var/run/dnsmasq/dnsmasq."${cfg}".pid
756 procd_set_param file $CONFIGFILE
757 procd_set_param respawn
759 local dnsmasqconffile="/etc/dnsmasq.${cfg}.conf"
760 if [ ! -r "$dnsmasqconffile" ]; then
761 dnsmasqconffile=/etc/dnsmasq.conf
764 procd_add_jail dnsmasq ubus log
765 procd_add_jail_mount $CONFIGFILE $TRUSTANCHORSFILE $HOSTFILE /etc/passwd /etc/group /etc/TZ /dev/null /dev/urandom $dnsmasqconffile $dnsmasqconfdir $resolvfile $dhcpscript /etc/hosts /etc/ethers $EXTRA_MOUNT
766 procd_add_jail_mount_rw /var/run/dnsmasq/ $leasefile
775 config_get resolvfile "$cfg" "resolvfile"
777 #relink /tmp/resolve.conf only for main instance
778 [ "$resolvfile" = "/tmp/resolv.conf.auto" ] && {
779 [ -f /tmp/resolv.conf ] && {
780 rm -f /tmp/resolv.conf
781 ln -s "$resolvfile" /tmp/resolv.conf
785 rm -f ${BASEDHCPSTAMPFILE}.${cfg}.*.dhcp
790 procd_add_reload_trigger "dhcp"
791 procd_add_raw_trigger "interface.*" 2000 /etc/init.d/dnsmasq reload
802 local instance_found=0
804 [ -n "$BOOT" ] && return
806 . /lib/functions/network.sh
811 if [ "$type" = "dnsmasq" ]; then
812 if [ -n "$instance" -a "$instance" = "$name" ]; then
820 if [ -n "$instance" ]; then
821 [ "$instance_found" -gt 0 ] || return
822 dnsmasq_start "$instance"
824 config_foreach dnsmasq_start dnsmasq
829 rc_procd start_service "$@"
835 local instance_found=0
840 if [ "$type" = "dnsmasq" ]; then
841 if [ -n "$instance" -a "$instance" = "$name" ]; then
849 if [ -n "$instance" ]; then
850 [ "$instance_found" -gt 0 ] || return
851 dnsmasq_stop "$instance"
853 config_foreach dnsmasq_stop dnsmasq