]> git.ipfire.org Git - people/ms/network.git/commitdiff
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 e81371b97139dc37413c1dff960e143b46116495..28fbecd5c608537a847799d2f8d3e4bd7db1ef53 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 4458eaa94862472c93d512520f95194a2733b1da..baeca5e3340daa79fab82ecff438b10e63d18c04 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 b643022a7442926eac67e3ede9fa5828b318e57b..1ad069471a1531220f1d6e6661caf70e0cd146c8 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 8796723ecb65b22098fec07bef97baf435311e73..6fd90a538170cbaa74df58e3a46a1277612600da 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 6a2c014c21935a0353e99103a7c5289fd2bf6db6..4d79549b19b33d668aae4936208108f920790775 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 23ae2d89d6e8157730f528aee9f80c427759e7eb..6fddc320f7f8b05b847ab19a02c2d6cd124b60a4 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}")"