Skip to content

Instantly share code, notes, and snippets.

cat ec2din.txt | \
perl -pe ' \
s{us-east-\S+}{us-east-xx}g;
s{i-[0-9a-f]{8}}{i-xxxxxxxx}g;
s{vol-[0-9a-f]{8}}{vol-xxxxxxxx}g;
s{\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d.\d\d\dZ}{dddd-dd-ddTdd:dd:dd.dddZ}g;
s{(arn:aws:cloudformation):\S+}{$1:xxxxxx}g;
s{/dev/sd\S+}{/dev/sdxxx}g;;
s{(\w)-[0-9a-f]{8}(,?)}{$1-xxxxxxxx$2}g;
s{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-fx]{12}_\S+}{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx}g;
@dstrctrng
dstrctrng / gist:5315149
Last active December 15, 2015 19:59
Running a docker with runsvdir, ssh in, then destroy it
function d {
did=$(docker run -d precise runsvdir /etc/service)
ip=$(docker inspect $did | grep IpAddress | cut -d'"' -f4)
nc -z $ip 22 && ssh -oStrictHostKeyChecking=no root@$ip
docker kill $did
}
@dstrctrng
dstrctrng / gist:5314483
Created April 4, 2013 21:22
Mirror Ubuntu packages installed on the local system
#!/bin/bash
mkdir -p ubuntu/{dists,pool}
meh=$(
rsync -iaO --exclude ubuntu --exclude pool --exclude dists rsync://archive.ubuntu.com/ubuntu/. ubuntu/
for a in dists/{lucid,precise}{,-{backports,security,updates}}; do
rsync -iaO --exclude 'installer-*' rsync://archive.ubuntu.com/ubuntu/$a/. ubuntu/$a/
done
2538 ? S 0:00 | | \_ nginx: master process nginx -g daemon off;
2547 ? S 0:00 | | \_ nginx: worker process
2548 ? S 0:00 | | \_ nginx: worker process
2549 ? S 0:00 | | \_ nginx: worker process
2550 ? S 0:00 | | \_ nginx: worker process
2535 ? S 0:00 | \_ runsv memcached
2541 ? Sl 0:00 | | \_ memcached -u memcache
2536 ? S 0:00 | \_ runsv redis
2540 ? S 0:00 | | \_ redis-server
2537 ? S 0:00 | \_ runsv ssh
PID TTY STAT TIME COMMAND
1 ? S 0:00 runsvdir /etc/service
4 ? S 0:00 runsv nginx
8 ? S 0:00 \_ nginx: master process nginx -g daemon off;
17 ? S 0:00 \_ nginx: worker process
18 ? S 0:00 \_ nginx: worker process
19 ? S 0:00 \_ nginx: worker process
20 ? S 0:00 \_ nginx: worker process
5 ? S 0:00 runsv memcached
10 ? Sl 0:00 \_ memcached -u memcache
root 1378 0.1 2.2 486092 11344 ? Ssl 07:00 0:04 /usr/local/bin/docker -d
root 1539 0.0 0.2 21164 1132 ? S 07:01 0:00 \_ /usr/bin/lxc-start -n 687378f63f96399519662486e439c4c524574da8bb180058ca71aca570641031 -f /var/lib/docker/containers/687378f63f96399519662486e439c4c524574da8bb180058ca71a
root 1544 0.0 0.0 188 24 ? S 07:01 0:00 | \_ runsvdir -P /etc/service
root 1575 0.0 0.0 164 4 ? Ss 07:01 0:00 | \_ runsv ssh
root 1576 0.0 0.5 49956 2844 ? S 07:01 0:00 | \_ /usr/sbin/sshd -D
root 3887 0.0 0.2 21164 1160 ? S 07:40 0:00 \_ /usr/bin/lxc-start -n 24e1604df2befa7de335e14c991c9b6b99b609192c881d13f6e51fe92d08fe41 -f /var/lib/docker/containers/24e1604df2befa7de335e14c991c9b6b99b609192c881d13f6e51
root 3894 0.0 0.0 188 32 ? S 07:40 0:00 \_ runsvdir -P /etc/service
root 3925 0.0 0.0 164 4 ? Ss 07:40 0:00
root@f7586939fe50:~# ps axuf
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 188 24 ? S 23:36 0:00 runsvdir -P /etc/service
root 514 0.0 0.0 164 4 ? Ss 23:36 0:00 runsv ssh
root 515 0.0 0.5 49956 2848 ? S 23:36 0:00 \_ /usr/sbin/sshd -D
root 516 0.0 0.7 73356 3628 ? Ss 23:37 0:00 \_ sshd: root@pts/0
root 600 0.8 0.8 23204 4440 pts/0 Ss 23:37 0:00 \_ -bash
root 635 0.0 0.2 18128 1124 pts/0 R+ 23:37 0:00 \_ ps axuf
root@c4a6608aaff6:~# ps axf
PID TTY STAT TIME COMMAND
1 ? S 0:00 bash -c aptitude install -y openssh-server; mkdir -p /var/run/sshd; mkdir /root/.ssh; wget -O /root/.ssh/authorized_keys https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub ; /usr/sbin/sshd -d
511 ? S 0:00 sshd: root@pts/0
595 pts/0 Ss 0:00 \_ -bash
642 pts/0 R+ 0:00 \_ ps axf
@dstrctrng
dstrctrng / gist:5257727
Last active December 15, 2015 12:08
ubuntu-precise-image.sh
#!/bin/bash
# run as a non-root user on Ubuntu Precise
export DEBIAN_FRONTEND="noninteractive"
sudo aptitude -y install lxc bsdtar libsqlite3-dev git pkg-config
sudo aptitude -y install linux-image-extra-$(uname -r)
sudo aptitude -y install golang 0<&-
cd
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.