hooks: Import zone default settings, too
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 30 Mar 2019 12:10:58 +0000 (13:10 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 30 Mar 2019 12:10:58 +0000 (13:10 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/header-zone
src/hooks/zones/bridge
src/hooks/zones/ip-tunnel
src/hooks/zones/modem
src/hooks/zones/pppoe

index ead4a32..7ad3e39 100644 (file)
@@ -34,6 +34,11 @@ hook_new() {
        assert isset zone
        shift
 
+       local ${HOOK_SETTINGS}
+
+       # Import all default variables
+       hook_set_defaults
+
        if ! hook_parse_cmdline "$@"; then
                return ${EXIT_ERROR}
        fi
index 93a3a31..33d5811 100644 (file)
@@ -29,6 +29,7 @@ HOOK_SETTINGS="${HOOK_SETTINGS} STP_PRIORITY MTU"
 HOOK_PORT_SETTINGS="COST PRIORITY"
 
 # Default values
+DEFAULT_STP="on"
 DEFAULT_STP_FORWARD_DELAY=0
 DEFAULT_STP_HELLO=2
 DEFAULT_STP_MAXAGE=20
@@ -123,19 +124,11 @@ hook_parse_cmdline() {
                shift
        done
 
-       # Generate a random MAC address if the user passed no one
+       # Generate a random MAC address if the user passed none
        if ! isset ADDRESS; then
                ADDRESS="$(mac_generate)"
        fi
 
-       # Enable Spanning Tree Protocol by default
-       if ! isset STP; then
-               STP="on"
-       fi
-
-       # Set all other defaults
-       hook_set_defaults
-
        return ${EXIT_OK}
 }
 
index c9c73ba..e4be361 100644 (file)
@@ -26,13 +26,7 @@ SUPPORTED_IP_TUNNEL_MODES="gre vti"
 HOOK_SETTINGS="HOOK MARK MODE PEER LOCAL_ADDRESS"
 
 # Default mode of the tunnel
-MODE="gre"
-
-# The IP address of the tunnel endpoint where to connect to
-PEER=
-
-# The local IP address of the tunnel endpoint
-LOCAL_ADDRESS=
+DEFAULT_MODE="gre"
 
 hook_check_settings() {
        assert isset MODE && assert isoneof MODE ${SUPPORTED_IP_TUNNEL_MODES}
index 1b4c3c0..50d43c7 100644 (file)
@@ -27,47 +27,37 @@ MODEM_ALLOWED_AUTH_METHODS="${PPP_ALLOWED_AUTH_METHODS}"
 HOOK_SETTINGS="HOOK"
 
 # Access Point Name.
-APN=
 HOOK_SETTINGS="${HOOK_SETTINGS} APN"
 
 # Sets the authentication algortihm that must be used.
-AUTH=
 HOOK_SETTINGS="${HOOK_SETTINGS} AUTH"
 
 # Baudrate.
-BAUDRATE=921600
+DEFAULT_BAUDRATE=921600
 HOOK_SETTINGS="${HOOK_SETTINGS} BAUDRATE"
 
 # The device name of the serial device.
 # XXX how can we make sure that this does not change all the time?
-DEVICE=
 HOOK_SETTINGS="${HOOK_SETTINGS} DEVICE"
 
 # A monitor device.
 # Send AT commands to this device, when the primary device is
 # connected.
-MONITOR_DEVICE=
 HOOK_SETTINGS="${HOOK_SETTINGS} MONITOR_DEVICE"
 
 # Maximum transmission unit.
-MTU=
 HOOK_SETTINGS="${HOOK_SETTINGS} MTU"
 
 # User credentials.
-USERNAME=
-PASSWORD=
 HOOK_SETTINGS="${HOOK_SETTINGS} USERNAME PASSWORD"
 
 # PIN code.
-PIN=
 HOOK_SETTINGS="${HOOK_SETTINGS} PIN"
 
 # Phone number.
-PHONE_NUMBER=
 HOOK_SETTINGS="${HOOK_SETTINGS} PHONE_NUMBER"
 
 # IMSI
-IMSI=
 HOOK_SETTINGS="${HOOK_SETTINGS} IMSI"
 
 hook_check_settings() {
index e113c92..cd3913b 100644 (file)
 HOOK_SETTINGS="HOOK ACCESS_CONCENTRATOR AUTH USERNAME PASSWORD"
 HOOK_SETTINGS="${HOOK_SETTINGS} SERVICE_NAME MTU IPV6 PREFIX_DELEGATION"
 
-# User credentials for the dialin.
-USERNAME=""
-PASSWORD=""
-
-# Set the authentication mechanism.
-AUTH=
-
-# Access Concentrator.
-ACCESS_CONCENTRATOR=""
-
-# Service name.
-SERVICE_NAME=""
-
-# Maximum Transmission Unit.
-MTU=
-
 # This hook can work with all authentication methods supported by pppd.
 PPPOE_SUPPORTED_AUTH_METHODS="${PPP_SUPPORTED_AUTH_METHODS}"
 PPPOE_PLUGIN="rp-pppoe.so"
 
 # Request an IPv6 address.
-IPV6="true"
+DEFAULT_IPV6="true"
 
 # Use IPv6 prefix delegation.
-PREFIX_DELEGATION="true"
+DEFAULT_PREFIX_DELEGATION="true"
 
 hook_check_settings() {
        assert isset USERNAME