--- recepies/lxc/ve2lxc.sh 2009/06/15 20:22:52 112 +++ recepies/lxc/ve2lxc.sh 2009/10/21 12:06:10 151 @@ -1,14 +1,15 @@ #!/bin/sh -x -test -z "$1" && echo "usage: $0 /path/to/ve/private [10.60.0.253]" && exit +test -z "$1" && echo "usage: $0 /path/to/ve/private [10.60.0.253 [hostname]]" && exit dir=$1 -hostname=ve2lxc ip=$2 +hostname=$3 netmask=`grep netmask /etc/network/interfaces | head -1 | sed 's/^.*netmask *//'` gateway=`grep gateway /etc/network/interfaces | head -1 | sed 's/^.*gateway *//'` -test -z "$ip" && ip=10.60.0.253 +test -z "$ip" && ip=10.60.0.252 +test -z "$hostname" && hostname=ve2lxc path=/$dir/etc/inittab tmp=/tmp/inittab @@ -32,8 +33,8 @@ cp $path $path.old && mv $tmp $path fi -lxc-stop -n ve2lxc -lxc-destroy -n ve2lxc +lxc-stop -n $hostname +lxc-destroy -n $hostname test -d /cgroup || mkdir /cgroup grep /cgroup /etc/fstab || echo "cgroup /cgroup cgroup rw 0 0" >> /etc/fstab @@ -54,7 +55,7 @@ echo "$ip $hostname" >> $dir/etc/hosts -conf=/tmp/ve2lxc.conf +conf=/tmp/$hostname.conf cat << __lxc__ > $conf lxc.utsname = $hostname @@ -89,4 +90,4 @@ mount | grep /cgroup || mount /cgroup || exit -lxc-create -n ve2lxc -f $conf && lxc-start -n ve2lxc +lxc-create -n $hostname -f $conf && lxc-start -n $hostname