make sure to exit 0 when everything is fine
[build.git] / lbuild-initvm.sh
index 199cacf..23e52e7 100755 (executable)
@@ -499,6 +499,11 @@ function debian_install () {
     #virsh -c lxc:/// lxc-enter-namespace $lxc /bin/bash -c "apt-get -y install $DEBIAN_PREINSTALLED"
     chroot $lxc_root apt-get update
     chroot $lxc_root apt-get -y install $DEBIAN_PREINSTALLED
+    # configure hostname
+    cat <<EOF > ${lxc_root}/etc/hostname
+$GUEST_HOSTNAME
+EOF
+    
 }
 
 function debian_configure () {
@@ -719,6 +724,8 @@ function devel_or_vtest_tools () {
                ( cd /vservers/$lxc/etc/apt ; head -1 sources.list | sed -e s,main,universe, > sources.list.d/universe.list )
                # also adding a link to updates sounds about right
                ( cd /vservers/$lxc/etc/apt ; head -1 sources.list | sed -e 's, main,-updates main,' > sources.list.d/updates.list )
+               # tell apt about the changes
+               chroot /vservers/$lxc apt-get update
            fi
            for package in $packages ; do
                # container not started yet
@@ -916,7 +923,7 @@ function main () {
 
     if [ -n "$BUILD_MODE" ] ; then
        # we can now set GUEST_HOSTNAME safely
-        [ -z "$GUEST_HOSTNAME" ] && GUEST_HOSTNAME=$lxc
+        [ -z "$GUEST_HOSTNAME" ] && GUEST_HOSTNAME=$(echo $lxc | sed -e 's,\.,-,g')
     else
        # as this command can be used in other contexts, not specifying
        # a repo is considered a warning
@@ -963,6 +970,8 @@ function main () {
     post_install $lxc $personality
     
     echo $COMMAND Done
+
+    exit 0
 }
 
 main "$@"