add support for docker-based 'mocha suv new'

This commit is contained in:
Michael Becker 2025-03-25 15:20:18 -04:00
parent 94079220a5
commit fcb4817b69

View File

@ -5,6 +5,7 @@
# mocha suv down # mocha suv down
# mocha suv new # mocha suv new
USE_VAGRANT="false" USE_VAGRANT="false"
VAGRANT_MOCHADIR=~/Documents/Vagrant/mocha VAGRANT_MOCHADIR=~/Documents/Vagrant/mocha
VAGRANT_MACHINESDIR=$VAGRANT_MOCHADIR/machines VAGRANT_MACHINESDIR=$VAGRANT_MOCHADIR/machines
@ -288,20 +289,55 @@ elif [ "$1" == "delete" ]; then
elif [ "$1" == "new" ]; then elif [ "$1" == "new" ]; then
cd $VAGRANT_MOCHADIR shift;
BGS="" BACKEND="vagrant"
if [ "$USE_VAGRANT" == "true" ]; then
BGS="$BGS --use-vagrant" while true; do
fi case "$1" in
if [ "$2" == "--transient" ]; then -b | --backend ) BACKEND="$2"; shift 2 ;;
BGS="$BGS --transient" -- ) shift; break ;;
fi * ) break ;;
if [ "$2" == "--unattended" ]; then esac
BGS="$BGS --unattended" done
fi
./provision $BGS if [ "$BACKEND" == "vagrant" ]; then
command -v vagrant 2>&1 >/dev/null
Q=$?
if [ $Q -eq 1 ]; then
echo "error: backend 'vagrant' not found"
else
cd $VAGRANT_MOCHADIR
BGS=""
if [ "$USE_VAGRANT" == "true" ]; then
BGS="$BGS --use-vagrant"
fi
if [ "$2" == "--transient" ]; then
BGS="$BGS --transient"
fi
if [ "$2" == "--unattended" ]; then
BGS="$BGS --unattended"
fi
./provision $BGS
fi
elif [ "$BACKEND" == "docker" ]; then
/usr/lib/mocha/docker/docker-run
else
echo "unknown backend '$BACKEND'"
fi
else else
echo "usage: mocha suv new [--transient] | (up|down|shell|delete MACHINENAME) | list" echo "usage: mocha suv new [--transient] | (up|down|shell|delete MACHINENAME) | list"