diff --git a/Azure/build_ansible_inventory.sh b/Azure/build_ansible_inventory.sh index e777d45..3ff11a5 100755 --- a/Azure/build_ansible_inventory.sh +++ b/Azure/build_ansible_inventory.sh @@ -18,16 +18,16 @@ if ! which terraform >/dev/null; then exit 1 fi -cd ./Terraform +cd ./Terraform || exit 1 TF_OUTPUT=$(terraform output) -DC_IP=$(echo $TF_OUTPUT | egrep -o "dc_public_ip = ([0-9]{1,3}[\.]){3}[0-9]{1,3}" | cut -d '=' -f 2 | tr -d ' ') -WEF_IP=$(echo $TF_OUTPUT | egrep -o "wef_public_ip = ([0-9]{1,3}[\.]){3}[0-9]{1,3}" | cut -d '=' -f 2 | tr -d ' ') -WIN10_IP=$(echo $TF_OUTPUT | egrep -o "win10_public_ip = ([0-9]{1,3}[\.]){3}[0-9]{1,3}" | cut -d '=' -f 2 | tr -d ' ') +DC_IP=$(echo "$TF_OUTPUT" | egrep -o "dc_public_ip = ([0-9]{1,3}[\.]){3}[0-9]{1,3}" | cut -d '=' -f 2 | tr -d ' ') +WEF_IP=$(echo "$TF_OUTPUT" | egrep -o "wef_public_ip = ([0-9]{1,3}[\.]){3}[0-9]{1,3}" | cut -d '=' -f 2 | tr -d ' ') +WIN10_IP=$(echo "$TF_OUTPUT" | egrep -o "win10_public_ip = ([0-9]{1,3}[\.]){3}[0-9]{1,3}" | cut -d '=' -f 2 | tr -d ' ') # Don't update unless there's default values in inventory.yml -GREP_COUNT=$(egrep -c 'x\.x\.x\.x|y\.y\.y\.y|z\.z\.z\.z' ../Ansible/inventory.yml) -if [ $GREP_COUNT -ne 3 ]; then +GREP_COUNT=$(grep -E -c 'x\.x\.x\.x|y\.y\.y\.y|z\.z\.z\.z' ../Ansible/inventory.yml) +if [ "$GREP_COUNT" -ne 3 ]; then echo "This script is expecting the default values of x.x.x.x, y.y.y.y, and z.z.z.z for the dc, wef, and win10 hosts respectively in Ansible/inventory.yml." echo "You can restore the file to this state by running 'git checkout -- Ansible/inventory.yml'" echo "Rerun this script once that is complete." diff --git a/ESXi/Packer/_common/vagrant.sh b/ESXi/Packer/_common/vagrant.sh index b69c3a5..f1527b0 100644 --- a/ESXi/Packer/_common/vagrant.sh +++ b/ESXi/Packer/_common/vagrant.sh @@ -4,16 +4,16 @@ HOME_DIR="${HOME_DIR:-/home/vagrant}"; pubkey_url="https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub"; -mkdir -p $HOME_DIR/.ssh; +mkdir -p "$HOME_DIR"/.ssh; if command -v wget >/dev/null 2>&1; then - wget --no-check-certificate "$pubkey_url" -O $HOME_DIR/.ssh/authorized_keys; + wget --no-check-certificate "$pubkey_url" -O "$HOME_DIR"/.ssh/authorized_keys; elif command -v curl >/dev/null 2>&1; then - curl --insecure --location "$pubkey_url" > $HOME_DIR/.ssh/authorized_keys; + curl --insecure --location "$pubkey_url" > "$HOME_DIR"/.ssh/authorized_keys; elif command -v fetch >/dev/null 2>&1; then - fetch -am -o $HOME_DIR/.ssh/authorized_keys "$pubkey_url"; + fetch -am -o "$HOME_DIR"/.ssh/authorized_keys "$pubkey_url"; else echo "Cannot download vagrant public key"; exit 1; fi -chown -R vagrant $HOME_DIR/.ssh; -chmod -R go-rwsx $HOME_DIR/.ssh; +chown -R vagrant "$HOME_DIR"/.ssh; +chmod -R go-rwsx "$HOME_DIR"/.ssh; diff --git a/Vagrant/bootstrap.sh b/Vagrant/bootstrap.sh index 30a029f..6a9c6ab 100644 --- a/Vagrant/bootstrap.sh +++ b/Vagrant/bootstrap.sh @@ -166,7 +166,7 @@ install_splunk() { /opt/splunk/bin/splunk install app /vagrant/resources/splunk_server/threathunting_141.tgz -auth 'admin:changeme' # Install the Maxmind license key for the ASNgen App - if [ ! -z "$MAXMIND_LICENSE" ]; then + if [ -n "$MAXMIND_LICENSE" ]; then mkdir /opt/splunk/etc/apps/TA-asngen/local cp /opt/splunk/etc/apps/TA-asngen/default/asngen.conf /opt/splunk/etc/apps/TA-asngen/local/asngen.conf sed -i "s/license_key =/license_key = $MAXMIND_LICENSE/g" /opt/splunk/etc/apps/TA-asngen/local/asngen.conf