Created
December 6, 2012 21:33
-
-
Save samba/4228678 to your computer and use it in GitHub Desktop.
LXC Setup script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# THIS IS A WORK IN PROGRESS, might break things. | |
# Sets up LXC host configuration in AWS EC2 environments | |
# Reference: http://www.activestate.com/blog/2011/10/virtualization-ec2-cloud-using-lxc | |
# Exit NOW because we don't want to blow anything up outside our test systems | |
# (This is being drafted in a production environment.) | |
exit 1 | |
echo 'none /sys/fs/cgroup cgroup defaults 0 0' >> /etc/fstab | |
mount /sys/fs/cgroup | |
apt-get install lxc debootstrap bridge-utils dnsmasq | |
brctl addbr br0 | |
brctl setfd br0 0 | |
ifconfig br0 192.168.3.1 up | |
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE | |
sysctl -w net.ipv4.ip_forward=1 | |
[ -f /etc/dnsmasq.conf ] && mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig | |
cat > /etc/dnsmasq.conf <<END | |
domain-needed | |
bogus-priv | |
interface = br0 | |
listen-address = 127.0.0.1 | |
listen-address = 192.168.3.1 | |
expand-hosts | |
domain = containers | |
dhcp-range = 192.168.3.50,192.168.3.200,1h | |
END | |
dhcp_conf=`mktemp /tmp/dhcpconf.XXXXX` | |
cat > $dhcp_conf <<END | |
prepend domain-name-servers 127.0.0.1; | |
prepend domain-search "containers."; | |
END | |
cat $dhcp_conf /etc/dhcp3/dhclient.conf > ${dhcp_conf}.2 | |
mv ${dhcp_conf}.2 /etc/dhcp3/dhclient.conf | |
dhclient3 -e IF_METRIC=100 -pf /var/run/dhclient.eth0.pid -lf /var/lib/dhcp3/dhclient.eth0.leases eth0 | |
service dnsmasq restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment