Skip to content

Instantly share code, notes, and snippets.

View NFarrington's full-sized avatar

Neil Farrington NFarrington

View GitHub Profile
#!/bin/sh
set -e
# Docker CE for Linux installation script
#
# See https://docs.docker.com/engine/install/ for the installation steps.
#
# This script is meant for quick & easy install via:
# $ curl -fsSL https://get.docker.com -o get-docker.sh
# $ sh get-docker.sh
#
@NFarrington
NFarrington / Migrating Terraform Cloud State.md
Last active September 16, 2021 13:08
Migrating Terraform State

Migrating Terraform Cloud State (the Super Janky Method™️)

The following is a semi-automated (or semi-manual, if you're a glass-half-empty person) way of generating terraform state mv commands to move existing resources to new paths.

It does not use a Terraform plan file, as this is often not conveniently available (e.g. when using Terraform Cloud).

Tested with Terraform 0.12, 0.13 and 0.14 output.

Note: if you're not using Terraform Cloud, you might want to try some of the proper tooling other people have built, such as https://github.com/mbode/terraform-state-mover.

#!/bin/bash
# A basic healthcheck to determine when a URL is unavailable, and for how long.
[ -z "$1" ] && { echo "You must specify the URL to check" >&2; exit 1; }
URL="$1"
SLEEP="1"
CURL_CONNECT_TIMEOUT="1"
@NFarrington
NFarrington / AllowSSHFromIP.php
Created November 3, 2018 09:12 — forked from HSPDev/AllowSSHFromIP.php
Complementary code and IAM policy for "You don't need that Bastion host"
<?php
// For laravel 5 based systems
// /path/to/project/app/Console/Commands/AllowSSHFromIP.php
namespace App\Console\Commands;
use Aws\Ec2\Ec2Client;
use Carbon\Carbon;
use Illuminate\Console\Command;
@NFarrington
NFarrington / vagrant-parallel.sh
Created October 19, 2018 12:52
Runs any Vagrant command against multiple Vagrant boxes in parallel.
#!/bin/bash
### DEFAULT ARGUMENTS ###
ARGS=()
VAGRANT_ARGS=()
DEBUG=false
USAGE="
Usage: $0 [OPTIONS] [VAGRANT_COMMAND] [VAGRANT_BOX]...

Keybase proof

I hereby claim:

  • I am nfarrington on github.
  • I am nfarrington (https://keybase.io/nfarrington) on keybase.
  • I have a public key ASDLEx6aZ1EXX3zpSjF7OBkeIQnqrillP74nGypGO3HttQo

To claim this, I am signing this object:

@NFarrington
NFarrington / check_mem
Created November 18, 2017 17:58
Nagios Plugins
#!/bin/bash
# An updated memory plugin to use MemAvailable rather than MemFree
# TODO: Error check for kernel version (check MemAvailable is available in /proc/meminfo)
# TODO: Add swap checks
# TODO: Improve rounding
command -v bc > /dev/null 2>&1 || {
echo "UNKNOWN - Missing Command: bc"
@NFarrington
NFarrington / sshsocks.sh
Created November 18, 2017 17:53
SSH SOCKS Proxy Command - MacOS
#!/bin/bash
# MacOS bash script to enable/disable an SSH SOCKS proxy on port 1080
#
# Usage: ./sshsocks <hostname>
#
set -e
disable_proxy()