From e1068de05de78e9a384b6f3740f8ee5bf5b3d41b Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Tue, 29 Apr 2008 16:43:21 -0700 Subject: partial fix for bug 3216: display escaped edit path correctly. --- etc/bash_completion.d/20vyatta-cfg | 1 + 1 file changed, 1 insertion(+) (limited to 'etc/bash_completion.d') diff --git a/etc/bash_completion.d/20vyatta-cfg b/etc/bash_completion.d/20vyatta-cfg index f979939..fb2b142 100755 --- a/etc/bash_completion.d/20vyatta-cfg +++ b/etc/bash_completion.d/20vyatta-cfg @@ -70,6 +70,7 @@ 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='' -- cgit v1.2.3 From 4f12bac0dd00c1471fa8b1c6cf677e3a7680bc5f Mon Sep 17 00:00:00 2001 From: Stig Thormodsrud Date: Wed, 11 Jun 2008 14:36:35 -0700 Subject: Block reboot from config mode. --- etc/bash_completion.d/20vyatta-cfg | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'etc/bash_completion.d') diff --git a/etc/bash_completion.d/20vyatta-cfg b/etc/bash_completion.d/20vyatta-cfg index fb2b142..102ce8f 100755 --- a/etc/bash_completion.d/20vyatta-cfg +++ b/etc/bash_completion.d/20vyatta-cfg @@ -66,6 +66,11 @@ save () \"umask 0002 ; ${vyatta_sbindir}/vyatta-save-config.pl $@\"" } +reboot () +{ + echo "Exit from configure mode before rebooting." +} + declare vyatta_cfg_prompt_level='' set_config_ps1 () { -- cgit v1.2.3 From 97238661d34432eac6c8df62a28367da941f3e37 Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Tue, 17 Jun 2008 14:06:55 -0700 Subject: fix for bug 110. added discard command to configure mode. This command deletes local changes and keeps the user in configure mode. --- etc/bash_completion.d/20vyatta-cfg | 22 ++++++++++++++++++++++ etc/shell/level/users/allowed-op | 1 + 2 files changed, 23 insertions(+) (limited to 'etc/bash_completion.d') diff --git a/etc/bash_completion.d/20vyatta-cfg b/etc/bash_completion.d/20vyatta-cfg index 102ce8f..d77c933 100755 --- a/etc/bash_completion.d/20vyatta-cfg +++ b/etc/bash_completion.d/20vyatta-cfg @@ -66,6 +66,28 @@ 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}; + rm -fr ${VYATTA_CHANGES_ONLY_DIR}; + 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." diff --git a/etc/shell/level/users/allowed-op b/etc/shell/level/users/allowed-op index 724c235..5b997da 100644 --- a/etc/shell/level/users/allowed-op +++ b/etc/shell/level/users/allowed-op @@ -1,3 +1,4 @@ +discard clear debug exit -- cgit v1.2.3 From 2b12e94e3f19b694808fb2513f8e2a1e08eaec2d Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Wed, 18 Jun 2008 19:17:19 -0700 Subject: fix for bug 2622: add "copy" and "rename" commands for configuration mode. --- etc/bash_completion.d/20vyatta-cfg | 60 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'etc/bash_completion.d') 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=${#@} -- cgit v1.2.3 From 4c0cb014d55882ed769a89d9d630bd1160d4ef54 Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Wed, 25 Jun 2008 11:53:19 -0700 Subject: fixed non-root user access for discard. also moved help string. --- etc/bash_completion.d/20vyatta-cfg | 6 ++++-- etc/shell/level/users/allowed-op | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'etc/bash_completion.d') diff --git a/etc/bash_completion.d/20vyatta-cfg b/etc/bash_completion.d/20vyatta-cfg index d501019..f1d100e 100755 --- a/etc/bash_completion.d/20vyatta-cfg +++ b/etc/bash_completion.d/20vyatta-cfg @@ -76,8 +76,8 @@ discard () fi sudo umount ${VYATTA_TEMP_CONFIG_DIR}; - rm -fr ${VYATTA_CHANGES_ONLY_DIR}; - mkdir -p ${VYATTA_CHANGES_ONLY_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 @@ -814,6 +814,7 @@ vyatta_config_complete () if (( ${#COMP_WORDS[@]} < 2 )); then declare -a hitems=( "commit" \ "delete" \ + "discard" \ "edit" \ "exit" \ "load" \ @@ -824,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" \ diff --git a/etc/shell/level/users/allowed-op b/etc/shell/level/users/allowed-op index 5b997da..724c235 100644 --- a/etc/shell/level/users/allowed-op +++ b/etc/shell/level/users/allowed-op @@ -1,4 +1,3 @@ -discard clear debug exit -- cgit v1.2.3