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`
+ gateway=`grep ^\#lxc.network.ipv4.gw $path/config | cut -d= -f2`
if [ -e $rootfs/etc/network/interfaces ]
then
cat <<EOF > $rootfs/etc/network/interfaces
iface eth0 inet static
address $address
netmask $netmask
-
EOF
+ if [ ! -z "$gateway" ]
+ then
+ cat <<EOF >> $rootfs/etc/network/interfaces
+ gateway $gateway
+EOF
+ fi
cat <<EOF >> $rootfs/etc/hosts
$address $hostname
EOF
fi
# Next is a bit hacky, the only way I found to pass pubkey to the template
# LXC don't allow to pass extra args
+ if [ ! -z "$IPGW" ]
+ then
+ echo "#lxc.network.ipv4.gw = $IPGW" >> $tmpconf
+ fi
echo "#lxc.pubkey = $SSHPUBKEY" >> $tmpconf
sudo /usr/bin/lxc-create -n $HOST -f $tmpconf -t $TEMPLATE
rm -f $tmpconf