hook: Rename HOOK_CONFIG_SETTINGS to HOOK_SETTINGS
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 30 Mar 2019 15:54:04 +0000 (16:54 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 30 Mar 2019 15:54:04 +0000 (16:54 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.zone
src/header-config
src/hooks/configs/dhcp
src/hooks/configs/ipv6-auto
src/hooks/configs/pppoe-server
src/hooks/configs/static

index e81371b..28fbecd 100644 (file)
@@ -1312,8 +1312,8 @@ zone_config_settings_read() {
        shift 2
 
        local args
-       if [ $# -eq 0 ] && [ -n "${HOOK_CONFIG_SETTINGS}" ]; then
-               list_append args ${HOOK_CONFIG_SETTINGS}
+       if [ $# -eq 0 ] && [ -n "${HOOK_SETTINGS[*]}" ]; then
+               list_append args ${HOOK_SETTINGS[*]}
        else
                list_append args "$@"
        fi
@@ -1323,7 +1323,7 @@ zone_config_settings_read() {
 }
 
 zone_config_settings_write() {
-       assert [ $# -eq 2 ]
+       assert [ $# -eq 3 ]
 
        local zone="${1}"
        local hook="${2}"
@@ -1333,7 +1333,7 @@ zone_config_settings_write() {
 
        local path="${NETWORK_ZONES_DIR}/${zone}/configs/${hook}.${id}"
        settings_write "${path}" \
-               --check="hook_check_config_settings" ${HOOK_CONFIG_SETTINGS[*]}
+               --check="hook_check_config_settings" HOOK ${HOOK_SETTINGS[*]}
 }
 
 zone_config_settings_destroy() {
index 4458eaa..baeca5e 100644 (file)
@@ -26,6 +26,9 @@ hook_new() {
        local id=$(zone_config_get_new_id ${zone})
        log DEBUG "ID for the config is: ${id}"
 
+       # Import all default variables
+       hook_set_defaults
+
        # Parse command line arguments
        if ! hook_parse_cmdline "${id}" "$@"; then
                # Return an error if the parsing of the cmd line fails
@@ -64,7 +67,7 @@ hook_edit() {
                fi
        fi
 
-       local ${HOOK_CONFIG_SETTINGS}
+       local ${HOOK_SETTINGS}
 
        # If reading the config fails we cannot go on
        if ! zone_config_settings_read "${zone}" "${config}"; then
index b643022..1ad0694 100644 (file)
 
 . /usr/lib/network/header-config
 
-HOOK_CONFIG_SETTINGS="HOOK ENABLE_IPV6 ENABLE_IPV4"
+HOOK_SETTINGS=(
+       "ENABLE_IPV6"
+       "ENABLE_IPV4"
+)
 
-# Default settings.
-ENABLE_IPV6="on"
-ENABLE_IPV4="on"
+DEFAULT_ENABLE_IPV6="on"
+DEFAULT_ENABLE_IPV4="on"
 
 hook_check_config_settings() {
        assert isset ENABLE_IPV6
@@ -78,6 +80,9 @@ hook_new() {
        local id=$(zone_config_get_new_id ${zone})
        log DEBUG "ID for the config is: ${id}"
 
+       # Import defaults
+       hook_set_defaults
+
        if ! hook_parse_cmdline "${id}" "$@"; then
                # Return an error if the parsing of the cmd line fails
                return ${EXIT_ERROR}
index 8796723..6fd90a5 100644 (file)
 
 . /usr/lib/network/header-config
 
-HOOK_CONFIG_SETTINGS="HOOK PRIVACY_EXTENSIONS"
+HOOK_SETTINGS=(
+       "PRIVACY_EXTENSIONS"
+)
 
 # Privacy Extensions are disabled by default
-PRIVACY_EXTENSIONS="off"
+DEFAULT_PRIVACY_EXTENSIONS="off"
 
 hook_check_config_settings() {
        assert isbool PRIVACY_EXTENSIONS
@@ -35,17 +37,10 @@ hook_parse_cmdline() {
        shift
 
        local arg
-
        while read arg; do
                case "${arg}" in
                        --privacy-extensions=*)
-                               local val="$(cli_get_val "${arg}")"
-
-                               if enabled val; then
-                                       PRIVACY_EXTENSIONS="on"
-                               else
-                                       PRIVACY_EXTENSIONS="off"
-                               fi
+                               PRIVACY_EXTENSIONS="$(cli_get_bool "${arg}")"
                                ;;
                esac
        done <<< "$(args "$@")"
index 6a2c014..4d79549 100644 (file)
 
 . /usr/lib/network/header-config
 
-HOOK_CONFIG_SETTINGS="HOOK DNS_SERVERS MTU SERVICE_NAME SUBNET MAX_SESSIONS"
-
-# Maximum Transmission Unit.
-MTU=1492
-
-# Service Name.
-SERVICE_NAME=
-
-# A subnet. Addresses from this subnet will be given to the remote hosts.
-# The net address will be the gateway address for the PPPoE server.
-SUBNET=
-
-# Defines the max. number of sessions per MAC address.
-# 0 = unlimited.
-MAX_SESSIONS=0
+HOOK_SETTINGS=(
+       "DNS_SERVERS"
+       "MTU"
+       "SERVICE_NAME"
+       "SUBNET MAX_SESSIONS"
+)
+
+DEFAULT_MTU=1492
+DEFAULT_MAX_SESSIONS=0
 
 hook_check_config_settings() {
        assert isset MTU
index 23ae2d8..6fddc32 100644 (file)
 
 . /usr/lib/network/header-config
 
-HOOK_CONFIG_SETTINGS="HOOK ADDRESS PREFIX GATEWAY"
+HOOK_SETTINGS=(
+       "ADDRESS"
+       "PREFIX"
+       "GATEWAY"
+)
 
 hook_check_config_settings() {
        local protocol="$(ip_detect_protocol "${ADDRESS}")"