Skip to content

Instantly share code, notes, and snippets.

View clcollins's full-sized avatar

Christopher Collins clcollins

View GitHub Profile
@clcollins
clcollins / git-prompt
Created April 18, 2017 16:35
Git Prompt for bash
# Found on Reddit - cannot now remember where
# Modified by Chris Collins to suite his tastes
git rev-parse 2> /dev/null && git status --porcelain -b | awk '
/^## / {
branch = $0;
sub(/^## /, "", branch);
sub(/\.\.\..*/, "", branch);
if ($0 ~ /ahead /) {

Docker Build Pipeline with Remote Asset Compilation

Problem

To compile code into assets/artifacts and build a Docker image with the resulting code only, and no compilers/devel packages/libraries, you have a workflow like so:

@clcollins
clcollins / dkr.sh
Created February 23, 2017 15:25
Wrapper to handle Docker TLS connection flags
#!/bin/bash
usage () {
cat << EOF
Usage: dkr HOSTNAME
dkr HOSTNAME COMMAND [arg...]
A wrapper around Docker to simplify using TLS connections
In the first form, will watch the output of "docker ps" and "docker images" on the remote host.
@clcollins
clcollins / format-disks.yml
Last active September 16, 2016 16:30
Snippet of Ansible Playbook for auto-expanding a volume group based on disks on the server
---
## Snippet of Ansible Playbook for auto-expanding a volume group based on disks on the server
### Format Partitions ###
- name: Format | find disks
command: find /dev -regex "/dev/sd[b-z]" -exec echo "{}," \;
register: extra_pvs
- name: Format | expand vg if extra_pvs exist
# defaultpv comes last, because extra_pvs are formatted to have a comma on the end
#!/bin/bash
# Script that can be run to cleanup a Jenkins slave server that's used to build docker images
# Tries to account for the fact that a job might be running and using images & containers
# Adjust the Docker command to match your environment (esp. the $HOST hostname)
# TLS included as script it designed to be run from the master
DOCKER_TLS_VERIFY=1
DOCKER="docker --tlscacert /ca.pem --tlscert /cert.pem --tlskey /key.pem -H ${HOST}"
RUNNING_CONTAINERS=$($DOCKER ps -q)
@clcollins
clcollins / automount-enable.sh
Created April 18, 2016 18:53
Systemd NFS Automount
#!/bin/sh
systemctl enable <path-to-mountpoint>.automount
systemctl start <path-to-mountpoint>.automount
@clcollins
clcollins / throwaway_ssh_keypair.sh
Created March 14, 2016 15:54
Generate throwaway SSH key pairs for automated ... things.
#!/bin/bash
error () {
local msg="${1}"
echo "${msg}"
exit 1
}
make_tempdir () {
@clcollins
clcollins / run-docker-container.sh
Last active December 19, 2022 09:04
Bash script to easily setup and run Docker containers to test any given project
#!/bin/bash
# Set to true to just see what command
# would be run
DRY_RUN=false
TITLE='MY-TEST-CONTAINER'
IMAGE='MY-IMAGE'
# Local volume to be mapped into the container any time you run it
# usually with config files or whatnot
@clcollins
clcollins / wp-upgrade.sh
Last active May 15, 2019 15:18
WP-CLI Site Upgrade
#!/bin/bash
#
# TODO:
# How to handle NOT running the DB upgrade if it's not needed?
HOSTNAME="$(/bin/hostname)"
TMPDIR='/tmp'
MAILFROM="patch.adams@$HOSTNAME"
MAILTO="$@"
@clcollins
clcollins / docker-appstack-wordpress
Last active May 15, 2019 15:19
Docker Appstack WP Instance, via command line
#!/bin/bash
# Version 1.2 - 2015-01-07
# https://gist.github.com/clcollins/cfab1f63dc1aa927bf9f
# REQUIRES:
#
# Software -
# 1. Docker: https://docker.com
#