Skip to content

Instantly share code, notes, and snippets.

View cpswan's full-sized avatar
🏡

Chris Swan cpswan

🏡
View GitHub Profile
@cpswan
cpswan / show-ip-address.sh
Created March 21, 2015 18:02
Show IP address prior to login
#!/bin/sh
if [ "$METHOD" = loopback ]; then
exit 0
fi
# Only run from ifup.
if [ "$MODE" != start ]; then
exit 0
fi
@cpswan
cpswan / nginx_mod_security.sh
Last active August 29, 2015 14:17
Configure Nginx similarly to Ubuntu setup but with mod_security module added
./configure --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_spdy_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module --add-module=/root/modsecurity-2.9.0/nginx/modsecurity
@cpswan
cpswan / snapshot.sh
Created March 18, 2015 13:36
Create and retrieve a snapshot from a VNS3 manager
#!/bin/bash
command -v curl >/dev/null 2>&1 || { echo "This script requires curl, but it's not installed. Aborting." >&2; exit 1; }
MGRIP=10.0.0.10
APIPW=pa55Word
SNAPSHOTJSON=`curl -k -X POST -u api:$APIPW https://$MGRIP:8000/api/snapshots`
SNAPSHOTNAME=$(echo $SNAPSHOTJSON | grep -Po '"response":{.*?[^\\]"' | awk '{split($0,a,"{"); print a[2]}' )
curl -k -X GET -H 'Content-Type: application/json' https://api:$APIPW@$MGRIP:8000/api/snapshots/${SNAPSHOTNAME//\"} -o ${SNAPSHOTNAME//\"}
echo "Created and retrieved $SNAPSHOTNAME"
@cpswan
cpswan / clientpack.sh
Last active February 5, 2016 16:01
Get a VNS3 clientpack
#!/bin/bash
command -v openvpn >/dev/null 2>&1 || { echo "OpenVPN should be installed first. Aborting." >&2; exit 1; }
command -v curl >/dev/null 2>&1 || { echo "This script requires curl, but it's not installed. Aborting." >&2; exit 1; }
MGRIP=10.0.0.10
APIPW=pa55Word
NAME=$1
if [ -e /etc/openvpn/clientpack.ip ]; then
echo "VNS3 Clientpack already installed"
else
CLIENTPACKJSON=`curl -k -X POST -u api:$APIPW -H 'Content-Type: application/json' https://$MGRIP:8000/api/clientpacks/next_available`
@cpswan
cpswan / fixapt.sh
Created December 11, 2014 16:21
Fix apt on Ubuntu 12.04.5 to prevent hash mismatch errors
#!/bin/bash
sudo cp -arf /var/lib/dpkg /var/lib/dpkg.backup
sudo cp /var/lib/dpkg/status-old /var/lib/dpkg/status
sudo cp /var/lib/dpkg/available-old /var/lib/dpkg/available
sudo rm -rf /var/lib/dpkg/updates/*
sudo rm -rf /var/lib/apt/lists
sudo mkdir /var/lib/apt/lists
sudo mkdir /var/lib/apt/lists/partial
sudo apt-get clean
sudo apt-get update

Keybase proof

I hereby claim:

  • I am cpswan on github.
  • I am cpswan (https://keybase.io/cpswan) on keybase.
  • I have a public key whose fingerprint is B8F4 CBA3 EE20 D98C A9C0 DF60 9A17 F5CF B083 31FE

To claim this, I am signing this object:

@cpswan
cpswan / trusty-kernel.sh
Created June 2, 2014 09:48
Trusty kernel on 12.04
sudo apt-get install -y linux-image-generic-lts-trusty linux-headers-generic-lts-trusty
@cpswan
cpswan / cloud-localds
Last active December 29, 2016 18:44
cloud-localds from Ubuntu 13.04 - place in /usr/bin on older dists (e.g. 12.04)
#!/bin/bash
VERBOSITY=0
TEMP_D=""
DEF_DISK_FORMAT="raw"
DEF_FILESYSTEM="iso9660"
error() { echo "$@" 1>&2; }
errorp() { printf "$@" 1>&2; }
fail() { [ $# -eq 0 ] || error "$@"; exit 1; }
@cpswan
cpswan / es3client cmds
Created July 24, 2013 18:49
es3client commands and arguments
Available commands (grouped by type):
Base images:
create_base_image
delete_base_image
desc_base_images
Bundles:
add_content_to_bundle
create_bundle
delete_bundle
delete_content_from_bundle
@cpswan
cpswan / gcutil help
Last active December 20, 2015 04:38
gcutil help (version 1.8.2)
Command line tool for interacting with Google Compute Engine.
Please refer to http://developers.google.com/compute/docs/gcutil/tips for more
information about gcutil usage.
USAGE: gcutil [--global_flags] <command> [--command_flags] [args]
Any of the following commands: