]> git.ipfire.org Git - people/stevee/network.git/commitdiff
settings: Some code refactoring
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 30 Mar 2019 13:04:35 +0000 (14:04 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 30 Mar 2019 13:04:35 +0000 (14:04 +0100)
No functional changes

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.hook
src/functions/functions.ports
src/functions/functions.zone

index fb680374e74080644c5fdca9cbd35348d4082903..11887cdbf4b43241b1a398df59ad0815da585b49 100644 (file)
@@ -124,6 +124,19 @@ hook_help() {
        exit $?
 }
 
+# Dummy functions being overlayed by hooks
+hook_check_settings() {
+       :
+}
+
+hook_check_config_settings() {
+       :
+}
+
+hook_check_port_settings() {
+       :
+}
+
 # Sets all settings in HOOK_SETTINGS to their DEFAULT_* values
 hook_set_defaults() {
        local setting
index fb227150fc287d51f4ccea9c28708d1edbcbabf7..d8a9140b85df0a64dfa6bbb713f0244df1d068bb 100644 (file)
@@ -94,15 +94,9 @@ port_settings_read() {
 port_settings_write() {
        local port="${1}"
        assert isset port
-       shift
-
-       local args
-       if function_exists "hook_check_settings"; then
-               list_append args "--check=\"hook_check_settings\""
-       fi
-       list_append args HOOK ${HOOK_SETTINGS[*]}
 
-       settings_write "$(port_file "${port}")" ${args}
+       settings_write "$(port_file "${port}")" \
+               --check="hook_check_settings" HOOK ${HOOK_SETTINGS[*]}
 }
 
 port_file() {
index a0d3cfb87a081a3c406467b6f55507157ae2e9bc..e81371b97139dc37413c1dff960e143b46116495 100644 (file)
@@ -1267,13 +1267,8 @@ zone_settings_write() {
        local zone="${1}"
        assert isset zone
 
-       local args
-       if function_exists "hook_check_settings"; then
-               list_append args "--check=\"hook_check_settings\""
-       fi
-       list_append args HOOK ${HOOK_SETTINGS[*]}
-
-       settings_write "${NETWORK_ZONES_DIR}/${zone}/settings" ${args}
+       settings_write "${NETWORK_ZONES_DIR}/${zone}/settings" \
+               --check="hook_check_settings" HOOK ${HOOK_SETTINGS[*]}
 }
 
 zone_settings_set() {
@@ -1328,7 +1323,7 @@ zone_config_settings_read() {
 }
 
 zone_config_settings_write() {
-       assert [ $# -ge 2 ]
+       assert [ $# -eq 2 ]
 
        local zone="${1}"
        local hook="${2}"
@@ -1336,14 +1331,9 @@ zone_config_settings_write() {
 
        assert isset id
 
-       local args
-       if function_exists "hook_check_config_settings"; then
-               list_append args "--check=\"hook_check_config_settings\""
-       fi
-       list_append args ${HOOK_CONFIG_SETTINGS}
-
        local path="${NETWORK_ZONES_DIR}/${zone}/configs/${hook}.${id}"
-       settings_write "${path}" ${args}
+       settings_write "${path}" \
+               --check="hook_check_config_settings" ${HOOK_CONFIG_SETTINGS[*]}
 }
 
 zone_config_settings_destroy() {
@@ -1416,20 +1406,14 @@ zone_port_settings_read() {
 }
 
 zone_port_settings_write() {
-       assert [ $# -ge 2 ]
+       assert [ $# -eq 2 ]
 
        local zone="${1}"
        local port="${2}"
-       shift 2
-
-       local args
-       if function_exists "hook_check_port_settings"; then
-               list_append args "--check=\"hook_check_port_settings\""
-       fi
-       list_append args ${HOOK_PORT_SETTINGS}
 
        local path="${NETWORK_ZONES_DIR}/${zone}/ports/${port}"
-       settings_write "${path}" ${args}
+       settings_write "${path}" \
+               --check="hook_check_port_settings" ${HOOK_PORT_SETTINGS[*]}
 }
 
 zone_port_settings_remove() {