Skip to content

Instantly share code, notes, and snippets.

View seventhskye's full-sized avatar

Seventh Skye Limited seventhskye

View GitHub Profile
@seventhskye
seventhskye / grep_out_blanks.sh
Last active October 19, 2015 14:38
Grep out all commented and blank lines.
#!/bin/bash
grep -v '^$\|^\s*\#' $1
@seventhskye
seventhskye / create_ssl_cert.sh
Last active March 7, 2016 14:20
Script to create an SSL certificate.
#!/bin/bash
if [ $# -eq 0 ]; then
echo "Usage: $0 <CERT_NAME>"
echo "e.g. $0 example.com"
else
openssl genrsa -des3 -passout pass:x -out $1.pass.key 2048
openssl rsa -passin pass:x -in $1.pass.key -out $1.key
rm $1.pass.key
openssl req -new -key $1.key -out $1.csr
openssl x509 -req -days 365 -in $1.csr -signkey $1.key -out $1.crt
@seventhskye
seventhskye / docker-registry.yml
Created October 29, 2015 11:53
Basic config.yml for an s3 backed v2 docker registry.
version: 0.1
log:
fields:
service: registry
http:
addr: :5000
headers:
X-Content-Type-Options: [nosniff]
storage:
cache:
@seventhskye
seventhskye / Makefile
Created November 25, 2015 13:41
A Makefile for running an Infrastructure managed with Continuous Integration tools.
DATE = $(shell date)
release:
@echo "Enter commit message:"
@read REPLY; \
echo "${DATE} - $$REPLY" >> CHANGELOG; \
git add --all; \
git commit -m "$$REPLY"; \
git push
@seventhskye
seventhskye / userdata.d.sh
Last active December 10, 2018 05:02
Userdata script to download and execute a set of bash scripts from Amazon S3. Useful if you wanted to have a predefined set of scripts to share amongst EC2 instance, e.g. userdata.
#!/bin/bash -x
# The bucket containing the userdata.d
export USERDATAD_BUCKET=userdata.example.com
# Required to set the endpoint of the aws-cli
export AWS_DEFAULT_REGION=eu-west-1
# Install Prerequisites
yum install -y aws-cli
# Download all .sh scripts from the bucket and pipe to bash
SCRIPTS=$(aws s3 ls s3://$USERDATAD_BUCKET/userdata.d/ | awk '{ print $4 }')
for S in $SCRIPTS; do
@seventhskye
seventhskye / nokogiri.sh
Created January 3, 2016 00:24
A shell script to install nokogiri prequistes.
#!/bin/bash
sudo yum install -y gcc libxml2 libxml2-devel libxslt libxslt-devel
@seventhskye
seventhskye / get_url.sh
Last active March 11, 2016 04:45
A bash while loop to get a URL from $PROTOCOL, $HOST and $DNS_DOMAIN environment variables.
#!/bin/bash
DNS_DOMAIN=${DNS_DOMAIN:-example.com}
HOST=${HOST:-www}
HOSTNAME=$HOST.$DNS_DOMAIN
PROTOCOL=${PROTOCOL:-https}
URL=$PROTOCOL://$HOSTNAME
echo " --> Testing for $URL"
# Number of requests
TIMEOUT=30
# Time to wait between requests
@seventhskye
seventhskye / functions
Created March 16, 2016 09:20
A library of bash functions to use for Amazon Web Services CloudFormation deployments.
#!/bin/bash
# Abort with exit and message
# Used for testing
function abort()
{
echo " *** ERROR $@"
exit 1
}
#!/bin/sh
### BEGIN INIT INFO
# Provides: dockercompose
# Required-Start: $docker
# Required-Stop: $docker
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Docker Services
### END INIT INFO
@seventhskye
seventhskye / Makedocker
Last active May 25, 2016 13:26
A Makefile for docker images.
DATE = $(shell date)
NAME = dcrbsltd/image
VERSION = 1
all: build
build:
docker build -t $(NAME):$(VERSION) --rm .
tag_latest: