X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=functions.cli;h=a2ceb99e42df525c881fd3af9fcaeff95d69a550;hb=8a4ccede806c4888a95a3628d07c0989913ed477;hp=9339a7bc2f0690b689dd9bf00cbb80bcde233201;hpb=866de228a4bbbe76e4ec26dfbb5549ea0845eace;p=people%2Farne_f%2Fnetwork.git diff --git a/functions.cli b/functions.cli index 9339a7bc..a2ceb99e 100644 --- a/functions.cli +++ b/functions.cli @@ -33,44 +33,32 @@ function cli_config() { } function cli_device() { - if device_config_exists ${1}; then - local device=${1} - local action=${2} - shift 2 + local device=${1} + local action=${2} + shift 2 - case "${action}" in - down|up) - device_${action} ${device} $@ - ;; - esac - else - local action=${1} - shift + assert device_exists ${device} - case "${action}" in - create) - device_${action} $@ - ;; + if zone_exists ${device} || port_exists ${device}; then + error "The device '${device}' has already been configured." + error "You cannot do a device action." + return ${EXIT_ERROR} + fi - discover) - echo "# XXX need to implement --raw here" - local device - for device in ${devices}; do - cli_device_discover ${device} $@ - done - ;; + case "${action}" in + discover) + echo "# XXX need to implement --raw here" + cli_device_discover ${device} $@ + ;; - show|"") - local device - for device in $(device_get $@); do - device_print ${device} - done - ;; - *) - cli_usage device - ;; - esac - fi + show|"") + # XXX device_show needs to be implemented + device_show ${device} + ;; + *) + cli_usage device + ;; + esac } function cli_device_discover() { @@ -348,7 +336,8 @@ function cli_reset() { port_remove ${port} done - # XXX recreate ethernet ports + # Re-run the initialization functions + init_run exit ${EXIT_OK} } @@ -505,3 +494,12 @@ function cli_yesno() { return ${EXIT_ERROR} } + +function cli_get_key() { + local key="${1%%=*}" + echo "${key/--/}" +} + +function cli_get_val() { + echo "${1##*=}" +}