Skip to content

Instantly share code, notes, and snippets.

View mikedougherty's full-sized avatar

Mike Dougherty mikedougherty

View GitHub Profile
@mikedougherty
mikedougherty / get-github-keys
Created November 3, 2016 19:52
Bash script to fetch public keys of a github user
#!/bin/bash
# get-github-keys
# pipe the output to an ~/.ssh/authorized_keys file to grant ssh access
# of a system to a github user. Probably has other uses as well!
set +x
set +e
set -u
set -o pipefail
# Forked from https://gist.github.com/masterzen/6714787, thank you
#
# Windows AMIs don't have WinRM enabled by default -- this script will enable WinRM
# AND install 7-zip, curl and .NET 4 if its missing.
# Then use the EC2 tools to create a new AMI from the result, and you have a system
# that will execute user-data as a PowerShell script after the instance fires up!
# This has been tested on Windows 2008 SP2 64bits AMIs provided by Amazon
#
# Inject this as user-data of a Windows 2008 AMI, like this (edit the adminPassword to your needs):
#
import com.docker.ci.dsl.GithubProject
new GithubProject(dslFactory: delegate) {
owners [
"miked"
]
task("test-windows") {
label("windows")
Dir {
ArchiveDir "/repos/apt/repo";
CacheDir "/repos/apt/repo/db";
};
Default {
Packages::Compress ". gzip bzip2";
Sources::Compress ". gzip bzip2";
Contents::Compress ". gzip bzip2";
};
@mikedougherty
mikedougherty / docker-install.sh
Last active February 29, 2016 22:05
install script to change docker version on a docker-machine managed host
#!/bin/bash -x
# TODO: find a way to automated this variable
export CS_LATEST_VERSION=1.10.2-cs1
export HOME="$WORKSPACE"
DOCKER_MACHINE_OS=$(docker-machine ssh "$DOCKER_MACHINE_NAME" -- 'source /etc/os-release && echo "$ID-$ID_LIKE"')
DOCKER_MACHINE_USER=$(docker-machine inspect "$DOCKER_MACHINE_NAME" | jq -r '.Driver.SSHUser')
if ! [[ "$DOCKER_MACHINE_OS" =~ "debian" ]]; then
@mikedougherty
mikedougherty / rendered.ps
Last active January 20, 2016 00:04
packer file for a windows TP4 host on azure
# This is an approximately resolved version of the script generated above
mkdir c:\Packer
# Packer uploads the 'packer/files/windows' directory to 'c:\Packer' on the remote host
# Copy our authorized keys to the user directory
mkdir ~/.ssh
move c:\Packer\authorized_keys ~/.ssh/authorized_keys
# Install chocolatey
@mikedougherty
mikedougherty / docker-updater.sh
Last active June 17, 2016 18:07
Script to get the latest static binaries of docker, docker-machine, docker-compose.
#!/bin/bash
# Requires: jq, curl
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
[[ -n "$GITHUB_TOKEN" ]] && AUTH_ARGS="-u $GITHUB_TOKEN:"
function machine_url() {
echo "https://github.com/docker/machine/releases/download/${1}/docker-machine-$( uname -s )-$( uname -m)"
}
@mikedougherty
mikedougherty / gist:a06f4dc534a20767267c
Created October 20, 2015 17:40
docker data persists -- reddit
> Disk storage might be volatile
Actually the disk storage of a container is not inherently volatile. Your filesystem in this case still exists in your graph location (default /var/lib/docker, but check your daemon options for a `-g` or `--graph`). Here's a test I just did:
$ docker run --name data-test -it busybox
/ # echo "some text" > /tmp/test.txt
In another shell:
@mikedougherty
mikedougherty / oops.md
Created June 19, 2015 21:39
swarm-consul-failure

Yesterday I set up a set of 4 swarm hosts -- they're all both managing (with --replication) and have joined the group (consul for discovery).

At first, everything was going well:

time="2015-06-18T22:18:15Z" level=info msg="New leader elected: 10.128.31.224:3376"
time="2015-06-19T02:51:29Z" level=info msg="New leader elected: 10.128.13.40:3376"
time="2015-06-19T13:28:04Z" level=info msg="New leader elected: 10.128.24.95:3376"
time="2015-06-19T13:28:04Z" level=info msg="Cluster leadership acquired"
test