diff --git a/.gitignore b/.gitignore index e7f20f0..02eab18 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ # Provisioned SUVs machines/ +*.swp + diff --git a/docker-build b/docker-build new file mode 100755 index 0000000..76bcc14 --- /dev/null +++ b/docker-build @@ -0,0 +1,17 @@ +#!/bin/bash + +# generate random UUID for new SUV +# thanks https://stackoverflow.com/questions/34328759 +SUV_ID=$(hexdump -vn8 -e'2/4 "%08x" 1 "\n"' /dev/urandom) +SUV_NAME=i-0$SUV_ID + +# build the image (i.e. 'mocha suv init' ) +docker build -t mocha-httpd -f mocha-suv/docker/Dockerfile . + +# initiate a container (i.e. 'mocha suv up i-0...' ) +docker run --name $SUV_NAME -d --net mocha-docker -it mocha-httpd # -p 8000:80 mocha-httpd + +echo "waiting for network to settle..." +sleep 3 + +docker inspect $SUV_NAME diff --git a/mocha-common b/mocha-common index 54d5ab8..569e302 160000 --- a/mocha-common +++ b/mocha-common @@ -1 +1 @@ -Subproject commit 54d5ab8b2c37bb9139eb6800631eece9b60ee25a +Subproject commit 569e302f3000e236ba562f17bc83d9e70a54fbf5 diff --git a/mocha-suv/configure b/mocha-suv/configure index c17f24f..a4dc359 100644 --- a/mocha-suv/configure +++ b/mocha-suv/configure @@ -1,6 +1,21 @@ # mocha-suv post-installation configuration script # to be run on the SUV virtual machine (if building manually) +# set to 0 if we already have an installed SUV or CUP +FULL=1 + +if [ $FULL -eq 1 ]; then + # update the package repository and install required packages + apt update + # !!! NOTE: we are no longer requiring mysql for Mocha if we use the mocha-dotnet OMS + apt install apache2 php pwgen + + apt install dotnet-runtime-8.0 + + mkdir -p /usr/share/mocha/system + +fi + ENABLE_SSL=1 if [ $ENABLE_SSL -eq 1 ]; then diff --git a/mocha-suv/docker/Dockerfile b/mocha-suv/docker/Dockerfile new file mode 100644 index 0000000..e3193cb --- /dev/null +++ b/mocha-suv/docker/Dockerfile @@ -0,0 +1,7 @@ +FROM httpd + +RUN apt update && apt upgrade && apt install -y php php-mbstring php-curl php-xml pwgen +RUN rm /usr/local/apache2/htdocs/index.html + +COPY mocha-php/mocha-php/src/mocha-php /usr/local/apache2/htdocs/ + 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