Skip to content

Instantly share code, notes, and snippets.

@GeoffWilliams
GeoffWilliams / apt-proxy
Last active August 9, 2017 12:49
debian/ubuntu magic proxy setting depending on assigned domain
#!/bin/bash
#
# /etc/network/if-up.d/apt-proxy
# set a proxy to use for apt depending what network we're on
APT_CONFIG="/etc/apt/apt.conf.d/10proxy"
HOME_NETWORK="lan.asio"
CACHE_SERVER="cache.${HOME_NETWORK}"
CACHE_PORT=3142
if [ "${DHCP4_DOMAIN_NAME}" == "${HOME_NETWORK}" ] ; then
@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 / openwrt_transparent_proxy_rules.txt
Last active March 22, 2018 16:43
transparent proxy rules for openwrt and squid
#
# Shell commands to run on router to enable transparent proxying
#
uci add firewall redirect
uci set firewall.@redirect[0].name='Transparent Proxy Redirect'
uci set firewall.@redirect[0].src=lan
uci set firewall.@redirect[0].proto=tcp
uci set firewall.@redirect[0].dest_port=3128
uci set firewall.@redirect[0].src_dport=80
@GeoffWilliams
GeoffWilliams / squid.conf
Last active November 11, 2018 18:14
squid config file for openwrt. Cache large binary files ONLY and enable intercept proxy
#
# Recommended minimum configuration:
#
# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
@GeoffWilliams
GeoffWilliams / privoxy_rules.txt
Created September 29, 2014 03:55
firewall rules - privoxy
uci add firewall redirect
uci set firewall.@redirect[0].name='Transparent Proxy Redirect (privox)'
uci set firewall.@redirect[0].src=lan
uci set firewall.@redirect[0].proto=tcp
uci set firewall.@redirect[0].dest_port=8118
uci set firewall.@redirect[0].src_dport=80
uci set firewall.@redirect[0].src_dip='!192.168.1.1'
uci set firewall.@redirect[0].dest_ip=192.168.1.1
uci set firewall.@redirect[0].target='DNAT'
uci commit firewall
@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