From 229085524ce21fb72dd07530a2d8bba474fe3872 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Thu, 21 Jun 2018 12:49:16 -0300 Subject: Misc enhancements: show available ISOs at install usage, make 'boot' be an alias to 'install' and display exit codes at kvmx-shell --- kvmx | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'kvmx') diff --git a/kvmx b/kvmx index ae1a7cd..6aa1ac4 100755 --- a/kvmx +++ b/kvmx @@ -202,7 +202,8 @@ function __kvmx_initialize { if [ ! -e "$image" ] && [ "$ACTION" != "up" ] && [ "$ACTION" != "provision" ] && [ "$ACTION" != "purge" ] \ && [ "$ACTION" != "destroy" ] && [ "$ACTION" != "install" ] && [ "$ACTION" != "config" ] \ - && [ "$ACTION" != "config_unset" ] && [ "$ACTION" != "create" ] && [ "$ACTION" != "shell" ]; then + && [ "$ACTION" != "config_unset" ] && [ "$ACTION" != "create" ] && [ "$ACTION" != "shell" ] \ + && [ "$ACTION" != "boot" ]; then echo "$BASENAME: file not found: $image" exit 1 fi @@ -1713,6 +1714,22 @@ function kvmx_install { if [ -z "$media" ]; then echo "usage: $BASENAME install $VM " + + # Possible places to find existing ISOs + local candidates="/var/cache/media/distros /usr/local/share/isos" + + for candidate in $candidates; do + if [ -d "$candidate" ]; then + results="`find $candidate -not -iwholename '*.git*' -name '*.iso' | sed -e 's/^/\t/'`" + + if [ ! -z "$results" ]; then + echo "available images at $candidate:" + echo "" + echo -n "$results" + fi + fi + done + exit 1 elif [ ! -e "$media" ]; then echo "$BASENAME: file not found: $media" @@ -1742,6 +1759,11 @@ function kvmx_install { kvmx_up } +# Alias to install +function kvmx_boot { + kvmx_install $* +} + # Serial console function kvmx_console { if ! kvmx_running; then @@ -1806,12 +1828,13 @@ function kvmx_version { # Shell function kvmx_shell { + local last_exit_code="0" local restricted="$1" local restricted_actions=":status:start:stop:poweroff:suspend:resume:console:monitor" restricted_actions="$restricted_actions:wipe:shred:app_base:version:list_image:kill:" # While a "quit" command isn't entered, read STDIN - while read -rep "kvmx:/${USER}@${VM}> " STDIN; do + while read -rep "$last_exist_code kvmx:/${USER}@${VM}> " STDIN; do history -s "$STDIN" if [ "$STDIN" == "quit" ] || [ "$STDIN" == "exit" ] || [ "$STDIN" == "bye" ]; then @@ -1829,9 +1852,11 @@ function kvmx_shell { echo "Allowed commands are only `echo $restricted_actions | tr ':' ' '`" else $APP_BASE/kvmx ${STDIN[0]} $VM ${STDIN[@]:1} + last_exit_code="$?" fi else $APP_BASE/kvmx ${STDIN[0]} $VM ${STDIN[@]:1} + last_exit_code="$?" fi fi done -- cgit v1.2.3