2 VMROOT=/var/lib/lxc/vmdebian6
4 -include ../config/default
5 -include ../config/$(shell hostname)
7 default: vmdebian6-config netstaticdeb installkey
8 @echo "read the Makefile to see available targets"
11 [ ! -d /cgroup ] || mkdir /cgroup
13 checkmount: checkfstab /cgroup
14 grep -q 0 /cgroup/cpuset.cpu || mount /cgroup
17 grep ^cgroup /etc/fstab || (echo "You need to add cgroup entry to fstab \"cgroup /cgroup cgroup defaults 0 0\"" && false)
19 /var/lib/lxc/vmdebian6: beroot /usr/bin/lxc-info bridging
21 LANG=C MIRROR=$(DEBMIRROR) SUITE=$(DIST) ./lxc-debian6 -p $@
23 /usr/bin/lxc-info: beroot
24 apt-get install lxc bridge-utils
27 @grep -q '^iface br0 inet' /etc/network/interfaces || (echo "Please setup network bridging" && false)
29 vmdebian6-config: beroot /var/lib/lxc/vmdebian6
30 @grep -q lxc.utsname /var/lib/lxc/vmdebian6/config || \
31 (sh -c "echo \"lxc.utsname = vmdebian6\" >> $(VMROOT)/config" ; \
32 sh -c "echo \"lxc.network.type = veth\" >> $(VMROOT)/config" ; \
33 sh -c "echo \"lxc.network.flags = up\" >> $(VMROOT)/config" ; \
34 sh -c "echo \"lxc.network.link = br0\" >> $(VMROOT)/config" ; \
38 #sh -c "echo \"lxc.network.ipv4 = $(IPDEBBASE).$(VEIDDEB)/24\">> $(VMROOT)/config" ; \
42 lxc-stop -n vmdebian6 || true
43 lxc-destroy -n vmdebian6 || true
46 @grep -q "iface eth0 inet static" $(VMROOT)/rootfs/etc/network/interfaces || \
47 (sh -c "echo \"auto lo\" > $(VMROOT)/rootfs/etc/network/interfaces" ; \
48 sh -c "echo \"iface lo inet loopback\" >> $(VMROOT)/rootfs/etc/network/interfaces" ; \
49 sh -c "echo \"auto eth0\" >> $(VMROOT)/rootfs/etc/network/interfaces" ; \
50 sh -c "echo \"iface eth0 inet static\" >> $(VMROOT)/rootfs/etc/network/interfaces" ; \
51 sh -c "echo \" address $(IPDEBBASE).$(VEIDDEB)\" >> $(VMROOT)/rootfs/etc/network/interfaces" ; \
52 sh -c "echo \" netmask 255.255.255.0\" >> $(VMROOT)/rootfs/etc/network/interfaces" ; \
53 sh -c "echo \" gateway $(IPDEBBASE).1\" >> $(VMROOT)/rootfs/etc/network/interfaces" ; \
57 #sh -c "echo \" dns-nameservers $(IPDEBDNS)\" >> $(VMROOT)/rootfs/etc/network/interfaces" ; \
58 #sh -c "echo \" dns-search $(IPDEBDOMAIN)\" >> $(VMROOT)/rootfs/etc/network/interfaces" ; \
61 installkey: beroot ssh
62 [ -d $(VMROOT)/root/.ssh ] || mkdir -p $(VMROOT)/rootfs/root/.ssh
63 cp $(SSHPUBKEY) $(VMROOT)/rootfs/root/.ssh/authorized_keys
64 [ -d $(VMROOT)/etc/ssh ] || mkdir -p $(VMROOT)/rootfs/etc/ssh
65 cp ssh/ssh_host_* $(VMROOT)/rootfs/etc/ssh/
68 [ -e ssh ] || (echo "You need a ssh dir containing host keys like /etc/ssh_host_*" && false)
71 echo "debian6.local" > $(VMROOT)/rootfs/etc/hostname
72 grep -q debian6.local $(VMROOT)/rootfs/etc/hosts || echo "$(IPDEBBASE).$(VEIDDEB) debian6.local debian6" >> $(VMROOT)/rootfs/etc/hosts
75 @[ $(shell id -u) = "0" ] || (echo "you should be root to run this" ; exit 1)
77 lxcstart: /cgroup/tasks
78 lxc-start -n vmdebian6 -d
88 installtemplate: beroot
89 cat lxc-debian6 | sed 's!http://cdn.debian.net/debian/!$(DEBMIRROR)!' > /usr/lib/lxc/templates/lxc-debian6
90 cp lxc-debian6.postinst /usr/lib/lxc/templates/
93 sudo LANG=C MIRROR=$(DEBMIRROR) SUITE=$(DIST) /usr/bin/lxc-create -n debian6.local -f config.debian6 -t debian6
96 sudo LANG=C /usr/bin/lxc-start -n debian6.local -d
99 sudo LANG=C /usr/bin/lxc-stop -n debian6.local
100 sudo LANG=C /usr/bin/lxc-destroy -n debian6.local