1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2007 OpenWrt.org
13 config_get_bool enabled "$cfg" enabled '1'
14 [ $enabled -ne 0 ] || {
15 echo "$initscript: not enabled"
23 config_get interface "$cfg" interface
24 [ -n "$interface" ] || {
25 echo "$initscript: not 'interface' option specified"
33 config_get pid_file "$cfg" pid_file
34 [ -n "$pid_file" ] || pid_file="/var/run/$NAME-$interface.pid"
43 config_get options "$cfg" options
45 config_get config_script "$cfg" config_script
46 [ -n "$config_script" ] && append options "-c $config_script"
48 config_get address "$cfg" address
49 [ -n "$adress" ] && append options "-m $address"
51 config_get port "$cfg" port
52 [ -n "$port" ] && append options "-p $port"
54 config_get_bool authoritative "$cfg" authoritative '0'
55 [ $authoritative -ne 0 ] && {
59 config_get dat_file "$cfg" authority_file
60 [ -n "$dat_file" ] || dat_file="/var/run/$NAME-$interface.dat"
62 [ -f "$dat_file" ] || {
69 config_get prefix "$cfg" prefix
70 [ -n "$prefix" ] || prefix=`ahcp-generate-address -p -s -r`
71 append gen_options "-p $prefix"
73 config_get expire "$cfg" expire
74 [ -n "$expire" ] && append gen_options "-e $expire"
76 config_get protocol "$cfg" protocol
77 [ -n "$protocol" ] && append gen_options "-P $protocol"
79 [ "$protocol" = "static" ] && {
82 config_get gateway "$cfg" gateway
83 [ -n "$gateway" ] && append gen_options "-g $gateway"
86 config_get dns_server "$cfg" dns_server
87 [ -n "$dns_server" ] && append gen_options "-n $dns_server"
89 config_get ntp_server "$cfg" ntp_server
90 [ -n "$ntp_server" ] && append gen_options "-N $ntp_server"
92 ahcp-generate $gen_options > $dat_file
94 append options "-a $dat_file"
96 append options "$interface"
102 is_enabled "$cfg" || return
103 get_interface "$cfg" || return
107 $SSD -S -p $pid_file -b -m -x $BIN_F -- $options &>/dev/null
113 is_enabled "$cfg" || return
114 get_interface "$cfg" || return
117 $SSD -K -p $pid_file &>/dev/null
122 config_foreach start_service $NAME
127 config_foreach stop_service $NAME