1 -include ../config/default
2 -include ../config/$(shell hostname)
4 default: installtemplate
7 @echo "read the Makefile to see available targets"
10 [ -d /cgroup ] || ( if [ $(shell id -u) != "0" ] then; echo "you should be root to run this" ; else; mkdir /cgroup; fi
12 checkmount: checkfstab /cgroup
13 grep -q 0 /cgroup/cpuset.cpus || mount /cgroup
16 @grep ^cgroup /etc/fstab || (echo "You need to add cgroup entry to fstab 'cgroup /cgroup cgroup defaults 0 0'" && false)
19 @[ -d $@ ] || sudo apt-get install lxc
21 /usr/share/bridge-utils:
22 @[ -d $@ ] || apt-get install bridge-utils
25 @[ -f $@ ] || sudo apt-get install netmask
28 @[ -f $@ ] || sudo apt-get install rinse
31 @[ -f $@ ] || sudo apt-get install uml-utilities
34 @grep -q '^iface br0 inet' /etc/network/interfaces || (echo "Please setup network bridging" && false)
37 [ -e ssh ] || (echo "You need a ssh dir containing host keys like /etc/ssh_host_*" && false)
40 echo "debian7.local" > $(VMROOT)/rootfs/etc/hostname
41 grep -q debian7.local $(VMROOT)/rootfs/etc/hosts || echo "$(IPDEBBASE).$(VEIDDEB) debian7.local debian7" >> $(VMROOT)/rootfs/etc/hosts
44 @[ $(shell id -u) = "0" ] || (echo "you should be root to run this" ; exit 1)
52 installtemplate: /usr/lib/lxc/templates/lxc-debian7 /usr/lib/lxc/templates/lxc-debian6 /usr/lib/lxc/templates/lxc-centos5 /usr/lib/lxc/templates/lxc-centos6
54 /usr/lib/lxc/templates/lxc-debian6: lxc-debian6 /usr/lib/lxc
55 cat lxc-debian6 | sed 's!http://cdn.debian.net/debian/!$(DEBMIRROR)!' > /usr/lib/lxc/templates/lxc-debian6
56 chmod 755 /usr/lib/lxc/templates/lxc-debian6
58 /usr/lib/lxc/templates/lxc-debian7: lxc-debian7 /usr/lib/lxc
59 cat lxc-debian7 | sed 's!http://cdn.debian.net/debian/!$(DEBMIRROR)!' > /usr/lib/lxc/templates/lxc-debian7
60 chmod 755 /usr/lib/lxc/templates/lxc-debian7
62 /usr/lib/lxc/templates/lxc-centos5: lxc-centos5 /usr/lib/lxc
63 cp lxc-centos5 /usr/lib/lxc/templates/
65 /usr/lib/lxc/templates/lxc-centos6: lxc-centos6 /usr/lib/lxc
66 cp lxc-centos6 /usr/lib/lxc/templates/
69 sudo /usr/bin/lxc-create -n dhdebian7.local -f config.debian7 -t debian7
71 createcos: /usr/bin/netmask /usr/bin/rinse
72 sudo /usr/bin/lxc-create -n dhcentos5.local -f config.centos5 -t centos5
75 sudo LANG=C /usr/bin/lxc-start -n dhdebian7.local -d
78 sudo LANG=C /usr/bin/lxc-stop -n dhdebian7.local
81 sudo LANG=C /usr/bin/lxc-start -n dhcentos5.local -d
84 sudo LANG=C /usr/bin/lxc-stop -n dhcentos5.local
87 sudo LANG=C /usr/bin/lxc-stop -n dhdebian7.local
88 sudo LANG=C /usr/bin/lxc-destroy -n dhdebian7.local
91 sudo LANG=C /usr/bin/lxc-stop -n dhcentos5.local
92 sudo LANG=C /usr/bin/lxc-destroy -n dhcentos5.local