summaryrefslogtreecommitdiff
path: root/etc/bash_completion.d/20vyatta-cfg
diff options
context:
space:
mode:
authorAn-Cheng Huang <ancheng@vyatta.com>2008-06-18 19:17:19 -0700
committerAn-Cheng Huang <ancheng@vyatta.com>2008-06-18 19:17:19 -0700
commit2b12e94e3f19b694808fb2513f8e2a1e08eaec2d (patch)
treef317444b3635996ae2a7a0688234bf477ec596c0 /etc/bash_completion.d/20vyatta-cfg
parent9ecac28234e11b5df607fe338fdebc8956c9e349 (diff)
downloadvyatta-cfg-2b12e94e3f19b694808fb2513f8e2a1e08eaec2d.tar.gz
vyatta-cfg-2b12e94e3f19b694808fb2513f8e2a1e08eaec2d.zip
fix for bug 2622: add "copy" and "rename" commands for configuration mode.
Diffstat (limited to 'etc/bash_completion.d/20vyatta-cfg')
-rwxr-xr-xetc/bash_completion.d/20vyatta-cfg60
1 files changed, 60 insertions, 0 deletions
diff --git a/etc/bash_completion.d/20vyatta-cfg b/etc/bash_completion.d/20vyatta-cfg
index 102ce8f..c7e9ed7 100755
--- a/etc/bash_completion.d/20vyatta-cfg
+++ b/etc/bash_completion.d/20vyatta-cfg
@@ -113,6 +113,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=${#@}