diff options
Diffstat (limited to 'etc')
-rwxr-xr-x | etc/bash_completion.d/20vyatta-cfg | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/etc/bash_completion.d/20vyatta-cfg b/etc/bash_completion.d/20vyatta-cfg index d77c933..d501019 100755 --- a/etc/bash_completion.d/20vyatta-cfg +++ b/etc/bash_completion.d/20vyatta-cfg @@ -135,6 +135,66 @@ top () set_config_ps1 '' } +rename() +{ + mvcp rename Rename mv "$@" +} + +copy() +{ + mvcp copy Copy "cp -a" "$@" +} + +mvcp () +{ + local str=$1 + shift + local Str=$1 + shift + local cmd=$1 + shift + local _otag=$1 + local _ovalu=$2 + local _to=$3 + local _ntag=$4 + local _nvalu=$5 + local _oval='' + local _nval='' + local _mpath=${VYATTA_TEMP_CONFIG_DIR}/${VYATTA_EDIT_LEVEL} + local _tpath=${VYATTA_CONFIG_TEMPLATE}/${VYATTA_TEMPLATE_LEVEL} + vyatta_escape _ovalu _oval + vyatta_escape _nvalu _nval + if [ "$_to" != 'to' ] || [ -z "$_ntag" ] || [ -z "$_nval" ]; then + echo "Invalid $str command" + return 1 + fi + if [ "$_otag" != "$_ntag" ]; then + echo "Cannot $str from \"$_otag\" to \"$_ntag\"" + return 1 + fi + if [ ! -d "$_tpath/$_otag/$VYATTA_TAG_NAME" ]; then + echo "Cannot $str under \"$_otag\"" + return 1 + fi + if [ ! -d "$_mpath/$_otag/$_oval" ]; then + echo "Configuration \"$_otag $_ovalu\" does not exist" + return 1 + fi + if [ -d "$_mpath/$_ntag/$_nval" ]; then + echo "Configuration \"$_ntag $_nvalu\" already exists" + return 1 + fi + if ! /opt/vyatta/sbin/my_set $_ntag "$_nvalu"; then + echo "$Str failed" + return 1 + fi + /opt/vyatta/sbin/my_delete $_ntag "$_nvalu" >&/dev/null 3>&1 + + $cmd "$_mpath/$_otag/$_oval" "$_mpath/$_ntag/$_nval" + + return 0 +} + edit () { local num_comp=${#@} |