configure /etc/network/interfaces in new lxc container
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 21 May 2009 15:46:59 +0000 (15:46 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 21 May 2009 15:46:59 +0000 (15:46 +0000)
git-svn-id: svn://svn.rot13.org/sysadmin-cookbook@92 191e9f34-6774-4a6d-acfc-7664dacd4a2a

recepies/lxc/ve2lxc.sh

index 435cd6c..2bdd791 100755 (executable)
@@ -1,8 +1,12 @@
 #!/bin/sh -x
 
-test -z "$1" && echo "usage: $0 /path/to/ve/private" && exit
+test -z "$1" && echo "usage: $0 /path/to/ve/private [10.60.0.253]" && exit
 
 dir=$1
+ip=$2
+netmask=255.255.254.0
+
+test -z "$ip" && ip=10.60.0.253
 
 path=/$dir/etc/inittab
 tmp=/tmp/inittab
@@ -38,6 +42,17 @@ if ! grep /cgroup /etc/fstab ; then
        echo "cgroup /cgroup cgroup rw 0 0" >> /etc/fstab
 fi
 
+grep eth0 $dir/etc/network/interfaces || cat << __interfaces__ > $dir/etc/network/interfaces
+auto eth0 lo
+
+iface lo inet loopback
+
+iface eth0 inet static
+       address $ip
+       netmask $netmask
+
+__interfaces__
+
 mount | grep /cgroup || mount /cgroup || exit
 
-lxc-create -n ve2lxc -f $conf && read && lxc-start  -n ve2lxc
+lxc-create -n ve2lxc -f $conf && lxc-start -n ve2lxc