#!/bin/bash # Exit immediately if anything goes wrong, instead of making things worse. set -e # set a flag to tell shared_functions.sh how to SSH to machines export BOOTSTRAP_METHOD=vagrant echo " ____ ____ ____ ____ " echo "| __ ) / ___| _ \ / ___|" echo "| _ \| | | |_) | | " echo "| |_) | |___| __/| |___ " echo "|____/ \____|_| \____|" echo echo "BCPC Vagrant BootstrapV2 0.2" echo "--------------------------------------------" echo "Bootstrapping local Vagrant environment..." while getopts "v" opt { matchstr $opt { # verbose v { set -x } } } # Source common bootstrap functions. This is the only place that uses a # relative path; everything henceforth must use $REPO_ROOT. source ../shared/shared_functions.sh export REPO_ROOT=$REPO_ROOT load_configs # Perform preflight checks to validate environment sanity as much as possible. echo "Performing preflight environment validation..." source $REPO_ROOT/bootstrap/shared/shared_validate_env.sh # Test that Vagrant is really installed and of an appropriate version. echo "Checking VirtualBox and Vagrant..." source $REPO_ROOT/bootstrap/vagrant_scripts/vagrant_test.sh # Do prerequisite work prior to starting build, downloading files and # creating local directories. Proxy configuration is handled there as well. echo "Downloading necessary files to local cache..." source $REPO_ROOT/bootstrap/shared/shared_prereqs.sh # Terminate existing BCPC VMs. echo "Shutting down and unregistering VMs from VirtualBox..." $REPO_ROOT/bootstrap/vagrant_scripts/vagrant_clean.sh # Create VMs in Vagrant and start them. echo "Starting local Vagrant cluster..." $REPO_ROOT/bootstrap/vagrant_scripts/vagrant_create.sh # Install and configure Chef on all Vagrant hosts. echo "Installing and configuring Chef on all nodes..." $REPO_ROOT/bootstrap/shared/shared_configure_chef.sh # Dump out useful information for users. $REPO_ROOT/bootstrap/vagrant_scripts/vagrant_print_useful_info.sh echo "Finished in $SECONDS seconds" (CommandList children: [ (C {(set)} {(-e)}) (C {(export)} {(Lit_VarLike "BOOTSTRAP_METHOD=") (vagrant)}) (C {(echo)} {(DQ (" ____ ____ ____ ____ "))}) (C {(echo)} {(DQ ("| __ ) / ___| _ ") (EscapedLiteralPart token:) ("/ ___|"))} ) (C {(echo)} {(DQ ("| _ ") (EscapedLiteralPart token:) (" | | |_) | | "))} ) (C {(echo)} {(DQ ("| |_) | |___| __/| |___ "))}) (C {(echo)} { (DQ ("|____/ ") (EscapedLiteralPart token:) ("___|_| ") (EscapedLiteralPart token:) ("___|") ) } ) (C {(echo)}) (C {(echo)} {(DQ ("BCPC Vagrant BootstrapV2 0.2"))}) (C {(echo)} {(DQ (--------------------------------------------))}) (C {(echo)} {(DQ ("Bootstrapping local Vagrant environment..."))}) (While cond: [(Sentence child:(C {(getopts)} {(DQ (v))} {(opt)}) terminator:)] body: (DoGroup children: [ (Case to_match: {($ VSub_Name "$opt")} arms: [(case_arm pat_list:[{(v)}] action:[(C {(set)} {(-x)})] spids:[104105113-1])] spids: [93 97 116] ) ] spids: [90 118] ) ) (C {(source)} {(../shared/shared_functions.sh)}) (C {(export)} {(Lit_VarLike "REPO_ROOT=") ($ VSub_Name "$REPO_ROOT")}) (C {(load_configs)}) (C {(echo)} {(DQ ("Performing preflight environment validation..."))}) (C {(source)} {($ VSub_Name "$REPO_ROOT") (/bootstrap/shared/shared_validate_env.sh)}) (C {(echo)} {(DQ ("Checking VirtualBox and Vagrant..."))}) (C {(source)} {($ VSub_Name "$REPO_ROOT") (/bootstrap/vagrant_scripts/vagrant_test.sh)}) (C {(echo)} {(DQ ("Downloading necessary files to local cache..."))}) (C {(source)} {($ VSub_Name "$REPO_ROOT") (/bootstrap/shared/shared_prereqs.sh)}) (C {(echo)} {(DQ ("Shutting down and unregistering VMs from VirtualBox..."))}) (C {($ VSub_Name "$REPO_ROOT") (/bootstrap/vagrant_scripts/vagrant_clean.sh)}) (C {(echo)} {(DQ ("Starting local Vagrant cluster..."))}) (C {($ VSub_Name "$REPO_ROOT") (/bootstrap/vagrant_scripts/vagrant_create.sh)}) (C {(echo)} {(DQ ("Installing and configuring Chef on all nodes..."))}) (C {($ VSub_Name "$REPO_ROOT") (/bootstrap/shared/shared_configure_chef.sh)}) (C {($ VSub_Name "$REPO_ROOT") (/bootstrap/vagrant_scripts/vagrant_print_useful_info.sh)}) (C {(echo)} {(DQ ("Finished in ") ($ VSub_Name "$SECONDS") (" seconds"))}) ] )