Skip to content

Instantly share code, notes, and snippets.

@jodiecunningham
Created August 9, 2015 15:04
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jodiecunningham/0af64c999083c269df7c to your computer and use it in GitHub Desktop.
Save jodiecunningham/0af64c999083c269df7c to your computer and use it in GitHub Desktop.
AWS Startup on-demand script
#!/bin/sh
# Install the AWS CLI, set up an IAM user for the instance(s) you want to control.
# Pull the AWS keys for the IAM user and run aws configure to add them.
# I run this on Sophos UTM and have Sophos run a reverse proxy from the \
# $ROUTERIP:32400 to $PLEXHOST:32400
# set -x
# started with screen -Sdm a '/root/bin/awscheck.sh'een -Sdm a '/root/bin/awscheck.sh'screen -Sdm a '/root/bin/awscheck.sh'screen -Sdm a '/root/bin/awscheck.sh'n -Sdm a '/root/bin/awscheck.sh'
PLEXHOST=dokie.duckdns.org
WANIF=eth2
INSTID=i-3343fff0
while true
do
until nc -z -w15 "$PLEXHOST" 32400
do
tcpdump -i "$WANIF" -c1 -q dst port 32400 && aws ec2 start-instances --instance-ids "$INSTID"
sleep 120
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment