nodogsplash: simplify append_config_option
Drop arguement config_counterpart from append_config_option(). append_config_option took an additional argument named config_counterpart which represents the configuration name in configfile.This is needed for configuration variable names isn't the same as in uci. Nodogsplash ignores the case of configuration variables and makes this feature optional. Introduce new func append_config_option_map() which does the old behaviour.
This commit is contained in:
parent
dfa1e090fb
commit
7a233607af
|
@ -30,11 +30,11 @@ 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 config_file="$1"
|
||||
local cfg="$2"
|
||||
|
@ -45,6 +45,21 @@ append_config_option() {
|
|||
[ -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() {
|
||||
local cfg="$1"
|
||||
local val
|
||||
|
@ -168,42 +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" webroot webroot
|
||||
append_config_option "$CONFIGFILE" "$cfg" debuglevel debuglevel
|
||||
append_config_option "$CONFIGFILE" "$cfg" splashpage splashpage
|
||||
append_config_option "$CONFIGFILE" "$cfg" pagesdir pagesdir
|
||||
append_config_option "$CONFIGFILE" "$cfg" checkinterval checkinterval
|
||||
append_config_option "$CONFIGFILE" "$cfg" syslogfacility syslogfacility
|
||||
append_config_option "$CONFIGFILE" "$cfg" gatewayiprange gatewayiprange
|
||||
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" remoteauthenticatoraction remoteauthenticatoraction
|
||||
append_config_option "$CONFIGFILE" "$cfg" enablepreauth enablepreauth
|
||||
append_config_option "$CONFIGFILE" "$cfg" binvoucher binvoucher
|
||||
append_config_option "$CONFIGFILE" "$cfg" forcevoucher forcevoucher
|
||||
append_config_option "$CONFIGFILE" "$cfg" passwordauthentication passwordauthentication
|
||||
append_config_option "$CONFIGFILE" "$cfg" usernameauthentication usernameauthentication
|
||||
append_config_option "$CONFIGFILE" "$cfg" passwordattempts passwordattempts
|
||||
append_config_option "$CONFIGFILE" "$cfg" username username
|
||||
append_config_option "$CONFIGFILE" "$cfg" password password
|
||||
append_config_option "$CONFIGFILE" "$cfg" authenticateimmediately authenticateimmediately
|
||||
append_config_option "$CONFIGFILE" "$cfg" decongesthttpdthreads decongesthttpdthreads
|
||||
append_config_option "$CONFIGFILE" "$cfg" httpdthreadthreshold httpdthreadthreshold
|
||||
append_config_option "$CONFIGFILE" "$cfg" httpdthreaddelayms httpdthreaddelayms
|
||||
append_config_option "$CONFIGFILE" "$cfg" fw_mark_authenticated fw_mark_authenticated
|
||||
append_config_option "$CONFIGFILE" "$cfg" fw_mark_trusted fw_mark_trusted
|
||||
append_config_option "$CONFIGFILE" "$cfg" fw_mark_blocked fw_mark_blocked
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue