Skip to content

Instantly share code, notes, and snippets.

@GeoffWilliams
GeoffWilliams / squid.init
Last active August 29, 2015 14:06
init script for squid on openWRT
#!/bin/sh /etc/rc.common
# Squid 3.4 control script for openwrt
#
# Assumes a squid installation under /usr/local/squid, all other
# values are parsed from the squid config file so no need to edit
# locally
#
# Copyright (C) 2007 OpenWrt.org
START=99
@GeoffWilliams
GeoffWilliams / ubifs_support.diff
Created September 27, 2014 12:07
patch block.c from openwrt fstools to add support for systems using ubifs instead of mtdblocks
diff --git a/block.c b/block.c
index a1609b4..a68d62a 100644
--- a/block.c
+++ b/block.c
@@ -791,6 +791,19 @@ static int main_hotplug(int argc, char **argv)
return mount_device(find_block_info(NULL, NULL, path), 1);
}
+static int find_block_ubi(char *name, char *part, int plen)
+{
@GeoffWilliams
GeoffWilliams / aliases.txt
Created September 29, 2014 05:18
handy aliases
alias rake_api="/opt/puppet/bin/rake -f /opt/puppet/share/puppet-dashboard/Rakefile RAILS_ENV=production "
@GeoffWilliams
GeoffWilliams / apache-tomcat.spec
Last active August 29, 2015 14:07
Repackage apache-tomcat tarballs to allow side-by-side installation of different version at the same time. Once your RPM environment is setup, copy this .spec file to the SPECS directory and the downloaded tarball to the SOURCES directory. To build, run the command: rpmbuild --define 'upstream_version 7.0.56' \ --define 'vendor_name xxx'-ba SPEC…
#
# Example spec file to package apache-tomcat 'as-is' to install it under
# /usr/local
#
# To allow multiple version to be install at the same time with yum, the
# upstream version number is merged into the package name and the actual
# version field is reduced to a single incrementing digit to allow specific
# versions to be upgraded if required
#
@GeoffWilliams
GeoffWilliams / classroom_files.sh
Created November 21, 2014 11:00
Download a directory of files from webserver and save to /shared directory - for setting up classrooms
#!/bin/bash
#
# download files from laptop webserver in VM to teach fundamentals module
# usage:
# ./classroom_files.sh DOWNLOAD_URL
#
# DOWNLOAD_URL should be a directory of files on an http server
BASE_URL=$1
DOWNLOAD_DIR="/shared"
WGET_COMMAND="wget -r -nH --cut-dirs=2 --no-parent --reject=index.html* --directory-prefix=${DOWNLOAD_DIR}"
@GeoffWilliams
GeoffWilliams / rc.local
Created March 10, 2015 10:42
rc.local -- openwrt. fixes permissions on /dev/shm
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
chgrp nogroup /dev/shm
chmod g+w /dev/shm
exit 0
@GeoffWilliams
GeoffWilliams / publish_graph.sh
Created May 27, 2015 22:49
Install an apache web server and graphviz, then do a puppet apply and graph the results (assumes a class called ordering::mysql in the node graph)
#!/bin/bash
PUBDIR=$1
FINAL_DIR="/var/www/html/${PUBDIR}"
GRAPH_DIR="/var/opt/lib/pe-puppet/state/graphs/"
puppet apply -e "package {['httpd','graphviz']: ensure => present, }
service { 'httpd': ensure => 'running', }"
echo "publishing to $FINAL_DIR"
mkdir -p $FINAL_DIR
puppet apply --graph -e 'include ordering::mysql' && \
cd $GRAPH_DIR
@GeoffWilliams
GeoffWilliams / refresh_classes.sh
Created July 1, 2015 04:41
Refresh known classes in puppet using the NC API
#!/bin/bash
#
# This script will force a refresh of the classes available to use in the
# PE Node Classifier. This enables us to classify immediately, rather than
# waiting for the cache to expire.
#
# refresh_classes.sh
#
if [ "$#" -ne 0 ]
@GeoffWilliams
GeoffWilliams / node_classifier.sh
Last active October 20, 2015 06:36
node classifier on master script - how to talk to the NC api
curl -X POST \
https://$(facter fqdn):4433/classifier-api/v1/groups \
--cert /etc/puppetlabs/puppet/ssl/certs/$(facter fqdn).pem \
--key /etc/puppetlabs/puppet/ssl/private_keys/$(facter fqdn).pem \
--cacert /etc/puppetlabs/puppet/ssl/certs/ca.pem \
-H "Content-Type: application/json"
-d @data.json
@GeoffWilliams
GeoffWilliams / Vagrantfile
Created November 8, 2015 06:29
Vagrant Laptop provisioner code
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at