Ignore:
Timestamp:
2011-09-30T19:31:33+02:00 (5 years ago)
Author:
kerneis
Message:

[packages] ahcpd: add ahcp proto, use service_kill

File:
1 edited

Legend:

Unmodified
Added
Removed
  • packages/ipv6/ahcpd/files/ahcp.sh

    r27932 r28337  
    1 append_bool() { 
    2         local section="$1" 
    3         local option="$2" 
    4         local value="$3" 
    5         local _loctmp 
    6         config_get_bool _loctmp "$section" "$option" 0 
    7         [ "$_loctmp" -gt 0 ] && append args "$value" 
    8 } 
    9  
    10 append_parm() { 
    11         local section="$1" 
    12         local option="$2" 
    13         local switch="$3" 
    14         local _loctmp 
    15         config_get _loctmp "$section" "$option" 
    16         [ -z "$_loctmp" ] && return 0 
    17         append args "$switch $_loctmp" 
    18 } 
    19  
    20 append_stmt() { 
    21         local name="$1" 
    22         local switch="$2" 
    23         append args "-C '$switch $name'" 
    24 } 
    25  
    26 append_opt_stmt() { 
    27         local section="$1" 
    28         local option="$2" 
    29         local switch="$3" 
    30         local _loctmp 
    31         config_get _loctmp "$section" "$option" 
    32         [ -z "$_loctmp" ] && return 0 
    33         append args "-C '$switch $_loctmp'" 
    34 } 
    35  
    36 ahcp_addif() { 
    37         local ifname=$(uci_get_state network "$1" ifname "$1") 
    38         append interfaces "$ifname" 
    39 } 
    40  
    41 ahcp_server() { 
    42         local cfg="$1" 
    43  
    44         append_opt_stmt "$cfg" 'mode' 'mode' 
    45         append_opt_stmt "$cfg" 'lease_dir' 'lease-dir' 
    46         config_list_foreach "$cfg" 'prefix' append_stmt 'prefix' 
    47         config_list_foreach "$cfg" 'name_server' append_stmt 'name-server' 
    48         config_list_foreach "$cfg" 'ntp_server' append_stmt 'ntp-server' 
    49  
    50         append_parm "$cfg" 'id_file' '-i' 
    51         append_parm "$cfg" 'log_file' '-L' 
    52 } 
    53  
    54 ahcp_config() { 
    55         local cfg="$1" 
    56  
    57         config_list_foreach "$cfg" 'interface' ahcp_addif 
    58  
    59         append_bool "$cfg" 'ipv4_only' '-4' 
    60         append_bool "$cfg" 'ipv6_only' '-6' 
    61         append_bool "$cfg" 'no_dns' '-N' 
    62  
    63         append_parm "$cfg" 'multicast_address' '-m' 
    64         append_parm "$cfg" 'port' '-p' 
    65         append_parm "$cfg" 'lease_time' '-t' 
    66         append_parm "$cfg" 'debug' '-d' 
    67         append_parm "$cfg" 'conf_file' '-c' 
    68         append_parm "$cfg" 'script' '-s' 
    69 } 
    70  
    711setup_interface_ahcp() { 
    722        local interface="$1" 
    733        local config="$2" 
    744 
    75     echo "WARNING: ahcp client cannot be configured in /etc/config/network anymore." 
    76     echo "Please add $interface to /etc/config/ahcpd instead." 
     5        local mode=$(uci_get_state ahcpd "@ahcpd[0]" mode "client") 
     6        if [ "$mode" != "client" ]; then 
     7                echo "Warning: ahcp ignored for $interface (mode is $mode, should be client)." 
     8                echo "Fix ahcp mode in /etc/config/ahcpd." 
     9                return 
     10        fi 
     11        setup_interface_none "$interface" "$config" 
     12        /etc/init.d/ahcpd restart 
    7713} 
Note: See TracChangeset for help on using the changeset viewer.