Skip to content

Instantly share code, notes, and snippets.

Avatar

Adam Stokes adam-stokes

  • North Carolina
View GitHub Profile
@adam-stokes
adam-stokes / retry.sh
Created Jul 16, 2020 — forked from sj26/retry.sh
Bash retry function
View retry.sh
# Retry a command up to a specific numer of times until it exits successfully,
# with exponential back off.
#
# $ retry 5 echo Hello
# Hello
#
# $ retry 5 false
# Retry 1/5 exited 1, retrying in 1 seconds...
# Retry 2/5 exited 1, retrying in 2 seconds...
# Retry 3/5 exited 1, retrying in 4 seconds...
View gist:569072af88dab297de554d2436e5ddd6
cat <<EOF> profile-update.yaml
config: {}
description: Default LXD profile - updated
devices:
eth0:
name: eth0
parent: lxdbr0
nictype: bridged
type: nic
root:
@adam-stokes
adam-stokes / commands-channel.go
Created Jan 28, 2020 — forked from proudlygeek/commands-channel.go
Golang Commands in Goroutines
View commands-channel.go
package main
import (
"fmt"
"log"
"os/exec"
"runtime"
)
type Worker struct {
View gist:433899ec9c068d3fb802b293d8a440ad
for row in $(echo "$(sudo lxc list --format json)" | jq -r '.[] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
sudo lxc delete --force $(_jq '.name')
done
@adam-stokes
adam-stokes / update-cu-brew.txt
Created Apr 3, 2019 — forked from kwmonroe/update-cu-brew.txt
update conjure-up for brew
View update-cu-brew.txt
# update brew
brew update
cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
# fork https://github.com/Homebrew/homebrew-core
git fetch --all
git checkout master
git pull
git push <FORK>
View gist:cd690753b96bcba198c3d94ac592cc86
def create_or_update_snap_builder(self, name, owner, version, repo, branch, track):
""" Creates a new LP builder for snap with a specific git branch to build from
"""
lp_snap_name = f'{name}-{version}'
lp_snap_project_name = f'snap-{name}'
lp_owner = self.owner(owner)
if not isinstance(track, list):
track = [track]
@adam-stokes
adam-stokes / delete-vpc.sh
Created Oct 24, 2018 — forked from cjp/delete-vpc.sh
Delete AWS VPC including dependencies
View delete-vpc.sh
#!/bin/sh
#
# Delete a VPC and its dependencies
if [ -z "$1" ] then
echo "usage: $0 <vpcid>"
exit 64
fi
vpcid="$1"
View setup-lxd-profile.sh
#!/bin/bash
set -eu
_UID=$(id -u)
GID=$(id -g)
# give lxd permission to map your user/group id through
grep root:$_UID:1 /etc/subuid -qs || sudo usermod --add-subuids ${_UID}-${_UID} --add-subgids ${GID}-${GID} root
# set up a separate key to make sure we can log in automatically via ssh
# with $HOME mounted
@adam-stokes
adam-stokes / register_node.sh
Created Aug 16, 2018 — forked from scarytom/register_node.sh
bash script to register new jenkins node
View register_node.sh
#!/bin/bash
# jenkins master vitals
CI_MASTER_HOST="ci-1.youdevise.com"
CI_MASTER_PORT="80"
# node vitals
NODE_HOST="tom-denley-rocks-01.youdevise.com"
NODE_NAME="tom-denley-rocks-name-01"
NODE_DESC="my node of glory"
@adam-stokes
adam-stokes / remove-nodes-safely.sh
Created Aug 16, 2018 — forked from scarytom/remove-nodes-safely.sh
Script to safely de-register jenkins nodes usage: $ remove-nodes-safely.sh my-node-1 my-node-2 my-node-3
View remove-nodes-safely.sh
#!/bin/bash
set -e
set -u
CI_MASTER_URL="http://ci-1"
node_online() {
curl --silent "$CI_MASTER_URL/computer/$1/api/json" | grep --silent '"temporarilyOffline":false'
}