From 5cb9126e7f9f2956e5d61c4f186fb935a98fa5c7 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Mon, 23 Dec 2024 00:44:57 -0500 Subject: [PATCH] support multiple backends; e.g. lxc --- mocha-suv/provision | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/mocha-suv/provision b/mocha-suv/provision index cdebc1f..ca5d739 100755 --- a/mocha-suv/provision +++ b/mocha-suv/provision @@ -16,7 +16,13 @@ SUV_IP=$SUV_IP_PREFIX.$SUV_IP_FIRST.$SUV_IP_LAST SUV_ALWAYS_PROVISION="false" SUV_UNATTENDED="false" -USE_VAGRANT="false" +BACKEND="virtualbox" + +if [ "$1" == "--backend" ]; then + BACKEND="$2" + shift + shift +fi if [ "$1" == "--transient" ]; then shift @@ -32,10 +38,6 @@ if [ "$1" == "--unattended" ]; then shift fi -if [ "$1" == "--use-vagrant" ]; then - USE_VAGRANT="true" -fi - SUV_TEMPLATE="default" 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 -if [ "$USE_VAGRANT" == "true" ]; then +if [ "$BACKEND" == "vagrant" ]; then vagrant up -else +elif [ "$BACKEND" == "virtualbox" ]; then # create a new Host-Only Network Interface 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 VBoxManage modifyvm mochasuv-$SUV_NAME --nic2=hostonly --host-only-adapter2=$HOIFNAME +else + + echo "backend not supported: $BACKEND" + fi if [ "$?" != "0" ]; then