nodogplash: change section name
[feed/routing.git] / nodogsplash / files / nodogsplash.init
index 463ff91b04432bf11e15a30f40854c7ec5671964..a84172195b737d0b512943f277a29ef2259fdc80 100755 (executable)
@@ -30,19 +30,34 @@ nolog() {
   logger -s -t nodogsplash -p daemon.$level $@
 }
 
-# append_config_option <cfgfile> <uci_cfg_obj> <option_name> <config_counterpart> [<optional default>]
+# append_config_option_map <cfgfile> <uci_cfg_obj> <option_name> <config_counterpart> [<optional default>]
 # append "$config_counterpart $value" to cfgfile if option_name exists
 # e.g. append_config_option "$CONFIGFILE" "$cfg" bind_address BindAddress 0.0.0.0
 # will append "BindAddress 192.168.1.1" if uci bind_address is '192.168.1.1'
-append_config_option() {
+append_config_option_map() {
   local val=""
-  local cfg="$1"
-  local config_file="$2"
+  local config_file="$1"
+  local cfg="$2"
   local option_name="$3"
   local config_counterpart="$4"
   local default="$5"
   config_get val "$cfg" "$option_name" "$default"
-  [ -n "$val" ] && echo "" >> $config_file
+  [ -n "$val" ] && echo "$config_counterpart $val" >> $config_file
+}
+
+# append_config_option <cfgfile> <uci_cfg_obj> <option_name> [<optional default>]
+# append "$option_name $value" to cfgfile if option_name exists
+# e.g. append_config_option "$CONFIGFILE" "$cfg" bind_address 0.0.0.0
+# will append "bind_address 192.168.1.1" if uci bind_address is '192.168.1.1'
+# if uci bind_address is unset append "bind_address 0.0.0.0"
+append_config_option() {
+  local val=""
+  local config_file="$1"
+  local cfg="$2"
+  local option_name="$3"
+  local default="$4"
+  config_get val "$cfg" "$option_name" "$default"
+  [ -n "$val" ] && echo "$option_name $val" >> $config_file
 }
 
 setup_user_authentication() {
@@ -54,13 +69,13 @@ setup_user_authentication() {
 
   config_get val "$cfg" username
   if [ -n "$val" ] ; then
-    echo "UsernameAuthentication" >> $CONFIGFILE
+    echo "UsernameAuthentication 1" >> $CONFIGFILE
     echo "Username $val" >> $CONFIGFILE
   fi
 
   config_get val "$cfg" password
   if [ -n "$val" ] ; then
-    echo "PasswordAuthentication" >> $CONFIGFILE
+    echo "PasswordAuthentication 1" >> $CONFIGFILE
     echo "Password $val" >> $CONFIGFILE
   fi
 }
@@ -137,11 +152,11 @@ generate_uci_config() {
 
   config_get val "$cfg" config
   if [ -n "$val" ] ; then
-    if [ -f "$val" ] ; then
+    if [ -f "$val" ] ; then
       nolog error "Configuration file '$file' doesn't exist"
       return 0
     fi
-    cat $val > CONFIGFILE
+    cat "$val" >> $CONFIGFILE
   fi
 
   config_get val "$cfg" network
@@ -168,19 +183,42 @@ generate_uci_config() {
 
   echo "GatewayInterface $ifname" >> $CONFIGFILE
 
-  append_config_option "$CONFIGFILE" "$cfg" gatewayname GatewayName
-  append_config_option "$CONFIGFILE" "$cfg" gatewayaddress GatewayAddress
-  append_config_option "$CONFIGFILE" "$cfg" gatewayport GatewayPort
-  append_config_option "$CONFIGFILE" "$cfg" maxclients MaxClients
-  append_config_option "$CONFIGFILE" "$cfg" imagedir ImagesDir
-  append_config_option "$CONFIGFILE" "$cfg" redirecturl RedirectURL
-  append_config_option "$CONFIGFILE" "$cfg" clientidletimeout ClientIdleTimeout
-  append_config_option "$CONFIGFILE" "$cfg" clientforcetimeout ClientForceTimeout
-  append_config_option "$CONFIGFILE" "$cfg" gatewayiprange GatewayIPRange
-  append_config_option "$CONFIGFILE" "$cfg" passwordattempts PasswordAttempts
-  append_config_option "$CONFIGFILE" "$cfg" macmechanism MACMechanism
-  append_config_option "$CONFIGFILE" "$cfg" uploadlimit UploadLimit
-  append_config_option "$CONFIGFILE" "$cfg" downloadlimit DownloadLimit
+  append_config_option "$CONFIGFILE" "$cfg" gatewayname
+  append_config_option "$CONFIGFILE" "$cfg" gatewayaddress
+  append_config_option "$CONFIGFILE" "$cfg" gatewayport
+  append_config_option "$CONFIGFILE" "$cfg" maxclients
+  append_config_option "$CONFIGFILE" "$cfg" webroot
+  append_config_option "$CONFIGFILE" "$cfg" debuglevel
+  append_config_option "$CONFIGFILE" "$cfg" splashpage
+  append_config_option "$CONFIGFILE" "$cfg" pagesdir
+  append_config_option "$CONFIGFILE" "$cfg" checkinterval
+  append_config_option "$CONFIGFILE" "$cfg" syslogfacility
+  append_config_option "$CONFIGFILE" "$cfg" gatewayiprange
+  append_config_option "$CONFIGFILE" "$cfg" imagedir
+  append_config_option "$CONFIGFILE" "$cfg" redirecturl
+  append_config_option "$CONFIGFILE" "$cfg" clientidletimeout
+  append_config_option "$CONFIGFILE" "$cfg" clientforcetimeout
+  append_config_option "$CONFIGFILE" "$cfg" gatewayiprange
+  append_config_option "$CONFIGFILE" "$cfg" passwordattempts
+  append_config_option "$CONFIGFILE" "$cfg" macmechanism
+  append_config_option "$CONFIGFILE" "$cfg" uploadlimit
+  append_config_option "$CONFIGFILE" "$cfg" downloadlimit
+  append_config_option "$CONFIGFILE" "$cfg" remoteauthenticatoraction
+  append_config_option "$CONFIGFILE" "$cfg" enablepreauth
+  append_config_option "$CONFIGFILE" "$cfg" binvoucher
+  append_config_option "$CONFIGFILE" "$cfg" forcevoucher
+  append_config_option "$CONFIGFILE" "$cfg" passwordauthentication
+  append_config_option "$CONFIGFILE" "$cfg" usernameauthentication
+  append_config_option "$CONFIGFILE" "$cfg" passwordattempts
+  append_config_option "$CONFIGFILE" "$cfg" username
+  append_config_option "$CONFIGFILE" "$cfg" password
+  append_config_option "$CONFIGFILE" "$cfg" authenticateimmediately
+  append_config_option "$CONFIGFILE" "$cfg" decongesthttpdthreads
+  append_config_option "$CONFIGFILE" "$cfg" httpdthreadthreshold
+  append_config_option "$CONFIGFILE" "$cfg" httpdthreaddelayms
+  append_config_option "$CONFIGFILE" "$cfg" fw_mark_authenticated
+  append_config_option "$CONFIGFILE" "$cfg" fw_mark_trusted
+  append_config_option "$CONFIGFILE" "$cfg" fw_mark_blocked
 
   config_get download "$cfg" downloadlimit
   config_get upload "$cfg" uploadlimit
@@ -219,7 +257,7 @@ start_service() {
   mkdir -p /tmp/etc/
   config_load nodogsplash
 
-  config_foreach create_instance instance
+  config_foreach create_instance nodogsplash
 }
 
 stop_service() {