]> git.ipfire.org Git - people/stevee/network.git/blobdiff - functions.ports
Add whitelist of serial USB devices.
[people/stevee/network.git] / functions.ports
index cb247a165ae64adcd547419bb6168d4d15129f35..198a08ba3694576e1102c41087c8b04971907958 100644 (file)
 ###############################################################################
 
 function port_dir() {
-       echo "${CONFIG_DIR}/ports"
+       echo "${NETWORK_CONFIG_DIR}/ports"
+}
+
+function port_get_hook() {
+       local port=${1}
+       assert isset port
+
+       config_get_hook $(port_file ${port})
+}
+
+function port_config_dir() {
+       local port=${1}
+
+       print "${RUN_DIR}/ports/${port}"
+       return ${EXIT_OK}
+}
+
+function port_config_read() {
+       local port=${1}
+       assert isset port
+
+       # Save the HOOK variable.
+       local hook="${HOOK}"
+
+       config_read $(port_file ${port})
+
+       # Restore hook.
+       HOOK="${hook}"
+}
+
+function port_config_write() {
+       local port=${1}
+       assert isset port
+
+       config_write $(port_file ${port})
 }
 
 function ports_get_all() {
@@ -35,7 +69,6 @@ function ports_get_all() {
 
 function port_file() {
        local port=${1}
-
        assert isset port
 
        echo "$(port_dir)/${port}"
@@ -44,7 +77,7 @@ function port_file() {
 function port_exists() {
        local port=${1}
 
-       [ -f "${CONFIG_DIR}/ports/${port}" ]
+       [ -f "${NETWORK_CONFIG_DIR}/ports/${port}" ]
 }
 
 function port_get_hook() {
@@ -199,22 +232,6 @@ function ports_get() {
        done
 }
 
-# This function automatically creates the real ethernet devices
-# that do not exists in the configuration.
-# Saves some work for the administrator.
-function ports_init() {
-       local device
-       for device in $(devices_get_all); do
-               if device_is_real ${device}; then
-                       if ! port_exists ${device}; then
-                               port_create ethernet ${device}
-                       fi
-               fi
-       done
-}
-
-init_register ports_init
-
 function port_find_free() {
        local pattern=${1}