Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
- 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
else
list_append args "$@"
fi
}
zone_config_settings_write() {
}
zone_config_settings_write() {
local zone="${1}"
local hook="${2}"
local zone="${1}"
local hook="${2}"
local path="${NETWORK_ZONES_DIR}/${zone}/configs/${hook}.${id}"
settings_write "${path}" \
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() {
}
zone_config_settings_destroy() {
local id=$(zone_config_get_new_id ${zone})
log DEBUG "ID for the config is: ${id}"
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
# Parse command line arguments
if ! hook_parse_cmdline "${id}" "$@"; then
# Return an error if the parsing of the cmd line fails
- local ${HOOK_CONFIG_SETTINGS}
# If reading the config fails we cannot go on
if ! zone_config_settings_read "${zone}" "${config}"; then
# If reading the config fails we cannot go on
if ! zone_config_settings_read "${zone}" "${config}"; then
. /usr/lib/network/header-config
. /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
hook_check_config_settings() {
assert isset ENABLE_IPV6
local id=$(zone_config_get_new_id ${zone})
log DEBUG "ID for the config is: ${id}"
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}
if ! hook_parse_cmdline "${id}" "$@"; then
# Return an error if the parsing of the cmd line fails
return ${EXIT_ERROR}
. /usr/lib/network/header-config
. /usr/lib/network/header-config
-HOOK_CONFIG_SETTINGS="HOOK PRIVACY_EXTENSIONS"
+HOOK_SETTINGS=(
+ "PRIVACY_EXTENSIONS"
+)
# Privacy Extensions are disabled by default
# Privacy Extensions are disabled by default
-PRIVACY_EXTENSIONS="off"
+DEFAULT_PRIVACY_EXTENSIONS="off"
hook_check_config_settings() {
assert isbool PRIVACY_EXTENSIONS
hook_check_config_settings() {
assert isbool PRIVACY_EXTENSIONS
while read arg; do
case "${arg}" in
--privacy-extensions=*)
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 "$@")"
;;
esac
done <<< "$(args "$@")"
. /usr/lib/network/header-config
. /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
hook_check_config_settings() {
assert isset MTU
. /usr/lib/network/header-config
. /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}")"
hook_check_config_settings() {
local protocol="$(ip_detect_protocol "${ADDRESS}")"