Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
#
make_mac () {
echo "6A:AA:`ifconfig eth0 | head -1 | sed 's/.*HWaddr...:..:\(..:..:..:..\).*/\1/g'`"
}
if ! test -d /dev/net; then
mkdir /dev/net;
mknod /dev/net/tun c 10 200
void@tahr:~/docker/etest$ cat Dockerfile
FROM ubuntu
RUN useradd -m user
RUN echo 'export TOKEN=ok' >> /home/user/.bashrc
USER user
void@tahr:~/docker/etest$ docker build -t local/test .
Sending build context to Docker daemon 2.048 kB
Sending build context to Docker daemon
@flashvoid
flashvoid / gist:7bcc7c7813114e1bd238
Last active October 14, 2015 17:27
linux network namespace routing
ip netns add space-a
ip netns add space-b
ip link add veth0 type veth peer name veth1
ip link set veth1 netns space-a
ip link add veth2 type veth peer name veth3
ip link set veth3 netns space-b
ifconfig veth0 0.0.0.0 up
ifconfig veth2 0.0.0.0 up
ip netns exec space-a ifconfig veth1 192.168.1.130/32 up
ip netns exec space-a route add -host 192.168.7.141 dev veth1
@flashvoid
flashvoid / gist:df41829da31162757938
Last active August 29, 2015 14:26
align windows from command line
SIZE=400; STEP=100; for i in `wmctrl -l | awk '/VLC/ { print $1 }'`; do wmctrl -ir $i -e 100,$STEP,100,$SIZE,$SIZE; STEP=$(( $STEP + $SIZE )); done
==terminal 1===
ip netns add space-a
ip netns add space-b
ip link add veth0 type veth peer name veth1
ip link set veth1 netns space-a
ip link add veth2 type veth peer name veth3
ip link set veth3 netns space-b
ifconfig veth0 10.0.0.0/31 up
ifconfig veth2 10.0.0.2/31 up
route add -host 10.0.0.1 dev veth0
void@tahr:/tmp/tmp.6ZYoSGn0V1$ cat Makefile
a := foo
b := bar
var := $(sort $(a) $(b))
all:
echo $(var)
void@tahr:/tmp/tmp.6ZYoSGn0V1$ make
echo bar foo
bar foo
@flashvoid
flashvoid / gist:d63ad92584ab09c26a88
Last active August 29, 2015 14:27
userdata for calco-chef
#!/bin/bash -x
if ! ls /etc/apt/sources.list.d/ | grep project-calico-icehouse-trusty.list; then
dpkg --add-architecture i386
apt-add-repository -y ppa:project-calico/icehouse
fi
apt-get update && apt-get install -y git docker.io
IP=`ec2metadata --local-ipv4`
@flashvoid
flashvoid / gist:bf1755807c7cddc0c7ed
Created August 20, 2015 21:50
CREATE_PORT_POSTCOMMIT calico
{
'status': 'DOWN',
'binding: host_id': u'ip-192-0-2-180',
'allowed_address_pairs': [
],
'device_owner': 'network: dhcp',
'binding: profile': {
},
@flashvoid
flashvoid / gist:9f3ac0d6d83376321f30
Created August 20, 2015 21:52
UPDATE_PORT_POSTCOMMIT calico
{
'status': u'DOWN',
'binding: host_id': u'ip-192-0-2-180',
'allowed_address_pairs': [
],
'extra_dhcp_opts': [
],
'device_owner': u'network: dhcp',
@flashvoid
flashvoid / gist:71a6444df2ec380a9848
Last active November 11, 2015 03:43
AWS ebs snapshots
#!/bin/bash -e
# creating snapshot of jenkins instance
MOUNTPOINT=/u1
DEVICE="/dev/xvdf" # TODO discover
AWS_DEVICE="/dev/sdf"
LINEAGE="ci"
KEEP=10 # how many shapshots to keep