Skip to content

Instantly share code, notes, and snippets.

@ketzacoatl
Last active August 13, 2016 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ketzacoatl/58fdb1905319035e360ad2c90240a827 to your computer and use it in GitHub Desktop.
Save ketzacoatl/58fdb1905319035e360ad2c90240a827 to your computer and use it in GitHub Desktop.
Shell Snippets, Tips, and Tricks

Useful Snippets for a few Random Ops Tasks

#!/bin/sh
# here is a helper script which sets up the go dependencies for nomad,
# builds the project executable, and packages that up in a zip file for
# distribution through your own channels. This zip can be push to S3,
# hosted on CM (salt), etc
# modify $VERSION, though that's just a surface detail
# run as root or with sudo
#apt-get update
#apt-get install -y build-essential curl \
# git-core mercurial bzr \
# libpcre3-dev pkg-config \
# zip default-jre qemu \
# libc6-dev-i386 \
# silversearcher-ag jq \
# htop vim unzip
# make sure you have $GOPATH and $GOROOT set, and $PATH updated
#export GOPATH=$HOME/.go
#export GOROOT=/opt/go
#export PATH="$PATH:$GOROOT/bin:$GOPATH/bin"
VERSION="0.4.1-dev"
HASHI_GIT="$GOPATH/src/github.com/hashicorp"
NOMAD_SRC="$HASHI_GIT/nomad"
ZIP_FILE="$HOME/nomad_${VERSION}_linux_amd64.zip"
mkdir -p $HASHI_GIT
git clone https://github.com/hashicorp/nomad $NOMAD_SRC
cd $NOMAD_SRC
make bootstrap
make dev
cd bin
zip $ZIP_FILE nomad
sha512sum $ZIP_FILE

To download and generate checksums for bunch of releases at once

docker-compose

First, set the VERSIONS:

VERSIONS="1.7.1 1.7.0 1.6.2 1.6.1 1.6.0 1.5.2"

Then wget and sha512sum those in a loop:

for v in $VERSIONS
  do
  wget -o download.log -O docker-compose-Linux-x86_64-$v https://github.com/docker/compose/releases/download/$v/docker-compose-Linux-x86_64
  sha512sum docker-compose-Linux-x86_64-$v
done

Output looks like:

06ab1b16d067292b7a0235805eaff13698f7ff9263d20a4368e535f1cb1ebe417fa85a51fd1e335128aa94afff26b6ff22f8f6af534e9e8caa73c4e390916955  docker-compose-Linux-x86_64-1.7.1
ebb70b96961c18d3cbdd045e742087a018ea3d20d223f7e23cdace0bd77a596bf68952d767b79c1dfada35123dfcc7f2dd3a1a6dc8134f8d5cf7e445665061b2  docker-compose-Linux-x86_64-1.7.0
71864f5fd7e1b1ba7b37b0f65b5d13e9825ee94f7e6de758c00813d0425ce46f38b3594fbeeaa692232e3b2f57bd26ca997876a7780b90b583091e1df13874d3  docker-compose-Linux-x86_64-1.6.2
9c6d9304df501e084c18379eca34f6e785dbb3c85cf400551a1dccf2e9be6da6f3305577ac5f89866bbc26e6dc2674699c79f75f289854470d53679ea7b08ab8  docker-compose-Linux-x86_64-1.6.1
f67ab4e2f225adae57813a4188803893a49aa8651a324af67c2554d35e4e72278a7d8a565a8021b3153227748f5b7937522dee3e2fe72f9ea211e8bc80a8abfd  docker-compose-Linux-x86_64-1.6.0
7dc80c9f86c9845bdd67624e3584c40024a54c8c2cb62e07c9a784625e68d7a9670dd4cd5aa2239917a23a8a149c68c053c24e60baa82ee3cf4cc7bbce65670e  docker-compose-Linux-x86_64-1.5.2

Hashicorp Tools

Set the app, and versions to target:

APP=vault
VERSIONS="0.5.1 0.5.2 0.5.3 0.6.0"

Then wget and sha512sum those in a loop:

for v in $VERSIONS
  do
  wget -o download.log -O ${APP}_${v}_linux_amd64.zip https://releases.hashicorp.com/$APP/$v/${APP}_${v}_linux_amd64.zip
  sha512sum ${APP}_${v}_linux_amd64.zip
done

Output looks like:

caeafe21ec01911cb888dd77e299d16457eb1b80844a68070489bfe078c5f8160067a5d8e82174e1e5d11f0e1a254272c71ab801b590ef556f1880c421f5fc12  vault_0.5.1_linux_amd64.zip
17e60dbb13d34db805f8a4659e177ab2c05ae164aba75debfd3d05197f1f270022436cd37c00050883271ac0ea4e66847495fa573880a1135f67d16155fa28d1  vault_0.5.2_linux_amd64.zip
82d8daa4251d23759381d6a8f2267a74ec27f15ef134f1db023d2ff1c7b7de81bfa50af614e752e0f9d6632505e3c04a2ed42613f31e0b14c0455e5a3a238ff9  vault_0.5.3_linux_amd64.zip
4efcf844c6ef4dafafb4174808936649c7dca3293f443e1de56a18fd052607f3b0d1b7111e74788eba5612b1d3b48988e16aa4cd2d4851b80696aa9b60483a4c  vault_0.6.0_linux_amd64.zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment