summaryrefslogtreecommitdiff
path: root/etc/bash_completion.d/20vyatta-cfg
diff options
context:
space:
mode:
authorrbalocca <rbalocca@vyatta.com>2008-06-29 18:05:08 -0700
committerrbalocca <rbalocca@vyatta.com>2008-06-29 18:05:08 -0700
commit7db066e99a5e9c3b41ce30d19b9781b1a8df8d44 (patch)
tree75da49d74a9da7cb6df98651ef511ddd12a42790 /etc/bash_completion.d/20vyatta-cfg
parentdd1921164c972be0333d8b90f7c12f31f67a136e (diff)
parent3b1043be67c60220c107e42998635c628eb84393 (diff)
downloadvyatta-cfg-7db066e99a5e9c3b41ce30d19b9781b1a8df8d44.tar.gz
vyatta-cfg-7db066e99a5e9c3b41ce30d19b9781b1a8df8d44.zip
Merge branch 'hollywood'
Diffstat (limited to 'etc/bash_completion.d/20vyatta-cfg')
-rwxr-xr-xetc/bash_completion.d/20vyatta-cfg90
1 files changed, 90 insertions, 0 deletions
diff --git a/etc/bash_completion.d/20vyatta-cfg b/etc/bash_completion.d/20vyatta-cfg
index f979939..f1d100e 100755
--- a/etc/bash_completion.d/20vyatta-cfg
+++ b/etc/bash_completion.d/20vyatta-cfg
@@ -66,10 +66,38 @@ save ()
\"umask 0002 ; ${vyatta_sbindir}/vyatta-save-config.pl $@\""
}
+discard ()
+{
+ local changes
+ if [ -f "$VYATTA_TEMP_CONFIG_DIR/$VYATTA_MOD_NAME" ]; then
+ changes=1
+ else
+ changes=0
+ fi
+
+ sudo umount ${VYATTA_TEMP_CONFIG_DIR};
+ sudo rm -fr ${VYATTA_CHANGES_ONLY_DIR};
+ sudo mkdir -p ${VYATTA_CHANGES_ONLY_DIR};
+ sudo mount -t unionfs -o dirs=${VYATTA_CHANGES_ONLY_DIR}=rw:${VYATTA_ACTIVE_CONFIGURATION_DIR}=ro unionfs ${VYATTA_TEMP_CONFIG_DIR};
+
+ if (( changes )); then
+ echo "Changes have been discarded"
+ else
+ echo "No changes have been discarded"
+ fi
+
+}
+
+reboot ()
+{
+ echo "Exit from configure mode before rebooting."
+}
+
declare vyatta_cfg_prompt_level=''
set_config_ps1 ()
{
local level=$1
+ vyatta_unescape level level
if [ -z "$level" ]; then
export PS1="[edit]\n\u@\h# "
vyatta_cfg_prompt_level=''
@@ -107,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=${#@}
@@ -726,6 +814,7 @@ vyatta_config_complete ()
if (( ${#COMP_WORDS[@]} < 2 )); then
declare -a hitems=( "commit" \
"delete" \
+ "discard" \
"edit" \
"exit" \
"load" \
@@ -736,6 +825,7 @@ vyatta_config_complete ()
declare -a hstrs=( \
"Commit the current set of changes" \
"Delete a configuration element" \
+ "Discard uncommitted changes" \
"Edit a sub-element" \
"Exit from this configuration level" \
"Load configuration from a file" \