diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-12-31 15:51:58 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-12-31 15:51:58 -0200 |
commit | 4d78c576128c8be6f5d1756b68ee23edc7bffccd (patch) | |
tree | a00048b4623197176ec1daeea2e74c48fe67b304 | |
parent | 6f2430b389f162cd89b86b771bf801d59a9321db (diff) | |
download | kvmx-4d78c576128c8be6f5d1756b68ee23edc7bffccd.tar.gz kvmx-4d78c576128c8be6f5d1756b68ee23edc7bffccd.tar.bz2 |
Make edit and alias to config action which might get, set and edit config
-rwxr-xr-x | kvmx | 22 |
1 files changed, 15 insertions, 7 deletions
@@ -1057,8 +1057,8 @@ function kvmx_copy { kvmx_clone $* } -# Edit guest config -function kvmx_edit { +# Get, set or edit guest config +function kvmx_config { if [ -z "$1" ]; then if [ -z "$EDITOR" ]; then EDITOR="vi" @@ -1070,15 +1070,18 @@ function kvmx_edit { echo "$BASENAME: $GLOBAL_USER_CONFIG_FOLDER/$VM: file not found." fi else - if [ -z "$2" ]; then - echo "usage: $BASENAME $VM edit $1 <value>" - exit 1 - fi + #if [ -z "$2" ]; then + # echo "usage: $BASENAME $VM edit $1 <value>" + # exit 1 + #fi param="$1" shift - if ! grep -q "^$param=" $GLOBAL_USER_CONFIG_FOLDER/$VM; then + if [ -z "$1" ]; then + grep "^$param=" $GLOBAL_USER_CONFIG_FOLDER/$VM | \ + sed -e 's/="/=/' -e 's/"$//' -e "s/='/=/" -e "s/'$//" -e 's/^.*=//' + elif ! grep -q "^$param=" $GLOBAL_USER_CONFIG_FOLDER/$VM; then echo "$param=\"$*\"" >> $GLOBAL_USER_CONFIG_FOLDER/$VM else sed -i -e "s#^$param=.*#$param=\"$*\"#" $GLOBAL_USER_CONFIG_FOLDER/$VM @@ -1086,6 +1089,11 @@ function kvmx_edit { fi } +# Alias to config +function kvmx_edit { + kvmx_config $* +} + # Stop a guest function kvmx_stop { if kvmx_running; then |