Skip to content

Instantly share code, notes, and snippets.

@rfairburn
rfairburn / awsssh
Last active October 28, 2019 15:57
aws cli ec2 bash ssh wrapper thingy
#!/bin/bash
REGION=us-east-2
set -e
function get_host() {
local HOSTLIST="${@}"
local HOSTARRAY=( $(awk 'BEGIN { OFS="|" } { print $1,$2 }' <<<"${HOSTLIST}") )
cat -n <<<"${HOSTLIST}" | column -t
read -p "Please enter selection >" HOSTENTRY
IFS="|" read -r HOST IP <<<"${HOSTARRAY[$((${HOSTENTRY}-1))]}"
@rfairburn
rfairburn / yamltest.py
Last active August 29, 2015 14:18
yamltest.py
#!/usr/bin/env python
import sys
import yaml
from pprint import pprint
filename = sys.argv[1]
with open(filename, 'r') as yaml_file:
try:
@rfairburn
rfairburn / manage_ec2.py
Last active October 30, 2015 19:21
Generate a list of EC2 instances and prompt to SSH into one
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
This script will list all hosts in an ec2 region and prompt you to connect
to them.
It expects the file .boto to exist in your home directory with contents
as follows:
@rfairburn
rfairburn / .vpn_helpers.sh
Last active November 8, 2022 03:16
Mac OS X command-line VPN Helpers
#!/bin/bash
# Source this file in your .bash_profile e.g.:
#
# source ~/gitcheckouts/vpn_heplers/.vpn_helpers.sh
#
# Note: This script works best with NOPASSWD: ALL configured in your sudoers file:
# /etc/sudoers:
# %admin ALL=(ALL) NOPASSWD: ALL
#
@rfairburn
rfairburn / checkdownminions.sh
Last active August 29, 2015 14:04
Check for down minions until all are up (good after a salt-master restart)
#!/bin/bash
count=0
while : ; do
minions=$(salt-run manage.down)
let count=count+1
if [ -n "${minions}" ]; then
echo -e "The following minions are down:\e[0;31m "${minions}"\e[0m. Waiting for them to recover."
else
echo -e "\e[0;32mAll minions are running!\e[0m"
#!/bin/bash
# shell script to convert a nagios .cfg file to yaml compatible with my nagios formula.
FILENAME=$1
DESTINATION=$2
GENERATED_FILENAME=$3
OBJECTTYPES=$(cat ${FILENAME} | awk '{ if ($1 == "define") { print $2 }}' | sed 's/{//' | sort -u)
awkit() {