3 test -z "$1" && echo "usage: $0 /path/to/ve/private [10.60.0.253]" && exit
8 netmask=`grep netmask /etc/network/interfaces | head -1 | sed 's/^.*netmask *//'`
9 gateway=`grep gateway /etc/network/interfaces | head -1 | sed 's/^.*gateway *//'`
11 test -z "$ip" && ip=10.60.0.253
13 path=/$dir/etc/inittab
19 if ! grep "$1" $path ; then
24 append "z6:6:respawn:/sbin/sulogin"
25 append "1:2345:respawn:/sbin/getty 38400 console"
26 append "c1:12345:respawn:/sbin/getty 38400 tty1 linux"
27 append "c2:12345:respawn:/sbin/getty 38400 tty2 linux"
28 append "c3:12345:respawn:/sbin/getty 38400 tty3 linux"
29 append "c4:12345:respawn:/sbin/getty 38400 tty4 linux"
31 if ! diff -uw $path $tmp ; then
32 cp $path $path.old && mv $tmp $path
38 test -d /cgroup || mkdir /cgroup
39 grep /cgroup /etc/fstab || echo "cgroup /cgroup cgroup rw 0 0" >> /etc/fstab
41 grep eth0 $dir/etc/network/interfaces || cat << __interfaces__ > $dir/etc/network/interfaces
44 iface lo inet loopback
46 iface eth0 inet static
53 echo $hostname > $dir/etc/hostname
57 cat << __lxc__ > $conf
58 lxc.utsname = $hostname
61 lxc.network.type = veth
62 lxc.network.flags = up
63 lxc.network.link = br0
64 lxc.network.name = eth0
65 lxc.network.mtu = 1500
68 lxc.cgroup.devices.deny = a
70 lxc.cgroup.devices.allow = c 1:3 rwm
71 lxc.cgroup.devices.allow = c 1:5 rwm
73 lxc.cgroup.devices.allow = c 5:1 rwm
74 lxc.cgroup.devices.allow = c 5:0 rwm
75 lxc.cgroup.devices.allow = c 4:0 rwm
76 lxc.cgroup.devices.allow = c 4:1 rwm
78 lxc.cgroup.devices.allow = c 1:9 rwm
79 lxc.cgroup.devices.allow = c 1:8 rwm
80 lxc.cgroup.devices.allow = c 136:* rwm
81 lxc.cgroup.devices.allow = c 5:2 rwm
83 lxc.cgroup.devices.allow = c 254:0 rwm
86 cp -v /etc/resolv.conf /$dir/etc/resolv.conf
88 mount | grep /cgroup || mount /cgroup || exit
90 lxc-create -n ve2lxc -f $conf && lxc-start -n ve2lxc