From: Michael Tremer Date: Thu, 25 Dec 2014 16:39:29 +0000 (+0000) Subject: Align zone create/remove actions to ports (new/destroy) X-Git-Tag: 007~54 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cf0fc8ab37a876189594b4232e4701bcb1d8b78b;p=network.git Align zone create/remove actions to ports (new/destroy) --- diff --git a/man/network-zone-6rd.xml b/man/network-zone-6rd.xml index 3dddc34c..ccf5fd8f 100644 --- a/man/network-zone-6rd.xml +++ b/man/network-zone-6rd.xml @@ -29,7 +29,7 @@ - network zone create ZONE 6rd ... + network zone new ZONE 6rd ... diff --git a/man/network-zone-6to4-tunnel.xml b/man/network-zone-6to4-tunnel.xml index 425d5c32..8126e821 100644 --- a/man/network-zone-6to4-tunnel.xml +++ b/man/network-zone-6to4-tunnel.xml @@ -29,7 +29,7 @@ - network zone create ZONE 6to4-tunnel ... + network zone new ZONE 6to4-tunnel ... diff --git a/man/network-zone-aiccu.xml b/man/network-zone-aiccu.xml index c046c0cb..ecd3db76 100644 --- a/man/network-zone-aiccu.xml +++ b/man/network-zone-aiccu.xml @@ -29,7 +29,7 @@ - network zone create ZONE aiccu ... + network zone new ZONE aiccu ... diff --git a/man/network-zone-bridge.xml b/man/network-zone-bridge.xml index 4a121fa3..efa8d11d 100644 --- a/man/network-zone-bridge.xml +++ b/man/network-zone-bridge.xml @@ -29,7 +29,7 @@ - network zone create ZONE bridge ... + network zone new ZONE bridge ... diff --git a/man/network-zone-pppoe.xml b/man/network-zone-pppoe.xml index ede9375c..abfb84bf 100644 --- a/man/network-zone-pppoe.xml +++ b/man/network-zone-pppoe.xml @@ -29,7 +29,7 @@ - network zone create ZONE pppoe ... + network zone new ZONE pppoe ... diff --git a/man/network-zone-pptp.xml b/man/network-zone-pptp.xml index 278816e6..3ef077d1 100644 --- a/man/network-zone-pptp.xml +++ b/man/network-zone-pptp.xml @@ -29,7 +29,7 @@ - network zone create ZONE pptp ... + network zone new ZONE pptp ... diff --git a/man/network-zone.xml b/man/network-zone.xml index 182b95fb..52e3d77f 100644 --- a/man/network-zone.xml +++ b/man/network-zone.xml @@ -29,7 +29,7 @@ - network zone [create|remove] ZONE ... + network zone [new|destroy] ZONE ... @@ -65,7 +65,7 @@ - create ZONE HOOK OPTIONS + new ZONE HOOK OPTIONS @@ -84,12 +84,12 @@ - remove ZONE + destroy ZONE - A zone can be simple removed with this command. + A zone can be destroyed with this command. There are two possible ways to remove a zone. The case diff --git a/src/functions/functions.hook b/src/functions/functions.hook index 8146277b..27f4389a 100644 --- a/src/functions/functions.hook +++ b/src/functions/functions.hook @@ -25,8 +25,8 @@ HOOK_COMMANDS_CONFIG="${HOOK_COMMANDS_CONFIG} hook_up" HOOK_COMMANDS_PORT="hook_new hook_edit hook_create hook_remove hook_up hook_down \ hook_hotplug hook_hotplug_rename hook_info hook_status" -HOOK_COMMANDS_ZONE="hook_add hook_create hook_discover hook_down hook_edit hook_help \ - hook_info hook_remove hook_status hook_up hook_hotplug \ +HOOK_COMMANDS_ZONE="hook_add hook_new hook_discover hook_down hook_edit hook_help \ + hook_info hook_destroy hook_status hook_up hook_hotplug \ \ hook_config_create hook_config_edit hook_config_remove hook_config_show \ \ diff --git a/src/functions/functions.zone b/src/functions/functions.zone index bf156dc9..b10ea7b8 100644 --- a/src/functions/functions.zone +++ b/src/functions/functions.zone @@ -213,7 +213,7 @@ function zone_cmd() { hook_exec zone "${hook}" "${cmd}" "${zone}" $@ } -function zone_create() { +function zone_new() { local zone=${1} local hook=${2} shift 2 @@ -238,13 +238,13 @@ function zone_create() { # Create directories for configs and ports mkdir -p $(zone_dir ${zone})/{configs,ports} - hook_zone_exec ${hook} create ${zone} $@ + hook_zone_exec "${hook}" "new" "${zone}" $@ local ret=$? - # Maybe the zone create hook did not exit correctly. + # Maybe the zone new hook did not exit correctly. # If this is the case we remove the created zone immediately. if [ "${ret}" = "${EXIT_ERROR}" ]; then - zone_remove_now ${zone} + zone_destroy_now "${zone}" return ${EXIT_ERROR} fi @@ -262,7 +262,7 @@ function zone_edit() { fi # Check if the zone is tagged for removal. - if zone_has_remove_tag ${zone}; then + if zone_has_destroy_tag ${zone}; then error "You cannot edit a zone that is tagged for removal." return ${EXIT_ERROR} fi @@ -282,39 +282,39 @@ function zone_edit() { } -function zone_remove() { - local zone=${1} - assert zone_exists ${zone} +function zone_destroy() { + local zone="${1}" + assert zone_exists "${zone}" # Make the zone for removal. - touch $(zone_dir ${zone})/.remove + touch "$(zone_dir "${zone}")/.destroy" log INFO "Zone '${zone}' has been tagged for removal." } -function zone_has_remove_tag() { - local zone=${1} - assert zone_exists ${zone} +function zone_has_destroy_tag() { + local zone="${1}" + assert zone_exists "${zone}" - [ -e "$(zone_dir ${zone})/.remove" ] + [ -e "$(zone_dir "${zone}")/.destroy" ] } # This function will remove the given zone -# RIGHT NOW. Use zone_remove to remove it +# RIGHT NOW. Use zone_destroy to remove it # at the next status change. -function zone_remove_now() { - local zone=${1} - assert zone_exists ${zone} +function zone_destroy_now() { + local zone="${1}" + assert zone_exists "${zone}" log INFO "Removing zone '${zone}' right now." # Force the zone down. - zone_is_up ${zone} && zone_set_down ${zone} + zone_is_up "${zone}" && zone_set_down "${zone}" # Disable zone. zone_disable "${zone}" - rm -rf $(zone_dir ${zone}) + rm -rf "$(zone_dir "${zone}")" } function zone_up() { @@ -377,8 +377,8 @@ function zone_down() { zone_db ${zone} stopped # Remove the zone, if it has got a remove tag. - if zone_has_remove_tag ${zone}; then - zone_remove_now ${zone} + if zone_has_destroy_tag "${zone}"; then + zone_destroy_now "${zone}" fi } diff --git a/src/header-zone b/src/header-zone index 996d0ac9..a9e1ebef 100644 --- a/src/header-zone +++ b/src/header-zone @@ -29,7 +29,7 @@ function hook_hotplug() { exit ${EXIT_NOT_HANDLED} } -function hook_create() { +function hook_new() { local zone="${1}" assert isset zone shift diff --git a/src/network b/src/network index 81bb3bb5..27f16c67 100644 --- a/src/network +++ b/src/network @@ -540,11 +540,11 @@ function cli_zone() { shift case "${action}" in - create) - zone_${action} $@ + new) + zone_new $@ ;; - remove) - cli_zone_remove $@ + destroy) + cli_zone_destroy $@ ;; list-hooks) cli_list_hooks zone $@ @@ -565,21 +565,21 @@ function cli_zone() { # Removes a zone either immediately, if it is currently down, # or adds a tag that the removal will be done when the zone # is brought down the next time. -function cli_zone_remove() { +function cli_zone_destroy() { if cli_help_requested $@; then cli_show_man network-zone exit ${EXIT_OK} fi - local zone=${1} - assert zone_exists ${zone} + local zone="${1}" + assert zone_exists "${zone}" if zone_is_up ${zone}; then echo "Zone '${zone}' is up and will be removed when it goes down the next time." - zone_remove ${zone} + zone_destroy "${zone}" else echo "Removing zone '${zone}' now..." - zone_remove_now ${zone} + zone_destroy_now "${zone}" fi exit ${EXIT_OK} @@ -1040,7 +1040,7 @@ function cli_reset() { local zone for zone in $(zones_get --all); do - zone_remove ${zone} + zone_destroy_now "${zone}" done local port