fix location of logfiles
[build.git] / vbuild-init-lxc.sh
index 06acdec..11916b7 100755 (executable)
@@ -139,26 +139,10 @@ function check_yumgroup_installed () {
 
 function prepare_host() {
    
-    host_fcdistro="$(cat /etc/fedora-release | cut -d' ' -f3)"    
-    ## check if libvirt_version is installed
-    virsh -v | grep -e $libvirt_version || { echo "$libvirt_version needs to be installed!!!" ; exit 1 ; }
-#    host_fcdistro="$(cat /etc/fedora-release | cut -d' ' -f3)"
-#    if [ ! -f /etc/yum.repos.d/libvirt.repo ] ; then
-#       touch /etc/yum.repos.d/libvirt.repo
-#       cat <<EOF > /etc/yum.repos.d/libvirt.repo
-#[libvirt]
-#name=libvirt-1.0.2-1
-#baseurl=http://build.onelab.eu/lxc/2013.02.25--lxc$host_fcdistro/RPMS/
-#enabled=1
-#gpgcheck=0
-#EOF
-#
-#       yum --assumeno update
-#       check_yumgroup_installed "Development Tools"
-#       check_yum_installed libcap-devel
-#       check_yum_installed libvirt
-#       systemctl start libvirtd
-#    fi
+### Thierry - jan 14 - turning off this check as our boxes now meet this req.
+### and I'm trying out f20's stock libvirt instead    
+#    ## check if libvirt_version is installed
+#    virsh -v | grep -e $libvirt_version || { echo "$libvirt_version needs to be installed!!!" ; exit 1 ; }
 
     #################### bride initialization
     check_yum_installed bridge-utils
@@ -195,21 +179,24 @@ TYPE=Ethernet
 MTU=1500
 EOF
 
-# set the hostname
-if [[ "$fcdistro" == "f18" ]] ; then
-    cat <<EOF > ${rootfs_path}/etc/hostname
+    # set the hostname
+    case "$fcdistro" in 
+       f18|f2?)
+           cat <<EOF > ${rootfs_path}/etc/hostname
 $HOSTNAME
 EOF
-else
-    cat <<EOF > ${rootfs_path}/etc/sysconfig/network
+           echo ;;
+       *)
+            cat <<EOF > ${rootfs_path}/etc/sysconfig/network
 NETWORKING=yes
 HOSTNAME=$HOSTNAME
 EOF
-    # set minimal hosts
-    cat <<EOF > $rootfs_path/etc/hosts
+            # set minimal hosts
+           cat <<EOF > $rootfs_path/etc/hosts
 127.0.0.1 localhost $HOSTNAME
 EOF
-fi
+           echo ;;
+    esac
 
     dev_path="${rootfs_path}/dev"
     rm -rf $dev_path
@@ -254,10 +241,9 @@ function configure_fedora_systemd() {
     # so ignore if we can't find /etc/systemd at all 
     [ -d ${rootfs_path}/etc/systemd ] || return 0
     # otherwise let's proceed
-    unlink ${rootfs_path}/etc/systemd/system/default.target
-    ln -s /lib/systemd/system/multi-user.target ${rootfs_path}/etc/systemd/system/default.target
+    ln -sf /lib/systemd/system/multi-user.target ${rootfs_path}/etc/systemd/system/default.target
     touch ${rootfs_path}/etc/fstab
-    ln -s /dev/null ${rootfs_path}/etc/systemd/system/udev.service
+    ln -sf /dev/null ${rootfs_path}/etc/systemd/system/udev.service
 # Thierry - Feb 2013
 # this was intended for f16 initially, in order to enable getty that otherwise would not start
 # having a getty running is helpful only if ssh won't start though, and we see a correlation between
@@ -265,7 +251,7 @@ function configure_fedora_systemd() {
 # so, turning getty off for now instead
 #   #dependency on a device unit fails it specially that we disabled udev
 #    sed -i 's/After=dev-%i.device/After=/' ${rootfs_path}/lib/systemd/system/getty\@.service
-    ln -s /dev/null ${rootfs_path}/etc/systemd/system/"getty@.service"
+    ln -sf /dev/null ${rootfs_path}/etc/systemd/system/"getty@.service"
     rm -f ${rootfs_path}/etc/systemd/system/getty.target.wants/*service || :
 # can't seem to handle this one with systemctl
     chroot ${rootfs_path} /sbin/chkconfig network on
@@ -276,6 +262,10 @@ set -x
     # check the mini fedora was not already downloaded
     INSTALL_ROOT=$cache/partial
     echo $INSTALL_ROOT
+
+    # download a mini fedora into a cache
+    echo "Downloading fedora minimal ..."
+
     mkdir -p $INSTALL_ROOT
     if [ $? -ne 0 ]; then
         echo "Failed to create '$INSTALL_ROOT' directory"
@@ -297,13 +287,6 @@ set -x
       sed -i "s/\$basearch/$arch/g; s/\$releasever/$release/g;" $f
     done 
 
- #   install fedora
- #   PKG_LIST="yum initscripts passwd rsyslog vim-minimal dhclient chkconfig rootfiles policycoreutils openssh-server openssh-clients"
- #   yum --installroot=$INSTALL_ROOT --nogpgcheck install fedora-release
- #   yum --installroot=$INSTALL_ROOT --nogpgcheck install $PKG_LIST
-
-  
-    
     MIRROR_URL=http://mirror.onelab.eu/fedora/releases/$release/Everything/$arch/os
     RELEASE_URL1="$MIRROR_URL/Packages/fedora-release-$release-1.noarch.rpm"
     # with fedora18 the rpms are scattered by first name