[Fusionforge-commits] r12857 - in trunk/tests: lxc scripts
Christian Bayle
cbayle at fusionforge.org
Sun Mar 20 18:06:36 CET 2011
Author: cbayle
Date: 2011-03-20 18:06:35 +0100 (Sun, 20 Mar 2011)
New Revision: 12857
Modified:
trunk/tests/lxc/lxc-centos5.postinst
trunk/tests/scripts/start_lxc.sh
Log:
Add dhcp support
Modified: trunk/tests/lxc/lxc-centos5.postinst
===================================================================
--- trunk/tests/lxc/lxc-centos5.postinst 2011-03-19 16:49:26 UTC (rev 12856)
+++ trunk/tests/lxc/lxc-centos5.postinst 2011-03-20 17:06:35 UTC (rev 12857)
@@ -2,15 +2,13 @@
configure_network()
{
-if [ $# -ne 5 ]
+rootfs=$1
+hostname=$2
+if [ $# -eq 5 ]
then
- exit 1
-else
- rootfs=$1
- address=$2
- netmask=$3
- gateway=$4
- hostname=$5
+ address=$3
+ netmask=$4
+ gateway=$5
if [ -e $rootfs/etc/sysconfig/network-scripts ]
then
cat <<EOF > $rootfs/etc/sysconfig/network-scripts/ifcfg-eth0
@@ -33,9 +31,32 @@
cat <<EOF >> $rootfs/etc/hosts
$address $hostname
EOF
+ echo "Network configured with static ip"
else
exit 2
fi
+else
+ if [ -e $rootfs/etc/sysconfig/network-scripts ]
+ then
+ cat <<EOF > $rootfs/etc/sysconfig/network-scripts/ifcfg-eth0
+DEVICE=eth0
+ONBOOT=yes
+BOOTPROTO=dhcp
+USERCTL=no
+EOF
+ cat <<EOF > $rootfs/etc/sysconfig/network
+NETWORKING=yes
+FORWARD_IPV4=yes
+HOSTNAME=$hostname
+GATEWAYDEV=eth0
+EOF
+ cat <<EOF >> $rootfs/etc/hosts
+127.0.1.1 $hostname
+EOF
+ echo "Network configured with dhcp"
+ else
+ exit 3
+ fi
fi
}
@@ -83,7 +104,7 @@
return 0
}
-options=$(getopt -o hp:n:c -l help,path:,name:,clean:,address:,netmask:,gateway:,pubkey: -- "$@")
+options=$(getopt -o hp:n:c -l help,path:,name:,clean:,address,netmask,gateway,pubkey: -- "$@")
if [ $? -ne 0 ]; then
usage $(basename $0)
exit 1
@@ -119,7 +140,7 @@
hostkeydir=/var/lib/lxc/ssh
[ -d $hostkeydir ] || mkdir $hostkeydir
-configure_network $rootfs $address $netmask $gateway $name
+configure_network $rootfs $name $address $netmask $gateway
if [ $? -ne 0 ]; then
echo "failed to configure network"
exit 1
Modified: trunk/tests/scripts/start_lxc.sh
===================================================================
--- trunk/tests/scripts/start_lxc.sh 2011-03-19 16:49:26 UTC (rev 12856)
+++ trunk/tests/scripts/start_lxc.sh 2011-03-20 17:06:35 UTC (rev 12857)
@@ -49,13 +49,15 @@
IPMASK=$IPCOSMASK
IPGW=$IPCOSGW
;;
+ *fgdeb*)
+ LXCTEMPLATE=$LXCDEBTEMPLATE
+ ;;
+ *fgcos*)
+ LXCTEMPLATE=$LXCCOSTEMPLATE
+ ;;
esac
fi
fi
-[ -z $IPBASE ] && exit 2
-[ -z $VEID ] && exit 3
-[ -z $IPMASK ] && exit 4
-[ -z $IPGW ] && exit 5
if [ ! -e /usr/lib/lxc/templates/lxc-$LXCTEMPLATE ]
then
@@ -72,12 +74,19 @@
echo "you need to install template"
echo "run: (cd $lxcdir ; sudo make)"
else
- sudo /usr/lib/lxc/templates/lxc-$LXCTEMPLATE.postinst \
+ if [ "x$VEID" != "x" ]
+ then
+ sudo /usr/lib/lxc/templates/lxc-$LXCTEMPLATE.postinst \
-p /var/lib/lxc/$HOST -n $HOST \
--address=$IPBASE.$VEID \
--netmask=$IPMASK \
--gateway=$IPGW \
--pubkey=$SSHPUBKEY
+ else
+ sudo /usr/lib/lxc/templates/lxc-$LXCTEMPLATE.postinst \
+ -p /var/lib/lxc/$HOST -n $HOST \
+ --pubkey=$SSHPUBKEY
+ fi
sudo /usr/bin/lxc-start -n $HOST -d
fi
More information about the Fusionforge-commits
mailing list