From 4de1e57710627ee00e9c913f7967bc1664201316 Mon Sep 17 00:00:00 2001 From: Danny Thomas Date: Sat, 29 Oct 2016 20:04:03 -0700 Subject: [PATCH] Move non-user facing files to scripts/ --- .gitignore | 7 ++++--- ec2gaming | 3 ++- ec2gaming-ca.crt => scripts/ec2gaming-ca.crt | 0 ec2gaming-instance.sh => scripts/ec2gaming-instance.sh | 0 ec2gaming-ip.sh => scripts/ec2gaming-ip.sh | 0 .../ec2gaming-permissionpolicy.json.template | 0 ec2gaming-price.sh => scripts/ec2gaming-price.sh | 0 ec2gaming-rdp.sh => scripts/ec2gaming-rdp.sh | 0 ec2gaming-reboot.sh => scripts/ec2gaming-reboot.sh | 0 ec2gaming-snapshot.sh => scripts/ec2gaming-snapshot.sh | 0 ec2gaming-start.sh => scripts/ec2gaming-start.sh | 8 +------- ec2gaming-stop.sh => scripts/ec2gaming-stop.sh | 0 ec2gaming-terminate.sh => scripts/ec2gaming-terminate.sh | 0 .../ec2gaming-trustpolicy.json | 0 ec2gaming-vnc.sh => scripts/ec2gaming-vnc.sh | 2 -- ec2gaming-vpndown.scpt => scripts/ec2gaming-vpndown.scpt | 0 ec2gaming-vpndown.sh => scripts/ec2gaming-vpndown.sh | 0 ec2gaming-vpnup.scpt => scripts/ec2gaming-vpnup.scpt | 0 ec2gaming-vpnup.sh => scripts/ec2gaming-vpnup.sh | 5 +++-- ec2gaming.bat.template => scripts/ec2gaming.bat.template | 0 ec2gaming.header => scripts/ec2gaming.header | 5 ++++- .../ec2gaming.ovpn.template | 0 ec2gaming.rdp.template => scripts/ec2gaming.rdp.template | 0 23 files changed, 14 insertions(+), 16 deletions(-) rename ec2gaming-ca.crt => scripts/ec2gaming-ca.crt (100%) rename ec2gaming-instance.sh => scripts/ec2gaming-instance.sh (100%) rename ec2gaming-ip.sh => scripts/ec2gaming-ip.sh (100%) rename ec2gaming-permissionpolicy.json.template => scripts/ec2gaming-permissionpolicy.json.template (100%) rename ec2gaming-price.sh => scripts/ec2gaming-price.sh (100%) rename ec2gaming-rdp.sh => scripts/ec2gaming-rdp.sh (100%) rename ec2gaming-reboot.sh => scripts/ec2gaming-reboot.sh (100%) rename ec2gaming-snapshot.sh => scripts/ec2gaming-snapshot.sh (100%) rename ec2gaming-start.sh => scripts/ec2gaming-start.sh (95%) rename ec2gaming-stop.sh => scripts/ec2gaming-stop.sh (100%) rename ec2gaming-terminate.sh => scripts/ec2gaming-terminate.sh (100%) rename ec2gaming-trustpolicy.json => scripts/ec2gaming-trustpolicy.json (100%) rename ec2gaming-vnc.sh => scripts/ec2gaming-vnc.sh (60%) rename ec2gaming-vpndown.scpt => scripts/ec2gaming-vpndown.scpt (100%) rename ec2gaming-vpndown.sh => scripts/ec2gaming-vpndown.sh (100%) rename ec2gaming-vpnup.scpt => scripts/ec2gaming-vpnup.scpt (100%) rename ec2gaming-vpnup.sh => scripts/ec2gaming-vpnup.sh (71%) rename ec2gaming.bat.template => scripts/ec2gaming.bat.template (100%) rename ec2gaming.header => scripts/ec2gaming.header (77%) rename ec2gaming.ovpn.template => scripts/ec2gaming.ovpn.template (100%) rename ec2gaming.rdp.template => scripts/ec2gaming.rdp.template (100%) diff --git a/.gitignore b/.gitignore index c8418b8..f858edb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ -ec2gaming.ovpn -ec2gaming.rdp ec2gaming.auth ec2gaming.bat -ec2gaming-permissionpolicy.json +scripts/ec2gaming-permissionpolicy.json +scripts/ec2gaming.ovpn +scripts/ec2gaming.rdp + diff --git a/ec2gaming b/ec2gaming index 580705a..261238a 100755 --- a/ec2gaming +++ b/ec2gaming @@ -1,5 +1,6 @@ #!/usr/bin/env bash -source "$(dirname "$0")/ec2gaming.header" +set -e +cd "$(dirname "$0")/scripts" || exit COMMANDS=($(find . -name 'ec2gaming-*.sh' | sed 's/.*ec2gaming-//;s/\.sh//')) diff --git a/ec2gaming-ca.crt b/scripts/ec2gaming-ca.crt similarity index 100% rename from ec2gaming-ca.crt rename to scripts/ec2gaming-ca.crt diff --git a/ec2gaming-instance.sh b/scripts/ec2gaming-instance.sh similarity index 100% rename from ec2gaming-instance.sh rename to scripts/ec2gaming-instance.sh diff --git a/ec2gaming-ip.sh b/scripts/ec2gaming-ip.sh similarity index 100% rename from ec2gaming-ip.sh rename to scripts/ec2gaming-ip.sh diff --git a/ec2gaming-permissionpolicy.json.template b/scripts/ec2gaming-permissionpolicy.json.template similarity index 100% rename from ec2gaming-permissionpolicy.json.template rename to scripts/ec2gaming-permissionpolicy.json.template diff --git a/ec2gaming-price.sh b/scripts/ec2gaming-price.sh similarity index 100% rename from ec2gaming-price.sh rename to scripts/ec2gaming-price.sh diff --git a/ec2gaming-rdp.sh b/scripts/ec2gaming-rdp.sh similarity index 100% rename from ec2gaming-rdp.sh rename to scripts/ec2gaming-rdp.sh diff --git a/ec2gaming-reboot.sh b/scripts/ec2gaming-reboot.sh similarity index 100% rename from ec2gaming-reboot.sh rename to scripts/ec2gaming-reboot.sh diff --git a/ec2gaming-snapshot.sh b/scripts/ec2gaming-snapshot.sh similarity index 100% rename from ec2gaming-snapshot.sh rename to scripts/ec2gaming-snapshot.sh diff --git a/ec2gaming-start.sh b/scripts/ec2gaming-start.sh similarity index 95% rename from ec2gaming-start.sh rename to scripts/ec2gaming-start.sh index fd10b62..0dc7938 100755 --- a/ec2gaming-start.sh +++ b/scripts/ec2gaming-start.sh @@ -3,10 +3,6 @@ source "$(dirname "$0")/ec2gaming.header" BOOTSTRAP=0 -if [ ! -f ec2gaming.auth ]; then - echo "ec2gaming.auth file not found!" -fi - echo -n "Getting lowest $INSTANCE_TYPE bid... " PRICE_AND_ZONE=($(./ec2gaming-price.sh)) PRICE=${PRICE_AND_ZONE[0]} @@ -50,9 +46,7 @@ if ! aws s3api head-bucket --bucket "$BUCKET" &> /dev/null; then REGION=$(aws configure get region) aws s3api create-bucket --bucket "$BUCKET" --region "$REGION" --create-bucket-configuration LocationConstraint="$REGION" > /dev/null fi -USERNAME=$(head -1 ec2gaming.auth) -PASSWORD=$(tail -1 ec2gaming.auth) -sed "s/BUCKET/$BUCKET/g;s/USERNAME/$USERNAME/g;s/PASSWORD/$PASSWORD/g" ec2gaming.bat.template > ec2gaming.bat +sed "s/BUCKET/$BUCKET/g;s/USERNAME/$USERNAME/g;s/PASSWORD/$PASSWORD/g" ec2gaming.bat.template > ../ec2gaming.bat echo "$BUCKET" PROFILE_NAME="ec2gaming" diff --git a/ec2gaming-stop.sh b/scripts/ec2gaming-stop.sh similarity index 100% rename from ec2gaming-stop.sh rename to scripts/ec2gaming-stop.sh diff --git a/ec2gaming-terminate.sh b/scripts/ec2gaming-terminate.sh similarity index 100% rename from ec2gaming-terminate.sh rename to scripts/ec2gaming-terminate.sh diff --git a/ec2gaming-trustpolicy.json b/scripts/ec2gaming-trustpolicy.json similarity index 100% rename from ec2gaming-trustpolicy.json rename to scripts/ec2gaming-trustpolicy.json diff --git a/ec2gaming-vnc.sh b/scripts/ec2gaming-vnc.sh similarity index 60% rename from ec2gaming-vnc.sh rename to scripts/ec2gaming-vnc.sh index 5ade617..126624e 100755 --- a/ec2gaming-vnc.sh +++ b/scripts/ec2gaming-vnc.sh @@ -1,6 +1,4 @@ #!/usr/bin/env bash source "$(dirname "$0")/ec2gaming.header" -USERNAME=$(head -1 ec2gaming.auth) -PASSWORD=$(tail -1 ec2gaming.auth) open "vnc://$USERNAME:$PASSWORD@10.8.0.1" diff --git a/ec2gaming-vpndown.scpt b/scripts/ec2gaming-vpndown.scpt similarity index 100% rename from ec2gaming-vpndown.scpt rename to scripts/ec2gaming-vpndown.scpt diff --git a/ec2gaming-vpndown.sh b/scripts/ec2gaming-vpndown.sh similarity index 100% rename from ec2gaming-vpndown.sh rename to scripts/ec2gaming-vpndown.sh diff --git a/ec2gaming-vpnup.scpt b/scripts/ec2gaming-vpnup.scpt similarity index 100% rename from ec2gaming-vpnup.scpt rename to scripts/ec2gaming-vpnup.scpt diff --git a/ec2gaming-vpnup.sh b/scripts/ec2gaming-vpnup.sh similarity index 71% rename from ec2gaming-vpnup.sh rename to scripts/ec2gaming-vpnup.sh index 2d4f4e7..341722d 100755 --- a/ec2gaming-vpnup.sh +++ b/scripts/ec2gaming-vpnup.sh @@ -3,15 +3,16 @@ source "$(dirname "$0")/ec2gaming.header" echo -n "Connecting VPN (you may see an authentication prompt)... " IP=$(./ec2gaming-ip.sh) +AUTH=$(realpath "$(pwd)/../ec2gaming.auth") BACKING_CONFIG=~/Library/Application\ Support/Tunnelblick/Configurations/ec2gaming.tblk/Contents/Resources/config.ovpn if [ ! -f "$BACKING_CONFIG" ]; then - sed "s#IP#$IP#g;s#AUTH#$(pwd)/ec2gaming.auth#g" ec2gaming.ovpn.template > ec2gaming.ovpn + sed "s#IP#$IP#g;s#AUTH#$AUTH#g" ec2gaming.ovpn.template > ec2gaming.ovpn open ec2gaming.ovpn echo "Waiting 10 seconds for import..." sleep 10 else # the authentication prompt on copy will block, avoids the messy sleep - sed "s#IP#$IP#g;s#AUTH#$(pwd)/ec2gaming.auth#g" ec2gaming.ovpn.template > "$BACKING_CONFIG" + sed "s#IP#$IP#g;s#AUTH#$AUTH#g" ec2gaming.ovpn.template > "$BACKING_CONFIG" fi osascript ec2gaming-vpnup.scpt diff --git a/ec2gaming.bat.template b/scripts/ec2gaming.bat.template similarity index 100% rename from ec2gaming.bat.template rename to scripts/ec2gaming.bat.template diff --git a/ec2gaming.header b/scripts/ec2gaming.header similarity index 77% rename from ec2gaming.header rename to scripts/ec2gaming.header index fbfb488..92faefa 100644 --- a/ec2gaming.header +++ b/scripts/ec2gaming.header @@ -1,7 +1,10 @@ #!/bin/bash set -e cd "$(dirname "$0")" || exit -source ec2gaming.cfg +source ../ec2gaming.cfg + +USERNAME=$(head -1 ../ec2gaming.auth) +PASSWORD=$(tail -1 ../ec2gaming.auth) describe_gaming_image() { aws ec2 describe-images --owner "$1" --filters Name=name,Values=ec2gaming diff --git a/ec2gaming.ovpn.template b/scripts/ec2gaming.ovpn.template similarity index 100% rename from ec2gaming.ovpn.template rename to scripts/ec2gaming.ovpn.template diff --git a/ec2gaming.rdp.template b/scripts/ec2gaming.rdp.template similarity index 100% rename from ec2gaming.rdp.template rename to scripts/ec2gaming.rdp.template