aboutsummaryrefslogtreecommitdiff
path: root/kvmx
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-06-21 12:49:16 -0300
committerSilvio Rhatto <rhatto@riseup.net>2018-06-21 12:49:16 -0300
commit229085524ce21fb72dd07530a2d8bba474fe3872 (patch)
tree17c0ce607aec75eec2d65a6d544d069b7801309b /kvmx
parent489c92b764cf372e319659dc43cd18c5679d58e3 (diff)
downloadkvmx-229085524ce21fb72dd07530a2d8bba474fe3872.tar.gz
kvmx-229085524ce21fb72dd07530a2d8bba474fe3872.tar.bz2
Misc enhancements: show available ISOs at install usage, make 'boot' be an alias to 'install' and display exit codes at kvmx-shell
Diffstat (limited to 'kvmx')
-rwxr-xr-xkvmx29
1 files changed, 27 insertions, 2 deletions
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 <installation-media>"
+
+ # 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