]> git.ipfire.org Git - people/stevee/network.git/blobdiff - src/functions/functions.ports
Fix hook settings writing and checking
[people/stevee/network.git] / src / functions / functions.ports
index 638d7ea13e1a444c80ff98ec0a8cf557efd2b18b..58f60cd180c5fd2248591b0fbffaed801c152fbc 100644 (file)
@@ -40,12 +40,11 @@ function port_config_dir() {
 function port_settings_read() {
        local port="${1}"
        assert isset port
-       shift
 
        # Save the HOOK variable.
        local hook="${HOOK}"
 
-       settings_read "$(port_file "${port}")" "$@"
+       settings_read "$(port_file "${port}")" ${HOOK_SETTINGS}
 
        # Restore hook.
        HOOK="${hook}"
@@ -56,7 +55,13 @@ function port_settings_write() {
        assert isset port
        shift
 
-       settings_write "$(port_file "${port}")" "$@"
+       local args
+       if function_exists "hook_check_settings"; then
+               list_append args "--check=\"hook_check_settings\""
+       fi
+       list_append args ${HOOK_SETTINGS}
+
+       settings_write "$(port_file "${port}")" ${args}
 }
 
 function ports_get_all() {
@@ -111,7 +116,7 @@ function port_is_attached() {
        return ${EXIT_ERROR}
 }
 
-function port_create() {
+function port_new() {
        #local port=${1}
        #shift
        #
@@ -134,7 +139,7 @@ function port_create() {
        #       port_destroy ${port}
        #fi
 
-       hook_exec port ${hook} create $@
+       hook_exec port ${hook} new $@
 }
 
 function port_destroy() {
@@ -180,8 +185,20 @@ function port_destroy() {
        rm -f $(port_file ${port})
 }
 
+function port_create() {
+       port_cmd "create" $@
+}
+
 function port_remove() {
-       port_destroy $@
+       local port="${1}"
+       assert isset port
+
+       # If the device is still up, we need to bring it down first.
+       if device_is_up "${port}"; then
+               port_down "${port}"
+       fi
+
+       port_cmd "remove" "${port}"
 }
 
 function port_edit() {