dnsmasq: clean up white space in dnsmasq.init
[openwrt/openwrt.git] / package / network / services / dnsmasq / files / dnsmasq.init
index 76128301037cd8c4b1387fce532cacabf4d0f1a1..46607dfe2520dcc3661bbd808753c27b2249c4ed 100644 (file)
@@ -23,22 +23,22 @@ xappend() {
 }
 
 hex_to_hostid() {
-        local var="$1"
-        local hex="${2#0x}"     # strip optional "0x" prefix
+       local var="$1"
+       local hex="${2#0x}" # strip optional "0x" prefix
 
-        if [ -n "${hex//[0-9a-fA-F]/}" ]; then
-                # is invalid hex literal
-                return 1
-        fi
+       if [ -n "${hex//[0-9a-fA-F]/}" ]; then
+               # is invalid hex literal
+               return 1
+       fi
 
-        # convert into host id
-        export "$var=$(
-                printf "%0x:%0x"  \
-                        $(((0x$hex >> 16) % 65536)) \
-                        $(( 0x$hex        % 256))
-        )"
+       # convert into host id
+       export "$var=$(
+               printf "%0x:%0x" \
+               $(((0x$hex >> 16) % 65536)) \
+               $(( 0x$hex        % 65536))
+               )"
 
-        return 0
+       return 0
 }
 
 dhcp_calc() {
@@ -278,6 +278,7 @@ dhcp_host_add() {
        config_get tag "$cfg" tag
 
        if [ "$DHCPv6CAPABLE" -eq 1 ]; then
+               config_get duid "$cfg" duid
                config_get hostid "$cfg" hostid
                if [ -n "$hostid" ]; then
                        hex_to_hostid hostid "$hostid"
@@ -289,7 +290,7 @@ dhcp_host_add() {
 
        config_get leasetime "$cfg" leasetime
 
-       xappend "--dhcp-host=$macs${networkid:+,net:$networkid}${broadcast:+,set:needs-broadcast}${tag:+,set:$tag}${ip:+,$ip${hostid:+,[::$hostid]}}${name:+,$name}${leasetime:+,$leasetime}"
+       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}"
 }
 
 dhcp_tag_add() {
@@ -573,6 +574,7 @@ dnsmasq_start()
        append_bool "$cfg" allservers "--all-servers"
        append_bool "$cfg" noping "--no-ping"
 
+       append_parm "$cfg" logfacility "--log-facility"
        append_parm "$cfg" dhcpscript "--dhcp-script"
        append_parm "$cfg" cachesize "--cache-size"
        append_parm "$cfg" dnsforwardmax "--dns-forward-max"
@@ -660,11 +662,17 @@ dnsmasq_start()
                append_bool "$cfg" dnsseccheckunsigned "--dnssec-check-unsigned"
        }
 
+       config_get addmac "$cfg" addmac 0
+       [ "$addmac" != "0" ] && {
+               [ "$addmac" = "1" ] && addmac=
+               xappend "--add-mac${addmac:+="$addmac"}"
+       }
+
        dhcp_option_add "$cfg" "" 0
 
        xappend "--dhcp-broadcast=tag:needs-broadcast"
 
-       xappend "--addn-hosts=$HOSTFILE"
+       xappend "--addn-hosts=$(dirname $HOSTFILE)"
 
        config_get dnsmasqconfdir "$cfg" confdir "/tmp/dnsmasq.d"
        [ ! -d "$dnsmasqconfdir" ] && mkdir -p $dnsmasqconfdir