Skip to content

Instantly share code, notes, and snippets.

View cpswan's full-sized avatar
🏡

Chris Swan cpswan

🏡
View GitHub Profile
@cpswan
cpswan / vm_time_sync.sh
Created December 24, 2015 16:29
Sync time between Ubuntu VM and VMware host
sudo apt-get install -y open-vm-tools
vmware-toolbox-cmd timesync enable
@cpswan
cpswan / overlay-docker-systemd.sh
Created December 24, 2015 15:07
Configure systemd to use overlay file system for Docker
sudo mkdir /etc/systemd/system/docker.service.d
sudo bash -c 'cat <<EOF > /etc/systemd/system/docker.service.d/overlay.conf
[Service]
ExecStart=
ExecStart=/usr/bin/docker daemon -H fd:// --storage-driver=overlay
EOF'
sudo systemctl daemon-reload
sudo systemctl restart docker
@cpswan
cpswan / linkit.sh
Last active October 17, 2015 11:28
Attempt to create symlinks for best quality music from mix of wav and mp3
while read -u 3 outerdir
do
cd "${outerdir}"
ls -1 ../../wav/"${outerdir}" > list
while read -u 4 innerdir
do
ln -s ../../wav/"${outerdir}"/"${innerdir}" "${innerdir}"
done 4< list
done 3< test
@cpswan
cpswan / mssql.rules
Created September 7, 2015 10:53
Suricata rule set for MS SQL Server
# Emerging Threats
#
# This distribution may contain rules under two different licenses.
#
# Rules with sids 1 through 3464, and 100000000 through 100000908 are under the GPLv2.
# A copy of that license is available at http://www.gnu.org/licenses/gpl-2.0.html
#
# Rules with sids 2000000 through 2799999 are from Emerging Threats and are covered under the BSD License
# as follows:
#
@cpswan
cpswan / vpcdns.sh
Created August 4, 2015 19:38
Extract VPC DNS IP from AWS instance metadata
#!/bin/bash
MAC="$(curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/)"
VPCCIDR="$(curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/"$MAC"/vpc-ipv4-cidr-block)"
VPCNET="${VPCCIDR%%/*}"
VPCBASE="$(echo "$VPCNET" | cut -d"." -f1-3)"
VPCDNS="$VPCBASE"'.2'
echo "$VPCDNS"
@cpswan
cpswan / IPsec_example.sh
Created July 23, 2015 20:46
VNS3 IPsec tunnel example
#!/bin/bash
# Set credentials and address for VNS3 manager
VNS3_PW=pa55Word
VNS3_IP=10.11.22.33
# Use IPsec connection 2
VNS3_EP=2
# Clear out any existing IPsec tunnels
while true; do
TUNNEL=$(curl -s -k -X GET -u api:"$VNS3_PW" \
https://"$VNS3_IP":8000/api/ipsec | python -mjson.tool \
@cpswan
cpswan / upgrade-docker.sh
Last active August 29, 2015 14:23
Upgrade Docker and restart running containers
#!/bin/bash
datenow=$(date +%s)
sudo docker ps > /tmp/docker."$datenow"
sudo apt-get update && sudo apt-get install -y lxc-docker
sudo docker start $(tail -n +2 /tmp/docker."$datenow" | cut -c1-12)
@cpswan
cpswan / nginx.conf
Last active May 29, 2023 12:20
Using nginx to proxy to an AWS ELB
daemon off;
worker_processes 1;
events { worker_connections 1024; }
http{
sendfile on;
@cpswan
cpswan / vns3.sh
Last active August 29, 2015 14:19
Launch and configure VNS3 from a single script
#!/bin/bash
VNS3_AMI=ami-ea084f82
VNS3_TYPE=t2.small
VNS3_SUBNET=subnet-b123b456
VNS3_GROUP=sg-ea123456
VNS3_NAME=myVNS3
VNS3_PW=pa55Word
VNS3_LIC=license.gpg
VNS3_TK=MyS3cret
@cpswan
cpswan / .bash_aliases
Last active August 29, 2015 14:17
Bash aliases for Docker
alias ds='sudo docker start'
alias dt='sudo docker stop'
alias dps='sudo docker ps'
alias da='sudo docker attach'
alias di='sudo docker inspect'