would be much simpler if enter-lxc-namespace was looking along a PATH...
[build.git] / lbuild-initvm.sh
index 31563d2..de88c89 100755 (executable)
@@ -520,7 +520,25 @@ function debian_install () {
 }
 
 function debian_configure () {
-    echo "WARNING No debian config available yet"
+    guest_interfaces=${rootfs_path}/etc/network/interfaces
+    ( [ -n "$BUILD_MODE" ] && write_guest_interfaces_build || write_guest_interfaces_test ) > $guest_interfaces
+}
+
+function write_guest_interfaces_build () {
+    cat <<EOF
+auto $VIF_GUEST
+iface $VIF_GUEST inet dhcp
+EOF
+}
+
+function write_guest_interfaces_test () {
+    cat <<EOF
+auto $VIF_GUEST
+iface $VIF_GUEST
+    address $IP
+    netmask $NETMASK
+    gateway $GATEWAY
+EOF
 }
 ##############################
 function setup_lxc() {
@@ -712,7 +730,14 @@ function devel_or_vtest_tools () {
            chroot $rootfs_path apt-get update
            for package in $packages ; do
                # close stdin in an attempt to avoid this hanging
-               chroot $rootfs_path apt-get install -y $package < /dev/null
+               # xxx also we ignore result for now, not sure if the kind of errors like below
+               # truly is serious or not
+#Setting up at (3.1.13-2ubuntu2) ...
+#initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
+#initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
+#start: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
+
+               chroot $rootfs_path apt-get install -y $package < /dev/null || :
            done
            ### xxx todo install groups with apt..
            ;;
@@ -724,6 +749,17 @@ function devel_or_vtest_tools () {
     return 0
 }
 
+# would be much simpler if enter-lxc-namespace was looking along a PATH...
+function bin_in_container () {
+    binary=$1; shift
+    lxc=$1; shift
+
+    for path in /sbin /bin /usr/bin /usr/sbin; do
+       [ -f $rootfs_path/$path/$binary ] && { echo $path/$binary; return; }
+    done
+    echo bin_in_container_cannot_find_$binary
+}
+
 function post_install () {
     lxc=$1; shift 
     personality=$1; shift
@@ -731,7 +767,7 @@ function post_install () {
        post_install_build $lxc $personality
        lxc_start $lxc
        # manually run dhclient in guest - somehow this network won't start on its own
-       virsh -c lxc:/// lxc-enter-namespace $lxc /usr/sbin/dhclient $VIF_GUEST
+       virsh -c lxc:/// lxc-enter-namespace $lxc $(bin_in_container dhclient $lxc) $VIF_GUEST
     else
        post_install_myplc $lxc $personality
        lxc_start $lxc