diff --git a/mocha-suv/common/libexec/mocha-suv b/mocha-suv/common/libexec/mocha-suv index 953f9bc..f74917f 100755 --- a/mocha-suv/common/libexec/mocha-suv +++ b/mocha-suv/common/libexec/mocha-suv @@ -78,12 +78,15 @@ elif [ "$1" == "delete" ]; then elif [ "$1" == "new" ]; then cd $VAGRANT_MOCHADIR - + + BGS="" if [ "$2" == "--transient" ]; then - ./provision --transient - else - ./provision + BGS="$BGS --transient" fi + if [ "$2" == "--unattended" ]; then + BGS="$BGS --unattended" + fi + ./provision $BGS else echo "usage: mocha suv new [--transient] | (up|down|shell|delete MACHINENAME) | list" diff --git a/mocha-suv/provision b/mocha-suv/provision index 635987c..803b993 100755 --- a/mocha-suv/provision +++ b/mocha-suv/provision @@ -15,16 +15,22 @@ SUV_IP_LAST=$(shuf -i 10-200 -n 1) SUV_IP=$SUV_IP_PREFIX.$SUV_IP_FIRST.$SUV_IP_LAST SUV_ALWAYS_PROVISION="false" +SUV_UNATTENDED="false" if [ "$1" == "--transient" ]; then shift - + SUV_ALWAYS_PROVISION="true" echo "initializing new TRANSIENT Mocha SUV with id $SUV_NAME" else echo "initializing new PERSISTENT Mocha SUV with id $SUV_NAME" fi +if [ "$1" == "--unattended" ]; then + SUV_UNATTENDED="true" + shift +fi + SUV_TEMPLATE="default" if [ "$1" != "" ]; then @@ -61,12 +67,14 @@ ln -s ../../../mocha-php/mocha-php/src/mocha-php ./site ln -s ../../../mocha-common/mocha-common/data/libraries/yaml ./libraries ln -s ../../../mocha-common/mocha-common/data/uploads ./uploads -echo "enter sudo password to add entry to /etc/hosts if desired" - SUV_DNS="" -echo "$SUV_IP $SUV_NAME$SUV_DOMAINNAME" | sudo tee -a /etc/hosts -if [ $? == "0" ]; then - SUV_DNS="$SUV_NAME$SUV_DOMAINNAME" + +if [ "$SUV_UNATTENDED" == "false" ]; then + echo "enter sudo password to add entry to /etc/hosts if desired" + echo "$SUV_IP $SUV_NAME$SUV_DOMAINNAME" | sudo tee -a /etc/hosts + if [ $? == "0" ]; then + SUV_DNS="$SUV_NAME$SUV_DOMAINNAME" + fi fi if [ "$SUV_DNS" != "" ]; then @@ -79,3 +87,8 @@ sed -i -e "s/@@MOCHA_SUV_ID@@/$SUV_NAME/" -e "s/@@MOCHA_SUV_ADDRESS@@/$SUV_IP/" vagrant up +if [ "$?" != "0" ]; then + rm -rf ../$SUV_NAME + + exit 127 +fi