support multiple backends; e.g. lxc

This commit is contained in:
Michael Becker 2024-12-23 00:44:57 -05:00
parent a81a816d2e
commit 5cb9126e7f

View File

@ -16,7 +16,13 @@ SUV_IP=$SUV_IP_PREFIX.$SUV_IP_FIRST.$SUV_IP_LAST
SUV_ALWAYS_PROVISION="false" SUV_ALWAYS_PROVISION="false"
SUV_UNATTENDED="false" SUV_UNATTENDED="false"
USE_VAGRANT="false" BACKEND="virtualbox"
if [ "$1" == "--backend" ]; then
BACKEND="$2"
shift
shift
fi
if [ "$1" == "--transient" ]; then if [ "$1" == "--transient" ]; then
shift shift
@ -32,10 +38,6 @@ if [ "$1" == "--unattended" ]; then
shift shift
fi fi
if [ "$1" == "--use-vagrant" ]; then
USE_VAGRANT="true"
fi
SUV_TEMPLATE="default" SUV_TEMPLATE="default"
if [ "$1" != "" ]; then if [ "$1" != "" ]; then
@ -90,11 +92,11 @@ fi
sed -i -e "s/@@MOCHA_SUV_ID@@/$SUV_NAME/" -e "s/@@MOCHA_SUV_ADDRESS@@/$SUV_IP/" -e "s/@@MOCHA_SUV_HOSTNAME@@/$SUV_IP_OR_DNS/" -e "s/@@MOCHA_ALWAYS_PROVISION@@/$SUV_ALWAYS_PROVISION/" ./Vagrantfile sed -i -e "s/@@MOCHA_SUV_ID@@/$SUV_NAME/" -e "s/@@MOCHA_SUV_ADDRESS@@/$SUV_IP/" -e "s/@@MOCHA_SUV_HOSTNAME@@/$SUV_IP_OR_DNS/" -e "s/@@MOCHA_ALWAYS_PROVISION@@/$SUV_ALWAYS_PROVISION/" ./Vagrantfile
if [ "$USE_VAGRANT" == "true" ]; then if [ "$BACKEND" == "vagrant" ]; then
vagrant up vagrant up
else elif [ "$BACKEND" == "virtualbox" ]; then
# create a new Host-Only Network Interface # create a new Host-Only Network Interface
HOIFNAME=$(VBoxManage hostonlyif create | grep -o -P "(?<=').*(?=')" ) HOIFNAME=$(VBoxManage hostonlyif create | grep -o -P "(?<=').*(?=')" )
@ -107,6 +109,10 @@ else
# assign the newly-created Host-Only Network Interface to the newly-created VM # assign the newly-created Host-Only Network Interface to the newly-created VM
VBoxManage modifyvm mochasuv-$SUV_NAME --nic2=hostonly --host-only-adapter2=$HOIFNAME VBoxManage modifyvm mochasuv-$SUV_NAME --nic2=hostonly --host-only-adapter2=$HOIFNAME
else
echo "backend not supported: $BACKEND"
fi fi
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then