. /usr/lib/network/header-port
-HOOK_SETTINGS="HOOK ADDRESS PARENT_DEVICE TAG"
+HOOK_SETTINGS=(
+ "ADDRESS"
+ "PARENT_DEVICE"
+ "TAG"
+)
PORT_PARENTS_VAR="PARENT"
-function hook_check_settings() {
+hook_check_settings() {
assert isset PARENT_DEVICE
assert isinteger TAG
done
}
-function hook_new() {
+hook_new() {
while [ $# -gt 0 ]; do
case "${1}" in
--parent-device=*)
- PARENT_DEVICE=$(cli_get_val ${1})
+ PARENT_DEVICE=$(cli_get_val "${1}")
;;
--address=*)
- ADDRESS=$(cli_get_val ${1})
+ ADDRESS=$(cli_get_val "${1}")
;;
--tag=*)
- TAG=$(cli_get_val ${1})
+ TAG=$(cli_get_val "${1}")
;;
*)
warning "Unknown argument '${1}'"
local port="${PARENT_DEVICE}${VLAN_PORT_INTERFIX}${TAG}"
- port_settings_write "${port}" ${HOOK_SETTINGS}
+ port_settings_write "${port}"
exit ${EXIT_OK}
}
-function hook_edit() {
+hook_edit() {
local port=${1}
assert isset port
shift
- port_settings_read "${port}" ${HOOK_SETTINGS}
+ port_settings_read "${port}"
while [ $# -gt 0 ]; do
case "${1}" in
--address=*)
- ADDRESS=$(cli_get_val ${1})
+ ADDRESS=$(cli_get_val "${1}")
;;
*)
warning "Unknown argument '${1}'"
shift
done
- port_settings_write "${port}" ${HOOK_SETTINGS}
+ port_settings_write "${port}"
exit ${EXIT_OK}
}
-function hook_create() {
+hook_create() {
local port="${1}"
assert isset port
device_exists "${port}" && exit ${EXIT_OK}
# Read configruation
- port_settings_read "${port}" ${HOOK_SETTINGS}
+ port_settings_read "${port}"
# Create the VLAN device
vlan_create "${port}" "${PARENT_DEVICE}" "${TAG}" "${ADDRESS}"
exit ${EXIT_OK}
}
-function hook_remove() {
+hook_remove() {
local port="${1}"
assert isset port