]> git.ipfire.org Git - people/arne_f/network.git/blobdiff - header-port
network: Add some sanity checks when removing a port.
[people/arne_f/network.git] / header-port
index d06b2e119903ec8e8982492d0982373cc46283f2..95b39d0e62007d17f22e2347d8709d27b6a2792f 100644 (file)
@@ -22,6 +22,7 @@
 . /lib/network/functions
 
 HOOK=$(basename ${0})
+INFO_SETTINGS="HOOK PORT_PARENTS PORT_CHILDREN"
 
 while [ $# -gt 0 ]; do
        case "${1}" in
@@ -39,7 +40,7 @@ done
 
 function run() {
        case "${action}" in
-               edit|add|create|rem|up|down|status)
+               edit|add|create|rem|up|down|status|info)
                        _${action} $@
                        ;;
        esac
@@ -47,3 +48,26 @@ function run() {
        error "Port hook '${HOOK}' didn't exit properly."
        exit ${EXIT_ERROR}
 }
+
+function _info() {
+       local port=${1}
+       shift
+
+       assert isset port
+
+       config_read $(port_file ${port})
+
+       local key
+       local val
+       for key in PORT_PARENTS PORT_CHILDREN; do
+               val="${key}_VAR"
+               val=${!val}
+               eval "${key}=\"${!val}\""
+       done
+
+       for key in ${INFO_SETTINGS}; do
+               echo "${key}=\"${!key}\""
+       done
+
+       exit ${ERROR_OK}
+}