Skip to content

Instantly share code, notes, and snippets.

View brianwhigham's full-sized avatar

Brian Whigham brianwhigham

View GitHub Profile
#!/bin/bash
PKGS="git swift ansible"
PKGMGR=yum
REPONAME=uat-swiftstack
REPOOWNER=encompassdigitalmedia
SWIFTRC=/etc/swiftrc-uat-swiftstack
grep "^ID=" /etc/os-release | grep ubuntu && PKGMGR=apt
# set swift credentials in order to download our SSH deploy key
read -p "Please enter the EDMTest Swift password: " ST_KEY
#!/bin/bash
PKGS="git swift ansible"
PKGMGR=yum
REPONAME=uat-swiftstack
REPOOWNER=encompassdigitalmedia
SWIFTRC=/etc/swiftrc-uat-swiftstack
grep "^ID=" /etc/os-release | grep ubuntu && PKGMGR=apt
# set swift credentials in order to download our SSH deploy key
read -p "Please enter the EDMTest Swift password: " ST_KEY
#!/bin/bash
PKGS="git swift ansible"
PKGMGR=yum
REPONAME=uat-swiftstack
REPOOWNER=encompassdigitalmedia
SWIFTRC=/etc/swiftrc-uat-swiftstack
grep "^ID=" /etc/os-release | grep ubuntu && PKGMGR=apt
# set swift credentials in order to download our SSH deploy key
read -p "Please enter the EDMTest Swift password: " ST_KEY
@brianwhigham
brianwhigham / ecr.repo.cloudformation.json
Created April 3, 2018 12:54
cloudformation resource to create an ECR Repo with a lifecycle policy
"ECRRepo": {
"Type" : "AWS::ECR::Repository",
"Properties" : {
"LifecyclePolicy" : {
"LifecyclePolicyText" : "{ \"rules\": [ { \"rulePriority\": 10, \"description\": \"remove untagged images except the latest one\", \"selection\": { \"tagStatus\": \"untagged\", \"countType\": \"imageCountMoreThan\", \"countNumber\": 1 }, \"action\": { \"type\": \"expire\" } } ] }"
},
"RepositoryName" : { "Ref": "StackName" }
}
},
@brianwhigham
brianwhigham / test-aws-es.php
Created June 22, 2016 03:29
quick test of AWS elasticsearch with PHP
<?php
require 'vendor/autoload.php';
$hosts = [
'https://yourhostname.us-east-1.es.amazonaws.com:443'
];
$client = Elasticsearch\ClientBuilder::create() // Instantiate a new ClientBuilder
->setHosts($hosts) // Set the hosts
->build();
$params = [
@brianwhigham
brianwhigham / showswapused.sh
Created May 27, 2016 22:04
show used swap using bash
#!/bin/sh
free -m | awk 'NR==4{print $3 }'
@brianwhigham
brianwhigham / showusedram.sh
Created May 27, 2016 21:40
show amount of used RAM with bash and awk
#!/bin/sh
free -m | awk 'NR==2{ram=$2; getline; used=$3; printf "%.0f\n", 100-(ram-used)/ram*100 }'
@brianwhigham
brianwhigham / countawsips.sh
Created May 24, 2016 17:12
Use my awsiprangefilter.py (https://gist.github.com/brianwhigham/d3d74c17c423254db2ba973f97fae614) gist to list AWS IP ranges. Then, use ipcalc to count how many hosts are in that list.
#!/bin/sh
# usage: supply a comma-separated list of regions as the first argument
# and a comma-separated list of services as the second argument.
wget -O /tmp/ip-ranges.json https://ip-ranges.amazonaws.com/ip-ranges.json
unset hostcnt
unset tcnt
for r in $(awsiprangefilter.py -r $1 --services $2)
do
hostcnt=$(ipcalc $r|grep Hosts|cut -d " " -f 2)
@brianwhigham
brianwhigham / awsiprangefilter.py
Created May 24, 2016 16:54
parse the list of AWS service IPs and filter given a list of regions and or services
#!/usr/bin/python
import json
import sys, getopt
ip_ranges_file_name = None
regions = None
services = None
try:
opts, args = getopt.getopt(sys.argv[1:],"hf:r:s:",["file=","regions=","services=","help"])
@brianwhigham
brianwhigham / websiteconfig.sh
Last active August 29, 2015 14:20
Configure Web Server
yum -y install httpd bind-utils
cd /var/www
HOSTIP=$(host $HOSTNAME|tail -1|awk '{print $4}')
wget -r --header="Host: $HOSTNAME" $HOSTIP
rm -rf html
mv $HOSTIP html
service httpd start
chkconfig httpd on
iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT
setenforce 0