2 VMROOT=/var/lib/lxc/vmdebian6
4 -include ../config/default
5 -include ../config/$(shell hostname)
7 #default: vmdebian6-config netstaticdeb installkey
8 default: installtemplate
9 @echo "read the Makefile to see available targets"
12 [ ! -d /cgroup ] || mkdir /cgroup
14 checkmount: checkfstab /cgroup
15 grep -q 0 /cgroup/cpuset.cpu || mount /cgroup
18 grep ^cgroup /etc/fstab || (echo "You need to add cgroup entry to fstab \"cgroup /cgroup cgroup defaults 0 0\"" && false)
20 /var/lib/lxc/vmdebian6: beroot /usr/bin/lxc-info bridging
22 LANG=C MIRROR=$(DEBMIRROR) SUITE=$(DIST) ./lxc-debian6 -p $@
24 /usr/bin/lxc-info: beroot
25 apt-get install lxc bridge-utils
28 @grep -q '^iface br0 inet' /etc/network/interfaces || (echo "Please setup network bridging" && false)
30 vmdebian6-config: beroot /var/lib/lxc/vmdebian6
31 @grep -q lxc.utsname /var/lib/lxc/vmdebian6/config || \
32 (sh -c "echo \"lxc.utsname = vmdebian6\" >> $(VMROOT)/config" ; \
33 sh -c "echo \"lxc.network.type = veth\" >> $(VMROOT)/config" ; \
34 sh -c "echo \"lxc.network.flags = up\" >> $(VMROOT)/config" ; \
35 sh -c "echo \"lxc.network.link = br0\" >> $(VMROOT)/config" ; \
39 #sh -c "echo \"lxc.network.ipv4 = $(IPDEBBASE).$(VEIDDEB)/24\">> $(VMROOT)/config" ; \
43 lxc-stop -n vmdebian6 || true
44 lxc-destroy -n vmdebian6 || true
47 @grep -q "iface eth0 inet static" $(VMROOT)/rootfs/etc/network/interfaces || \
48 (sh -c "echo \"auto lo\" > $(VMROOT)/rootfs/etc/network/interfaces" ; \
49 sh -c "echo \"iface lo inet loopback\" >> $(VMROOT)/rootfs/etc/network/interfaces" ; \
50 sh -c "echo \"auto eth0\" >> $(VMROOT)/rootfs/etc/network/interfaces" ; \
51 sh -c "echo \"iface eth0 inet static\" >> $(VMROOT)/rootfs/etc/network/interfaces" ; \
52 sh -c "echo \" address $(IPDEBBASE).$(VEIDDEB)\" >> $(VMROOT)/rootfs/etc/network/interfaces" ; \
53 sh -c "echo \" netmask 255.255.255.0\" >> $(VMROOT)/rootfs/etc/network/interfaces" ; \
54 sh -c "echo \" gateway $(IPDEBBASE).1\" >> $(VMROOT)/rootfs/etc/network/interfaces" ; \
58 #sh -c "echo \" dns-nameservers $(IPDEBDNS)\" >> $(VMROOT)/rootfs/etc/network/interfaces" ; \
59 #sh -c "echo \" dns-search $(IPDEBDOMAIN)\" >> $(VMROOT)/rootfs/etc/network/interfaces" ; \
62 installkey: beroot ssh
63 [ -d $(VMROOT)/root/.ssh ] || mkdir -p $(VMROOT)/rootfs/root/.ssh
64 cp $(SSHPUBKEY) $(VMROOT)/rootfs/root/.ssh/authorized_keys
65 [ -d $(VMROOT)/etc/ssh ] || mkdir -p $(VMROOT)/rootfs/etc/ssh
66 cp ssh/ssh_host_* $(VMROOT)/rootfs/etc/ssh/
69 [ -e ssh ] || (echo "You need a ssh dir containing host keys like /etc/ssh_host_*" && false)
72 echo "debian6.local" > $(VMROOT)/rootfs/etc/hostname
73 grep -q debian6.local $(VMROOT)/rootfs/etc/hosts || echo "$(IPDEBBASE).$(VEIDDEB) debian6.local debian6" >> $(VMROOT)/rootfs/etc/hosts
76 @[ $(shell id -u) = "0" ] || (echo "you should be root to run this" ; exit 1)
78 lxcstart: /cgroup/tasks
79 lxc-start -n vmdebian6 -d
89 installtemplate: beroot
90 cat lxc-debian6 | sed 's!http://cdn.debian.net/debian/!$(DEBMIRROR)!' > /usr/lib/lxc/templates/lxc-debian6
91 cp lxc-debian6.postinst /usr/lib/lxc/templates/
92 cp lxc-centos5 /usr/lib/lxc/templates/
93 cp lxc-centos5.postinst /usr/lib/lxc/templates/
96 /usr/bin/lxc-create -n debian6.local -f config.debian6 -t debian6
99 /usr/bin/lxc-create -n centos5.local -f config.centos5 -t centos5
102 sudo LANG=C /usr/bin/lxc-start -n debian6.local -d
105 sudo LANG=C /usr/bin/lxc-stop -n debian6.local
108 sudo LANG=C /usr/bin/lxc-start -n centos5.local -d
111 sudo LANG=C /usr/bin/lxc-stop -n centos5.local
114 sudo LANG=C /usr/bin/lxc-stop -n debian6.local
115 sudo LANG=C /usr/bin/lxc-destroy -n debian6.local
118 sudo LANG=C /usr/bin/lxc-stop -n centos5.local
119 sudo LANG=C /usr/bin/lxc-destroy -n centos5.local