Turn Off The Lights

After upgrading to macOS Sierra, and having Apex fail to work locally anymore, I decided it was time to build a dev instance, on EBS within EC2. I found a good idea from CloudSSH, but I really wanted to allow my instance to run docker commands while I was away. I decided to add the "--no-stop" flag to CloudSSH and just handle terminating the instances myself using a cronscript.

Here's the script:

# Don't even bother checking if we haven't been up for more than
# 3500 seconds (just under 1 hour)
UPTIME=`cat /proc/uptime|awk '{printf "%i", $1}'`
if [ "$UPTIME" -gt "3500" ]
  if [ -z "$(who)" ]
    if [ -z "$(docker ps -q)" ]
      shutdown -P now


And here's the /etc/cron.d/turn-off-the-lights file:

*/5 * * * * root /usr/local/bin/turn-off-the-lights

I also set up a nice little bash function to handle automatically configuring most of the common things I did for CloudSSH. I did this instead of an alias because I have multiple AWS profiles that I connect to:

# Connect to a "Cloud Environment"
  export AWS_REGION=us-east-1
  export AWS_PROFILE=$1
  $HOME/bin/cloudssh --no-stop ec2-user@${CLOUD_INSTANCE_ID[$1]}.us-east-1 -- -i ~/.ssh/$1-cmoyer.pem -o HostKeyAlias=${CLOUD_INSTANCE_ID[$1]}
cloud_profiles=(aci newstex)
compctl -k cloud_profiles cloud

Now I can just type "cloud aci" and automatically get logged into my ACI dev instance. Note that using "HostKeyAlias" allows me to not have to re-verify the host key every time the IP address changes.


There is also our famous QA team, checking on zipjob review every essay and paper written by our writers before sending the final draft over to a customer.
unknown said…
Before the writer, I was the best developer but recently I changed our field for some issues. When the last week also took law writing service from the best law essay writing services Manchester the reason is that I'm not a professional in the law writing.