Skip to content

Instantly share code, notes, and snippets.

@drwilco

drwilco/base.conf

Created Sep 8, 2011
Embed
What would you like to do?
setting up base lxc
lxc.network.type = veth
lxc.network.flags = up
lxc.network.name = eth0
lxc.network.link = virbr0
lxc.network.ipv4 = 10.13.37.2/24
dirs="/var/cache/lxc/lucid/apt /var/cache/lxc/lucid/cpan-sources /var/cache/lxc/lucid/mysql /var/cache/lxc/lucid/local /var/cache/lxc/lucid/repo"
for dir in $dirs; do
rm -rf $dir
mkdir -p $dir
done
lxc-create -n base -t lucid -f base.conf
mkdir -p /var/lib/lxc/base/rootfs/root/.ssh
cp ~drwilco/.ssh/id_rsa.pub /var/lib/lxc/base/rootfs/root/.ssh/authorized_keys
chroot /var/lib/lxc/base/rootfs/ passwd
rm /var/lib/lxc/base/rootfs/etc/init.d/resolvconf
cp -Rp /var/lib/lxc/base/rootfs/var/cache/apt/archives/* /var/cache/lxc/lucid/apt
cp -Rp /var/lib/lxc/base/rootfs/usr/local/* /var/cache/lxc/lucid/local
mkdir -p /root/.cpan/sources /var/cache/mysql /var/cache/repo /home/vagrant/fastly
cat <<EOF >> /var/lib/lxc/base/fstab
/var/cache/lxc/lucid/apt /var/cache/apt/archives none defaults,bind 0 0
/var/cache/lxc/lucid/cpan-sources /root/.cpan/sources none defaults,bind 0 0
/var/cache/lxc/lucid/mysql /var/cache/mysql none defaults,bind 0 0
/var/cache/lxc/lucid/local /usr/local none defaults,bind 0 0
/var/cache/lxc/lucid/repo /var/cache/repo none defaults,bind 0 0
/home/drwilco/dev/fastly /home/vagrant/fastly none defaults,bind 0 0
EOF
cat <<EOF > /var/lib/lxc/base/rootfs/etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 10.13.37.2
netmask 255.255.255.0
gateway 10.13.37.1
EOF
#!/bin/sh
if [ $# -ne 1 ]; then
echo "Enter box name "
exit 1
fi
ORIG_BOX="base"
cp -a /var/lib/lxc/$ORIG_BOX /var/lib/lxc/${1}
rm /var/lib/lxc/${1}/rootfs/etc/chef/client.pem /var/lib/lxc/${1}/rootfs/etc/ssh/ssh*key*
sed -i "s/$ORIG_BOX/${1}/g" /var/lib/lxc/${1}/config /var/lib/lxc/${1}/fstab /var/lib/lxc/${1}/rootfs/etc/hostname /var/lib/lxc/${1}/rootfs/etc/chef/client.rb
lxc-start -n $1 dpkg-reconfigure openssh-server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.