[Fusionforge-commits] r13089 - in trunk/tests: lxc scripts

Christian Bayle cbayle at fusionforge.org
Tue Apr 12 18:11:48 CEST 2011


Author: cbayle
Date: 2011-04-12 18:11:48 +0200 (Tue, 12 Apr 2011)
New Revision: 13089

Removed:
   trunk/tests/lxc/lxc-centos5.postinst
   trunk/tests/lxc/lxc-debian6.postinst
Modified:
   trunk/tests/lxc/Makefile
   trunk/tests/lxc/lxc-centos5
   trunk/tests/lxc/lxc-debian6
   trunk/tests/scripts/start_lxc.sh
Log:
Make templates more simple


Modified: trunk/tests/lxc/Makefile
===================================================================
--- trunk/tests/lxc/Makefile	2011-04-12 16:03:57 UTC (rev 13088)
+++ trunk/tests/lxc/Makefile	2011-04-12 16:11:48 UTC (rev 13089)
@@ -89,9 +89,7 @@
 installtemplate: beroot
 	cat lxc-debian6 | sed 's!http://cdn.debian.net/debian/!$(DEBMIRROR)!' > /usr/lib/lxc/templates/lxc-debian6
 	chmod 755 /usr/lib/lxc/templates/lxc-debian6
-	cp lxc-debian6.postinst /usr/lib/lxc/templates/
 	cp lxc-centos5 /usr/lib/lxc/templates/
-	cp lxc-centos5.postinst /usr/lib/lxc/templates/
 
 createdeb: beroot
 	/usr/bin/lxc-create -n debian6.local -f config.debian6 -t debian6

Modified: trunk/tests/lxc/lxc-centos5
===================================================================
--- trunk/tests/lxc/lxc-centos5	2011-04-12 16:03:57 UTC (rev 13088)
+++ trunk/tests/lxc/lxc-centos5	2011-04-12 16:11:48 UTC (rev 13089)
@@ -28,31 +28,80 @@
 
 configure_centos()
 {
-    rootfs=$1
-    hostname=$2
+    path=$1
+    rootfs=$2
+    hostname=$3
 
     # disable selinux in centos
     mkdir -p $rootfs/selinux
     echo 0 > $rootfs/selinux/enforce
 
-   # configure the network using the dhcp
-#    cat <<EOF > $rootfs/etc/network/interfaces
-#auto lo
-#iface lo inet loopback
-#
-#auto eth0
-#iface eth0 inet dhcp
-#EOF
+    if grep -q ^lxc.network.ipv4 $path/config
+    then
+        # configure static network
+        lxc_network_ipv4=`grep ^lxc.network.ipv4 $path/config | cut -d= -f2`
+        address=`echo $lxc_network_ipv4 | cut -d/ -f1`
+	netmask=`netmask -s $lxc_network_ipv4 | cut -d/ -f2`
+        if [ -e $rootfs/etc/sysconfig/network-scripts ]
+        then
+                cat <<EOF > $rootfs/etc/sysconfig/network-scripts/ifcfg-eth0
+DEVICE=eth0
+IPADDR=$address
+NETMASK=$netmask
+#NETWORK=
+#BROADCAST=
+ONBOOT=yes
+BOOTPROTO=none
+USERCTL=no
+EOF
+                cat <<EOF > $rootfs/etc/sysconfig/network
+NETWORKING=yes
+FORWARD_IPV4=yes
+HOSTNAME=$hostname
+#GATEWAY=
+GATEWAYDEV=eth0
+EOF
+                cat <<EOF >> $rootfs/etc/hosts
+$address        $hostname
+EOF
+                echo "Network configured with static ip"
+        else
+                exit 2
+        fi
+        
+    else
+        # configure the network using the dhcp
+        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
+        # When domain is not local, avahi completed by send hostname
+        hostnamebase=`echo $hostname | cut -d. -f1`
+        if [ "$hostnamebase.local" != "$hostname" ]
+        then
+                cat <<EOF > $rootfs/etc/dhclient.conf
+send host-name "$hostnamebase";
+EOF
+        fi
+    fi
 
-    # set the hostname
-#    cat <<EOF > $rootfs/etc/hostname
-#$hostname
-#EOF
-    # set minimal hosts
-#    cat <<EOF > $rootfs/etc/hosts
-#127.0.0.1 localhost $hostname
-#EOF
-
     # provide the lxc service
 #    cat <<EOF > $rootfs/etc/init/lxc.conf
 ## fake some events needed for correct startup other services
@@ -169,6 +218,48 @@
     return 0
 }
 
+configure_pubkey(){
+	path=$1
+	rootfs=$2
+        if grep -q ^\#lxc.pubkey $path/config
+        then
+		pubkey=`grep ^\#lxc.pubkey $path/config | cut -d= -f2`
+	fi
+	if [ ! -e $rootfs/root/.ssh ]
+	then
+		mkdir $rootfs/root/.ssh
+	fi
+	if [ ! -z "$pubkey" ]
+	then
+		echo "Copying $pubkey -> $rootfs/root/.ssh/authorized_keys"
+		cp $pubkey $rootfs/root/.ssh/authorized_keys
+	fi
+}
+
+configure_hostkeydir(){
+	rootfs=$1
+	hostkeydir=$2
+	name=$3
+	if [ $# -ne 3 ]
+	then
+		exit 1
+	else
+		[ -d $rootfs/etc/ssh ] || mkdir -p $rootfs/etc/ssh
+		if [ -e $hostkeydir ]
+		then 
+			if [ ! -d $hostkeydir/$name ]
+			then
+				mkdir $hostkeydir/$name
+				echo "Creating SSH2 RSA key; this may take some time ..."
+				ssh-keygen -q -f $hostkeydir/$name/ssh_host_rsa_key -N '' -t rsa
+				echo "Creating SSH2 DSA key; this may take some time ..."
+				ssh-keygen -q -f $hostkeydir/$name/ssh_host_dsa_key -N '' -t dsa
+			fi
+			cp $hostkeydir/$name/ssh_host_* $rootfs/etc/ssh/
+		fi
+	fi
+}
+
 download_centos()
 {
     cache=$1
@@ -417,6 +508,12 @@
     exit 0
 fi
 
+type netmask
+if [ $? -ne 0 ]; then
+    echo "'netmask' command is missing"
+    exit 1
+fi
+
 type rinse
 if [ $? -ne 0 ]; then
     echo "'rinse' command is missing"
@@ -434,6 +531,19 @@
 fi
 
 rootfs=$path/rootfs
+oldhostkeydir=/var/lib/lxc/ssh
+hostkeydir=/var/cache/lxc/ssh
+if [ -e $oldhostkeydir ]
+then
+    if [ ! -e $hostkeydir ]
+    then
+        mv $oldhostkeydir $hostkeydir
+    fi
+fi
+if [ ! -e $hostkeydir ]
+then
+    mkdir $hostkeydir
+fi
 
 install_centos $rootfs
 if [ $? -ne 0 ]; then
@@ -441,7 +551,7 @@
     exit 1
 fi
 
-configure_centos $rootfs $name
+configure_centos $path $rootfs $name
 if [ $? -ne 0 ]; then
     echo "failed to configure centos for a container"
     exit 1
@@ -453,6 +563,18 @@
     exit 1
 fi
 
+configure_pubkey $path $rootfs
+if [ $? -ne 0 ]; then
+    echo "failed to configure pubkey"
+    exit 1
+fi
+
+configure_hostkeydir $rootfs $hostkeydir $name
+if [ $? -ne 0 ]; then
+    echo "failed to configure hostkeydir"
+    exit 1
+fi
+
 if [ ! -z $clean ]; then
     clean || exit 1
     exit 0

Deleted: trunk/tests/lxc/lxc-centos5.postinst
===================================================================
--- trunk/tests/lxc/lxc-centos5.postinst	2011-04-12 16:03:57 UTC (rev 13088)
+++ trunk/tests/lxc/lxc-centos5.postinst	2011-04-12 16:11:48 UTC (rev 13089)
@@ -1,178 +0,0 @@
-#! /bin/sh
-
-configure_network()
-{
-rootfs=$1
-hostname=$2
-if [ $# -eq 5 ]
-then
-	address=$3
-	netmask=$4
-	gateway=$5
-	if [ -e $rootfs/etc/sysconfig/network-scripts ]
-	then
-		cat <<EOF > $rootfs/etc/sysconfig/network-scripts/ifcfg-eth0
-DEVICE=eth0
-IPADDR=$address
-NETMASK=$netmask
-#NETWORK=
-#BROADCAST
-ONBOOT=yes
-BOOTPROTO=none
-USERCTL=no
-EOF
-		cat <<EOF > $rootfs/etc/sysconfig/network
-NETWORKING=yes
-FORWARD_IPV4=yes
-HOSTNAME=$hostname
-GATEWAY=$gateway
-GATEWAYDEV=eth0
-EOF
-                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
-	# When domain is not local, avahi completed by send hostname
-	hostnamebase=`echo $hostname | cut -d. -f1`
-	if [ "$hostnamebase.local" != "$hostname" ]
-	then
-		cat <<EOF > $rootfs/etc/dhclient.conf
-send host-name "$hostnamebase";
-EOF
-	fi
-fi
-}
-
-configure_pubkey(){
-	rootfs=$1
-	pubkey=$2
-	if [ $# -ne 2 ]
-	then
-		exit 1
-	else
-		[ -d $rootfs/root/.ssh ] || mkdir $rootfs/root/.ssh
-		cp $pubkey $rootfs/root/.ssh/authorized_keys
-	fi
-}
-
-configure_hostkeydir(){
-	rootfs=$1
-	hostkeydir=$2
-	name=$3
-	if [ $# -ne 3 ]
-	then
-		exit 1
-	else
-		[ -d $rootfs/etc/ssh ] || mkdir -p $rootfs/etc/ssh
-		if [ -e $hostkeydir ]
-		then 
-			if [ ! -d $hostkeydir/$name ]
-			then
-				mkdir $hostkeydir/$name
-				echo "Creating SSH2 RSA key; this may take some time ..."
-				ssh-keygen -q -f $hostkeydir/$name/ssh_host_rsa_key -N '' -t rsa
-				echo "Creating SSH2 DSA key; this may take some time ..."
-				ssh-keygen -q -f $hostkeydir/$name/ssh_host_dsa_key -N '' -t dsa
-			fi
-			cp $hostkeydir/$name/ssh_host_* $rootfs/etc/ssh/
-		fi
-	fi
-}
-
-usage()
-{
-    cat <<EOF
-$1 -h|--help -p|--path=<path> --clean --address=<address> --netmask=<netmask> --gateway=<gateway> --pubkey=<pubkey>
-EOF
-    return 0
-}
-
-options=$(getopt -o hp:n:c -l help,path:,name:,clean:,address:,netmask:,gateway:,pubkey: -- "$@")
-if [ $? -ne 0 ]; then
-        usage $(basename $0)
-        exit 1
-fi
-eval set -- "$options"
-
-while true
-do
-    case "$1" in
-        -h|--help)      usage $0 && exit 0;;
-        -p|--path)      path=$2; shift 2;;
-        -n|--name)      name=$2; shift 2;;
-	--address)	address=$2; shift 2;;
-	--netmask)	netmask=$2; shift 2;;
-	--gateway)	gateway=$2; shift 2;;
-	--pubkey)	pubkey=$2; shift 2;;
-        --)             shift 1; break ;;
-        *)              break ;;
-    esac
-done
-
-if [ -z "$path" ]; then
-    echo "'path' parameter is required"
-    exit 1
-fi
-
-if [ "$(id -u)" != "0" ]; then
-    echo "This script should be run as 'root'"
-    exit 1
-fi
-
-rootfs=$path/rootfs
-oldhostkeydir=/var/lib/lxc/ssh
-hostkeydir=/var/cache/lxc/ssh
-if [ -e $oldhostkeydir ]
-then
-	if [ ! -e $hostkeydir ]
-	then
-		mv $oldhostkeydir $hostkeydir
-	fi
-fi
-if [ ! -e $hostkeydir ]
-then
-	mkdir $hostkeydir
-fi
-
-configure_network $rootfs $name $address $netmask $gateway
-if [ $? -ne 0 ]; then
-    echo "failed to configure network"
-    exit 1
-fi
-
-configure_pubkey $rootfs $pubkey
-if [ $? -ne 0 ]; then
-    echo "failed to configure pubkey"
-    exit 1
-fi
-
-configure_hostkeydir $rootfs $hostkeydir $name
-if [ $? -ne 0 ]; then
-    echo "failed to configure hostkeydir"
-    exit 1
-fi

Modified: trunk/tests/lxc/lxc-debian6
===================================================================
--- trunk/tests/lxc/lxc-debian6	2011-04-12 16:03:57 UTC (rev 13088)
+++ trunk/tests/lxc/lxc-debian6	2011-04-12 16:11:48 UTC (rev 13089)
@@ -60,14 +60,50 @@
     mkdir -p $rootfs/selinux
     echo 0 > $rootfs/selinux/enforce
 
-    # configure the network using the dhcp
-    cat <<EOF > $rootfs/etc/network/interfaces
+    if grep -q ^lxc.network.ipv4 $path/config
+    then
+        # configure static network
+        lxc_network_ipv4=`grep ^lxc.network.ipv4 $path/config | cut -d= -f2`
+        address=`echo $lxc_network_ipv4 | cut -d/ -f1`
+        netmask=`netmask -s $lxc_network_ipv4 | cut -d/ -f2`
+	if [ -e $rootfs/etc/network/interfaces ]
+	then
+		cat <<EOF > $rootfs/etc/network/interfaces
 auto lo
 iface lo inet loopback
 
 auto eth0
+iface eth0 inet static
+	address $address
+	netmask $netmask
+
+EOF
+		cat <<EOF >> $rootfs/etc/hosts
+$address	$hostname
+EOF
+		echo "Network configured with static ip"
+	else
+		exit 2
+	fi
+    else
+        # configure the network using the dhcp
+	if [ -e $rootfs/etc/network/interfaces ]
+	then
+                cat <<EOF > $rootfs/etc/network/interfaces
+auto lo
+iface lo inet loopback
+
+auto eth0
 iface eth0 inet dhcp
 EOF
+		cat <<EOF >> $rootfs/etc/hosts
+127.0.1.1	$hostname
+EOF
+		echo "Network configured with dhcp"
+	else
+		exit 3
+	fi
+    fi
 
     # set the hostname
     cat <<EOF > $rootfs/etc/hostname
@@ -102,6 +138,48 @@
     return 0
 }
 
+configure_pubkey(){
+	path=$1
+	rootfs=$2
+        if grep -q ^\#lxc.pubkey $path/config
+        then
+		pubkey=`grep ^\#lxc.pubkey $path/config | cut -d= -f2`
+	fi
+	if [ ! -e $rootfs/root/.ssh ]
+	then
+		mkdir $rootfs/root/.ssh
+	fi
+	if [ ! -z "$pubkey" ]
+	then
+		echo "Copying $pubkey -> $rootfs/root/.ssh/authorized_keys"
+		cp $pubkey $rootfs/root/.ssh/authorized_keys
+	fi
+}
+
+configure_hostkeydir(){
+	rootfs=$1
+	hostkeydir=$2
+	name=$3
+	if [ $# -ne 3 ]
+	then
+		exit 1
+	else
+		[ -d $rootfs/etc/ssh ] || mkdir -p $rootfs/etc/ssh
+		if [ -e $hostkeydir ]
+		then 
+			if [ ! -d $hostkeydir/$name ]
+			then
+				mkdir $hostkeydir/$name
+				echo "Creating SSH2 RSA key; this may take some time ..."
+				ssh-keygen -q -f $hostkeydir/$name/ssh_host_rsa_key -N '' -t rsa
+				echo "Creating SSH2 DSA key; this may take some time ..."
+				ssh-keygen -q -f $hostkeydir/$name/ssh_host_dsa_key -N '' -t dsa
+			fi
+			cp $hostkeydir/$name/ssh_host_* $rootfs/etc/ssh/
+		fi
+	fi
+}
+
 download_debian()
 {
     packages=\
@@ -320,6 +398,19 @@
 fi
 
 rootfs=$path/rootfs
+oldhostkeydir=/var/lib/lxc/ssh
+hostkeydir=/var/cache/lxc/ssh
+if [ -e $oldhostkeydir ]
+then
+    if [ ! -e $hostkeydir ]
+    then
+        mv $oldhostkeydir $hostkeydir
+    fi
+fi
+if [ ! -e $hostkeydir ]
+then
+    mkdir $hostkeydir
+fi
 
 install_debian $rootfs
 if [ $? -ne 0 ]; then
@@ -333,12 +424,24 @@
     exit 1
 fi
 
-copy_configuration $path $rootfs
+copy_configuration $path $rootfs $name
 if [ $? -ne 0 ]; then
     echo "failed write configuration file"
     exit 1
 fi
 
+configure_pubkey $path $rootfs
+if [ $? -ne 0 ]; then
+    echo "failed to configure pubkey"
+    exit 1
+fi
+
+configure_hostkeydir $rootfs $hostkeydir $name
+if [ $? -ne 0 ]; then
+    echo "failed to configure hostkeydir"
+    exit 1
+fi
+
 if [ ! -z $clean ]; then
     clean || exit 1
     exit 0

Deleted: trunk/tests/lxc/lxc-debian6.postinst
===================================================================
--- trunk/tests/lxc/lxc-debian6.postinst	2011-04-12 16:03:57 UTC (rev 13088)
+++ trunk/tests/lxc/lxc-debian6.postinst	2011-04-12 16:11:48 UTC (rev 13089)
@@ -1,152 +0,0 @@
-#! /bin/sh
-
-configure_network()
-{
-rootfs=$1
-hostname=$2
-if [ $# -eq 5 ]
-then
-	address=$3
-	netmask=$4
-	gateway=$5
-	if [ -e $rootfs/etc/network/interfaces ]
-	then
-		cat <<EOF > $rootfs/etc/network/interfaces
-auto lo
-iface lo inet loopback
-
-auto eth0
-iface eth0 inet static
-	address $address
-	netmask $netmask
-	gateway $gateway
-
-EOF
-		cat <<EOF >> $rootfs/etc/hosts
-$address	$hostname
-EOF
-		echo "Network configured with static ip"
-	else
-		exit 2
-	fi
-else
-	if [ -e $rootfs/etc/network/interfaces ]
-	then
-		cat <<EOF >> $rootfs/etc/hosts
-127.0.1.1	$hostname
-EOF
-		echo "Network configured with dhcp"
-	else
-		exit 2
-	fi
-fi
-}
-
-configure_pubkey(){
-	rootfs=$1
-	pubkey=$2
-	if [ $# -ne 2 ]
-	then
-		exit 1
-	else
-		[ -d $rootfs/root/.ssh ] || mkdir $rootfs/root/.ssh
-		cp $pubkey $rootfs/root/.ssh/authorized_keys
-	fi
-}
-
-configure_hostkeydir(){
-	rootfs=$1
-	hostkeydir=$2
-	name=$3
-	if [ $# -ne 3 ]
-	then
-		exit 1
-	else
-		[ -d $rootfs/etc/ssh ] || mkdir -p $rootfs/etc/ssh
-		if [ -e $hostkeydir ]
-		then 
-			if [ ! -d $hostkeydir/$name ]
-			then
-				mkdir $hostkeydir/$name
-				echo "Creating SSH2 RSA key; this may take some time ..."
-				ssh-keygen -q -f $hostkeydir/$name/ssh_host_rsa_key -N '' -t rsa
-				echo "Creating SSH2 DSA key; this may take some time ..."
-				ssh-keygen -q -f $hostkeydir/$name/ssh_host_dsa_key -N '' -t dsa
-			fi
-			cp $hostkeydir/$name/ssh_host_* $rootfs/etc/ssh/
-		fi
-	fi
-}
-
-usage()
-{
-    cat <<EOF
-$1 -h|--help -p|--path=<path> --clean --address=<address> --netmask=<netmask> --gateway=<gateway> --pubkey=<pubkey>
-EOF
-    return 0
-}
-
-options=$(getopt -o hp:n:c -l help,path:,name:,clean:,address:,netmask:,gateway:,pubkey: -- "$@")
-if [ $? -ne 0 ]; then
-        usage $(basename $0)
-        exit 1
-fi
-eval set -- "$options"
-
-while true
-do
-    case "$1" in
-        -h|--help)      usage $0 && exit 0;;
-        -p|--path)      path=$2; shift 2;;
-        -n|--name)      name=$2; shift 2;;
-	--address)	address=$2; shift 2;;
-	--netmask)	netmask=$2; shift 2;;
-	--gateway)	gateway=$2; shift 2;;
-	--pubkey)	pubkey=$2; shift 2;;
-        --)             shift 1; break ;;
-        *)              break ;;
-    esac
-done
-
-if [ -z "$path" ]; then
-    echo "'path' parameter is required"
-    exit 1
-fi
-
-if [ "$(id -u)" != "0" ]; then
-    echo "This script should be run as 'root'"
-    exit 1
-fi
-
-rootfs=$path/rootfs
-oldhostkeydir=/var/lib/lxc/ssh
-hostkeydir=/var/cache/lxc/ssh
-if [ -e $oldhostkeydir ]
-then
-	if [ ! -e $hostkeydir ]
-	then
-		mv $oldhostkeydir $hostkeydir
-	fi
-fi
-if [ ! -e $hostkeydir ] 
-then 
-	mkdir $hostkeydir
-fi
-
-configure_network $rootfs $name $address $netmask $gateway
-if [ $? -ne 0 ]; then
-    echo "failed to configure network"
-    exit 1
-fi
-
-configure_pubkey $rootfs $pubkey
-if [ $? -ne 0 ]; then
-    echo "failed to configure pubkey"
-    exit 1
-fi
-
-configure_hostkeydir $rootfs $hostkeydir $name
-if [ $? -ne 0 ]; then
-    echo "failed to configure hostkeydir"
-    exit 1
-fi

Modified: trunk/tests/scripts/start_lxc.sh
===================================================================
--- trunk/tests/scripts/start_lxc.sh	2011-04-12 16:03:57 UTC (rev 13088)
+++ trunk/tests/scripts/start_lxc.sh	2011-04-12 16:11:48 UTC (rev 13089)
@@ -71,28 +71,18 @@
 	echo "you need to install template"
 	echo "run: (cd $lxcdir ; sudo make)"
 else
-	sudo /usr/bin/lxc-create -n $HOST -f $lxcdir/config.$LXCTEMPLATE -t $LXCTEMPLATE
-fi
-
-if [ ! -e /usr/lib/lxc/templates/lxc-$LXCTEMPLATE.postinst ]
-then
-	echo "/usr/lib/lxc/templates/lxc-$LXCTEMPLATE.postinst not found"
-	echo "you need to install template"
-	echo "run: (cd $lxcdir ; sudo make)"
-else
-	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
+	tmpconf=`mktemp`
+	cat $lxcdir/config.$LXCTEMPLATE > $tmpconf
+	if [ ! -z "$VEID" ] 
+	then
+		CIDRMASK=`netmask -c $IPBASE.$VEID/$IPMASK | cut -d/ -f2`
+		echo "lxc.network.ipv4 = $IPBASE.$VEID/$CIDRMASK" >> $tmpconf
+		# Next is a bit hacky, the only way I found to pass pubkey to the template
+		# LXC don't allow to pass extra args
+		echo "#lxc.pubkey = $SSHPUBKEY" >> $tmpconf
 	fi
+	sudo /usr/bin/lxc-create -n $HOST -f $tmpconf -t $LXCTEMPLATE
+	rm -f $tmpconf
 	sudo /usr/bin/lxc-start -n $HOST -d
 fi
 




More information about the Fusionforge-commits mailing list