Skip to content

Instantly share code, notes, and snippets.

View AstroTom's full-sized avatar

Tom Rosenfeld AstroTom

View GitHub Profile
@AstroTom
AstroTom / sqs.sh
Last active December 23, 2022 13:36
sample AWS sqs in CLI
# Create Q
ENV=dev1
Qname=tom-test1
Q1=$(aws sqs create-queue --queue-name "$ENV-$Qname" --output text)
echo $Q1
aws sqs send-message --queue-url $Q1 --message-body "Test message 1 from Tom"
@AstroTom
AstroTom / stop-if-inactive.sh
Last active August 20, 2018 17:46
Shutdown EC2 instance after timeout if no one is connected via ssh
#!/bin/bash
# based on AWS Cloud9
# shutdown ec2 if no ssh connections after 1/2 hour
# Add to cron to run every minute
# User needs sudo permission to run 'shutdown'
#
set -euo pipefail
#
# sample property file
# illustrates more flexible way to define variables based on Environemnt
#
# Assume external variable $RNT_ENV
#
# current system
# only works for 3 environments
@AstroTom
AstroTom / add-dns-record.sh
Last active May 10, 2018 05:54 — forked from justinclayton/add-dns-record.sh
CLI to add DNS Records in Route53
#!/bin/bash
set -eo pipefail
## Allows for creation of "Basic" DNS records in a Route53 hosted zone
# Make sure all output is in json
export AWS_DEFAULT_OUTPUT=json
function main() {
@AstroTom
AstroTom / register-from-tags.sh
Last active July 5, 2018 12:21
Register DNS and variables from TAGS of instance
#! /bin/bash
# Last update 2018-06-21 v0.2
# Author: Tom R.
#
# wishtrip-register-from-tags.sh - Register DNS and variables from TAGS of instance
# 1) get tags into env and then register DNS
# 2) create /etc/rnt.conf with value of RNT_ENV from "Env" tag
# 3) Set the hostname from tag "Hostname"
# 4) Set the DNS in route53 from tags "Host" and "Env"
@AstroTom
AstroTom / wishtrip-boot
Last active December 30, 2020 08:18
wishtrip boot script to run program at startup
#! /bin/bash
### BEGIN INIT INFO
# Provides: Wishtrip-boot
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts wishtrip services
# Description: starts wishtrip services
@AstroTom
AstroTom / wishtrip-service-skel
Created May 14, 2018 14:11
wishtrip startup skeleton
#
# all wishtrip services (controller, jobexec, gate) should have the following near the top of the service starup script
#
RNT_CONFIG_FILE=/etc/rnt.conf
# read in wishtrip config file for value of RNT_ENV etc
if [ -s $RNT_CONFIG_FILE ]; then
. $RNT_CONFIG_FILE
@AstroTom
AstroTom / live-server
Created May 29, 2018 15:21
live-server startup script to be installed in /etc/init.d
#!/bin/sh
# May 2018
# removed iptables and just run directly on port 443
# added RNT_ENV
#
#
# read in wishtrip config file for value of RNT_ENV etc
#
#
# resize an ec2 from and GPU g4dn.xlarge to t3.medium
#
AWS_INSTANCE_ID=i-0d286d48c371f57b1
TYPE=t3.medium
echo This will stop your instance $AWS_INSTANCE_ID to type $TYPE
# find name
echo Name tag is:
#
# resize an ec2 between t3.medium and GPU g4dn.xlarge
#
AWS_INSTANCE_ID=i-0d286d48c371f57b1
TYPE=g4dn.xlarge
echo This will stop your instance $AWS_INSTANCE_ID to type $TYPE
# find name
echo Name tag is: