various fixes

This commit is contained in:
kneutron 2022-05-20 15:46:16 -05:00 committed by GitHub
parent 212360e56e
commit 22f837edf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,7 +41,11 @@ function startvm () {
if [ "$1" = "s" ] || [ "$1" = "" ]; then
# select ; REF: https://www.baeldung.com/linux/reading-output-into-array
runtest=$($vbm list runningvms)
[ "$runtest" = "" ] && failexit 44 "No VMs are running under ID $(whoami)"
if [ "$runtest" = "" ]; then
echo "FYI: No VMs are currently running under ID $(whoami)"
else
echo "( $(echo "$runtest" |grep -c \}) ) VMs are currently running" # ya, its a hack :B
fi
OIFS=$IFS
IFS=$'\n'
@ -49,6 +53,8 @@ if [ "$1" = "s" ] || [ "$1" = "" ]; then
declare -a vmlist=( $($vbm list vms |tr -d '"' |sort) )
#LiveCD--64 {hexnum}
maxvmnum=${#vmlist[@]} # of elements in array
IFS=$OIFS
echo "o-> Utility to change the state of a virtualbox VM - stop if running, start if not running <-o"
@ -85,7 +91,6 @@ elif [ $test4comma -gt 0 ]; then
# self-shortening loop, like bash "shift"
stopafterme=0
maxvmnum=${#vmlist[@]} # of elements in array
while [ ${#procthese} -gt 0 ]; do
# check length
@ -169,3 +174,5 @@ exit;
# In all cases we should pass the UUID to stop/start in case of dup vm names to avoid confusion...
# + standardized date format in logfile
# fixed single-vm treatment, check if single-vm index number outside known, dont failexit if no vms are running