Skip to content

Instantly share code, notes, and snippets.

Avatar
🏡

Chris Swan cpswan

🏡
View GitHub Profile
@cpswan
cpswan / vm_time_sync.sh
Created Dec 24, 2015
Sync time between Ubuntu VM and VMware host
View vm_time_sync.sh
sudo apt-get install -y open-vm-tools
vmware-toolbox-cmd timesync enable
@cpswan
cpswan / overlay-docker-systemd.sh
Created Dec 24, 2015
Configure systemd to use overlay file system for Docker
View overlay-docker-systemd.sh
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 Oct 17, 2015
Attempt to create symlinks for best quality music from mix of wav and mp3
View linkit.sh
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 Sep 7, 2015
Suricata rule set for MS SQL Server
View mssql.rules
# 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 Aug 4, 2015
Extract VPC DNS IP from AWS instance metadata
View vpcdns.sh
#!/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 Jul 23, 2015
VNS3 IPsec tunnel example
View IPsec_example.sh
#!/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 Aug 29, 2015
Upgrade Docker and restart running containers
View upgrade-docker.sh
#!/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 Jun 15, 2022
Using nginx to proxy to an AWS ELB
View nginx.conf
daemon off;
worker_processes 1;
events { worker_connections 1024; }
http{
sendfile on;
@cpswan
cpswan / vns3.sh
Last active Aug 29, 2015
Launch and configure VNS3 from a single script
View vns3.sh
#!/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 Aug 29, 2015
Bash aliases for Docker
View .bash_aliases
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'