Changeset 39101


Ignore:
Timestamp:
2013-12-16T17:47:41+01:00 (4 years ago)
Author:
jow
Message:

dnsmasq: switch to /lib/functions/network.sh

This commit changes the dnsmasq init script to use the interface
status exposed by netifd. The old references to scan_interfaces()
and (indirect) accesses to uci state variables are removed and
replaced with corresponding network_*() calls.

Signed-off-by: Jo-Philipp Wich <jow@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/package/network/services/dnsmasq/files/dnsmasq.init

    r38648 r39101  
    339339        [ -n "$networkid" ] || networkid="$net" 
    340340 
    341         config_get ifname "$net" ifname 
    342         [ -n "$ifname" ] || return 0 
    343  
    344         config_get dnsserver "$net" dns 
    345         [ "$cachelocal" = "0" -a -n "$dnsserver" ] && { 
     341        network_get_subnet subnet "$net" || return 0 
     342        network_get_device ifname "$net" || return 0 
     343        network_get_protocol proto "$net" || return 0 
     344 
     345        [ "$cachelocal" = "0" ] && network_get_dnsserver dnsserver "$net" && { 
    346346                DNS_SERVERS="$DNS_SERVERS $dnsserver" 
    347347        } 
     
    349349        append_bool "$cfg" ignore "--no-dhcp-interface=$ifname" && return 0 
    350350 
    351         config_get proto "$net" proto 
     351        # Do not support non-static interfaces for now 
    352352        [ static = "$proto" ] || return 0 
    353353 
    354         config_get ipaddr "$net" ipaddr 
    355         config_get netmask "$cfg" netmask 
    356         [ -n "$netmask" ] || config_get netmask "$net" netmask 
     354        # Override interface netmask with dhcp config if applicable 
     355        config_get netmask "$cfg" netmask "${subnet##*/}" 
    357356 
    358357        #check for an already active dhcp server on the interface, unless 'force' is set 
     
    377376        limit="${limit:-150}" 
    378377        [ "$limit" -gt 0 ] && limit=$((limit-1)) 
    379         eval "$(ipcalc.sh $ipaddr $netmask $start $limit)" 
     378        eval "$(ipcalc.sh "${subnet%%/*}" $netmask $start $limit)" 
    380379        if [ "$dynamicdhcp" = "0" ]; then END="static"; fi 
    381380        xappend "--dhcp-range=$networkid,$START,$END,$NETMASK,$leasetime${options:+ $options}" 
     
    495494 
    496495start_service() { 
    497         include /lib/network 
    498         scan_interfaces 
    499  
    500         local lanaddr 
    501         config_get lanaddr "lan" ipaddr 
     496        include /lib/functions 
    502497 
    503498        config_load dhcp 
     
    533528 
    534529        # add own hostname 
    535         [ $ADD_LOCAL_HOSTNAME -eq 1 ] && [ -n "$lanaddr" ] && { 
     530        local lanaddr 
     531        [ $ADD_LOCAL_HOSTNAME -eq 1 ] && network_get_ipaddr lanaddr "lan" && { 
    536532                local hostname="$(uci_get system @system[0] hostname OpenWrt)" 
    537533                dhcp_hostrecord_add "" "${hostname%.$DOMAIN}${DOMAIN:+.$DOMAIN ${hostname%.$DOMAIN}}" "$lanaddr" 
Note: See TracChangeset for help on using the changeset viewer.