]> git.ipfire.org Git - people/stevee/network.git/commitdiff
wireless networks: Only delete one network at a time
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 18 Aug 2017 13:32:30 +0000 (15:32 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 18 Aug 2017 13:32:30 +0000 (15:32 +0200)
Destroying multiple networks in one go is not really a good
idea here, since error codes are not properly passed on.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.wireless-networks

index 0133fe7f41f1534e42fab8cf70889ce0dc269534..e2af14cdc6a87cadf0bc643e96d9fc34d426bd3a 100644 (file)
@@ -236,26 +236,25 @@ wireless_network_new() {
        fi
 }
 
-# Function that deletes based on the passed parameters
-# one ore more wireless networks
+# Deletes a wireless network
 wireless_network_destroy() {
-       local ssid
-       for ssid in "$@"; do
-               local ssid_hash="$(wireless_network_hash "${ssid}")"
-               assert isset ssid_hash
-
-               if ! wireless_network_exists "${ssid}"; then
-                       log ERROR "The wireless network ${ssid} does not exist."
-                       continue
-               fi
-
-               log DEBUG "Deleting wireless network ${ssid}"
-
-               if ! rm -rf "${NETWORK_WIRELESS_NETWORKS_DIR}/${ssid_hash}"; then
-                       log ERROR "Deleting the wireless network ${ssid} was not sucessful"
-                       return ${EXIT_ERROR}
-               fi
-       done
+       local ssid="${1}"
+
+       if ! wireless_network_exists "${ssid}"; then
+               error "No such wireless network: ${ssid}"
+               return ${EXIT_ERROR}
+       fi
+
+       local ssid_hash="$(wireless_network_hash "${ssid}")"
+       assert isset ssid_hash
+
+       if ! rm -rf "${NETWORK_WIRELESS_NETWORKS_DIR}/${ssid_hash}"; then
+               error "Could not delete the wireless network"
+               return ${EXIT_ERROR}
+       fi
+
+       log INFO "Successfully destroyed wireless network ${ssid}"
+       return ${EXIT_OK}
 }
 
 wireless_network_encryption_mode() {