local port="${1}"
assert isset port
+ if ! port_exists "${port}"; then
+ log ERROR "Port ${port} does not exist"
+ return ${EXIT_ERROR}
+ fi
+
# If the device is still up, we need to bring it down first.
if device_is_up "${port}"; then
port_down "${port}"
port_cmd "remove" "${port}"
}
+# Restarts the port by removing it and then re-creating it
+port_restart() {
+ local port="${1}"
+ assert isset port
+
+ port_remove "${port}"
+
+ port_create "${port}"
+}
+
port_edit() {
port_cmd edit $@
}
fi
}
-hook_new() {
+hook_parse_cmdline() {
while [ $# -gt 0 ]; do
case "${1}" in
--broadcast-ssid=*)
# Save address of phy do identify it again
PHY=$(phy_get ${PHY})
PHY=$(phy_get_address ${PHY})
+}
+
+hook_new() {
+ if ! hook_parse_cmdline $@; then
+ return ${EXIT_ERROR}
+ fi
local port=$(port_find_free ${PORT_PATTERN_ACCESSPOINT})
assert isset port
hook_edit() {
local port=${1}
- shift
-
assert isset port
- port_settings_read "${port}" ${HOOK_SETTINGS}
-
- while [ $# -gt 0 ]; do
- case "${1}" in
- --broadcast-ssid=*)
- BROADCAST_SSID=$(cli_get_val ${1})
- ;;
- --channel=*)
- CHANNEL=$(cli_get_val ${1})
- ;;
- --encryption=*)
- ENCRYPTION=$(cli_get_val ${1})
- ;;
- --key=*)
- KEY=$(cli_get_val ${1})
- ;;
- --ssid=*)
- SSID=$(cli_get_val ${1})
- ;;
- --mode=*)
- MODE=$(cli_get_val ${1})
- ;;
- *)
- warning "Unknown argument '${1}'"
- ;;
- esac
- shift
- done
-
- port_settings_write "${port}" ${HOOK_SETTINGS}
+ if ! hook_default_edit $@; then
+ return ${EXIT_ERROR}
+ fi
- exit ${EXIT_OK}
+ # To apply all changes, we need to restart the port
+ port_restart "${port}"
}
hook_create() {