add 'show' command

This commit is contained in:
Michael Becker 2025-07-16 18:35:46 -04:00
parent fcb4817b69
commit 17fe649353
2 changed files with 43 additions and 6 deletions

View File

@ -193,6 +193,11 @@ elif [ "$1" == "up" ]; then
echo "usage: mocha suv up MACHINENAME"
fi
elif [ "$1" == "show" ]; then
URL="https://$2.privatesuv.com"
xdg-open "$URL"
elif [ "$1" == "down" ]; then
if [ "$2" != "" ]; then
@ -209,7 +214,36 @@ elif [ "$1" == "down" ]; then
else
VBoxManage controlvm "mochasuv-$2" poweroff &
EXISTS=$(VBoxManage list vms | grep 'mochasuv-$2')
if [ "$EXISTS" != "" ]; then
# is VBox VM
VBoxManage controlvm "mochasuv-$2" poweroff &
else
EXISTS=$(echo "$LXC_VMS" | grep $2)
if [ "$EXISTS" != "" ]; then
# LXC container found, start it
lxc stop $2
else
# last chance, maybe we used Docker
EXISTS=$(echo "$DOCKER_VMS_RUNNING" | grep $2)
if [ "$EXISTS" != "" ]; then
docker container stop $2
else
exit 127
fi
fi
fi
fi
@ -291,10 +325,12 @@ elif [ "$1" == "new" ]; then
shift;
BACKEND="vagrant"
BACKEND="docker"
UNATTENDED="0"
while true; do
case "$1" in
--unattended ) UNATTENDED="1"; shift ;;
-b | --backend ) BACKEND="$2"; shift 2 ;;
-- ) shift; break ;;
* ) break ;;
@ -331,7 +367,8 @@ elif [ "$1" == "new" ]; then
elif [ "$BACKEND" == "docker" ]; then
/usr/lib/mocha/docker/docker-run
cd /usr/lib/mocha/docker
./docker-run
else

View File

@ -20,10 +20,10 @@ _mocha()
return 0
;;
suv)
COMPREPLY=( $( compgen -W "new up down delete shell status list" -- "$cur" ) )
COMPREPLY=( $( compgen -W "new up down show delete shell status list" -- "$cur" ) )
return 0
;;
up|down|delete|shell|status)
up|down|show|delete|shell|status)
COMPREPLY=( $( compgen -W "$(mocha suv list)" -- "$cur" ) )
return 0
;;