Skip to content

Instantly share code, notes, and snippets.

@wakwanza
wakwanza / ansible-role-nutcracker
Last active August 29, 2015 14:00
Ansible play to install Twemproxy(Nutcracker)
---
- name: Download and unpack the twemproxy/nutcracker source
shell: creates=/tmp/nutcracker-0.3.0 wget -O - https://twemproxy.googlecode.com/files/nutcracker-0.3.0.tar.gz | tar -xz -C /tmp
- name: Install twemproxy
command: {{ item }} chdir=/tmp/nutcracker-0.3.0
with_items:
- ./configure --enable-debug=log
- make
- make install
@wakwanza
wakwanza / nginx.spec
Last active April 28, 2017 00:53
spec file for nginx build with extra functionality modules
#
# Additional modules follow Download to SOURCE directory
# for TCP proxy module untar the source and patch with
# patch -p1 < /path/to/nginx_tcp_proxy_module/tcp.patch
# recreate the tar and replace in SOURCE directory
#
# * git clone https://github.com/yaoweibin/nginx_tcp_proxy_module.git
# * wget https://www.openssl.org/source/openssl-{ STABLE }.tar.gz
# * wget https://github.com/openresty/headers-more-nginx-module/archive/v0.25.tar.gz
# * git clone https://github.com/nulab/nginx-length-hiding-filter-module.git
@wakwanza
wakwanza / ndn-cxx.spec
Last active August 29, 2015 14:16
spec file for custom rpms of the ndn-cxx library
Name: ndn-cxx
Version: 0.3.1
Release: 1
Summary: NDN C++ library with eXperimental eXtensions
Group: System Environment/Network library
License: LGPL 3.0
URL: http://www.named-data.net/doc/ndn-cxx/
Source0: %{_sourcedir}/%{name}-%{version}.tar.bz2
BuildRequires: boost
@wakwanza
wakwanza / nfd.spec
Last active August 29, 2015 14:16
rpm spec to build the nfd for named data networking
%global logdir /var/log/%name
Name: nfd
Version: 0.3.1
Release: 1
Summary: Named Data Networking Forwarding Daemon
Group: System Environment/Network Daemons
License: GPL 3.0
URL: http://named-data.net/doc/NFD/current/
Source0: %{_sourcedir}/%{name}-%{version}.tar.bz2
@wakwanza
wakwanza / ec2.py
Created March 11, 2015 09:30
Modified ansible ec2.py for credential export from cred.ini in same folder as ec2.ini
#!/usr/bin/env python
'''
EC2 external inventory script
=================================
Generates inventory that Ansible can understand by making API request to
AWS EC2 using the Boto library.
NOTE: This script assumes Ansible is being executed where the environment
@wakwanza
wakwanza / extern.py
Created March 26, 2015 23:59
shlex and subprocess Popen in python to execute external command and get return code plus result.
#!/usr/bin/python
import subprocess, sys, shlex
def main(argv):
args = shlex.split(argv)
op = subprocess.Popen(args,stdout=subprocess.PIPE)
result, err = op.communicate()
op.wait()
tw = op.returncode
# Use the result , error and return code here for extra processing
@wakwanza
wakwanza / builds3fuse.sh
Created April 2, 2015 07:21
Build latest fuse and s3fs-fuse module for Google Cloud Storage and AWS S3 , Centos6
#!/bin/sh
#
function compile_bin { ./configure --prefix=/usr; make && make install; wait 3; }
function download_untar { wget -O - "http://downloads.sourceforge.net/fuse/fuse-2.9.3.tar.gz" | tar -xzvf - ; wget -O - "https://github.com/s3fs-fuse/s3fs-fuse/archive/v1.78.tar.gz" | tar -xzvf - ; }
echo "Build the S3 fuse with native binaries"
download_untar
#
cd fuse-2.9.3
compile_bin
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib64/pkgconfig/
@wakwanza
wakwanza / archivelogs.sh
Created April 5, 2015 11:57
log backup script for nginx and fail2ban
#!/bin/bash
BackupDir=logbackup
HomeDir=/archive/$HOSTNAME
# Set $BackupYear equal to 4 characters of $f starting with the first character, the YYYY
BackupYear=$(date +"%Y")
# Set $BackupMonth equal to 2 characters of $f starting with the fifth character, the MM
BackupMonth=$(date +"%m")
# Test to see if the main backup directory exists if not then create it
if [ ! -d $HomeDir/$BackupDir ]; then
@wakwanza
wakwanza / mountformat.sh
Created April 5, 2015 12:16
Mount and format disk on Google Compute Engine
#!/bin/bash
# Mount and format the disks
sudo mkdir -p /data
sudo yum install xfsprogs -y
sudo /usr/share/google/safe_format_and_mount -m "mkfs.xfs -isize=512" /dev/sdb /data
sudo echo "Mount persists"
sudo sh -c "echo \"/dev/sdb /data xfs noatime,data=writeback,errors=remount-ro 0 1\" >> /etc/fstab"
sudo echo "fstab done"
@wakwanza
wakwanza / setnat.sh
Created April 5, 2015 12:16
Create NAT route on GCE
#!/bin/bash
#
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD --in-interface eth0 -j ACCEPT
sudo service iptables save
sudo sed -i 's/.*net.ipv4.ip_forward = 0*/net.ipv4.ip_forward = 1/' /etc/sysctl.conf
sudo sysctl -e -p /etc/sysctl.conf
sudo service iptables restart