Skip to content

Instantly share code, notes, and snippets.

@nextrevision
nextrevision / unsource.sh
Last active November 16, 2015 16:10
Small script to unsource variables from a script or file. See http://nextrevision.github.io/2015/unsourcing-vars-files-in-bash/
#!/bin/bash -e
if [ -z "$1" ]; then
echo "usage: unsource.sh vars.env"
elif [ ! -f "$1" ]; then
echo "No such file: ${1}"
else
__start_env=$(mktemp -t unsource.XXXXXX)
__end_env=$(mktemp -t unsource.XXXXXX)
@nextrevision
nextrevision / Dockerfile
Last active April 2, 2021 00:58
Sempl Workflow with Docker Container
FROM ubuntu:trusty
RUN apt-get update && apt-get -y upgrade
RUN apt-get install -y apache2 wget
RUN wget -O /usr/local/bin/sempl \
https://raw.githubusercontent.com/nextrevision/sempl/0.2.1/sempl
RUN chmod 755 /usr/local/bin/sempl
ADD index.html.tmpl /app/index.html.tmpl
@nextrevision
nextrevision / registrycli
Last active August 29, 2015 14:23
CLI tool to interact with private docker registries
#!/bin/bash
# requirements:
# brew install gawk gsed
# settings file ~/.registry_settings
# REGISTRY="registry.acme.com"
# URL="https://${REGISTRY}:5000/v1"
# USERNAME="admin"
# PASSWORD="password"
@nextrevision
nextrevision / puppet_compile.rb
Created April 20, 2015 20:37
Compiles a puppet catalog without any puppet config files
# Requires automysqlbackup and stdlib module to be a child
# directory of the CWD
require "puppet"
require "json"
def run
manifest_path = './manifests/site.pp'
module_paths = ['../','./']
config_dir = nil
hiera_config = nil
@nextrevision
nextrevision / docker_pulp_env.sh
Created March 22, 2015 13:56
Configures a complete pulp environment with docker-machine
#!/bin/bash
ACTION=$1
PULP_IMAGES=(
pulp/mongodb
pulp/qpid
pulp/base
pulp/worker
pulp/apache
@nextrevision
nextrevision / extract_iso.sh
Created March 19, 2015 16:02
Uses isoinfo to extract all contents of an ISO to the given output directory
#!/bin/bash
# Description:
# Extracts all contents of an ISO to the given output directory
# Requires:
# Packages: genisoimage
ISO=$1
OUTDIR=${2:-"./out"}
usage() {
@nextrevision
nextrevision / watch_pps.sh
Created March 2, 2015 14:20
Watch PPS for a given interface
#!/bin/bash
[ -z $1 ] && { echo "usage: $0 [iface] [interval: default 1]"; exit 1; }
IFACE=$1
INTERVAL=${2:-1}
loop=1
PPS_RX=/sys/class/net/${IFACE}/statistics/rx_packets
PPS_TX=/sys/class/net/${IFACE}/statistics/tx_packets
@nextrevision
nextrevision / udpflood_scapy.py
Created March 2, 2015 13:56
Send a flood of UDP packets to a specific UDP port
#!/usr/bin/env python
#
# Requires:
# - scapy
# - tcpreplay
import sys
from scapy.all import *
if len(sys.argv) != 6:
@nextrevision
nextrevision / replay_and_test.py
Last active August 29, 2015 14:15
Duplicate/Replay and Reroute HTTP Request and Compare Responses with mitmproxy
# File: Vagrantfile
# Vagrant.configure(2) do |config|
# config.vm.box = "ubuntu/trusty64"
# end
#
# Process:
# $ wget https://gist.githubusercontent.com/nextrevision/f81cc9493af565613e6a/raw/e48f4229743f1f29e82fb17d7129c8dead3c51f0/replay_and_test.py
# $ vagrant up
# $ vagrant ssh
# $ sudo apt-get update
@nextrevision
nextrevision / pulp_upload.py
Last active September 9, 2023 12:08
Upload RPM to Pulp Repository and Publish
#!/usr/bin/env python
import os
import sys
import requests
import argparse
import json
import time
pulp_user = 'admin'