Merge branch 'master' of ssh://git.planet-lab.org/git/build
[build.git] / config.planetlab / bootstrapfs.post
1 #!/bin/bash
2
3 vdir=$1
4 if [ -z "${vdir}" ] ; then
5         echo "ERROR: $0"
6         echo "Provide the directory of the root filesystem to operate on"
7         exit
8 fi
9
10 # Cleanup yum config entirely, waiting for the config files to populate this
11 rm -rf ${vdir}/etc/yum.conf ${vdir}/etc/yum.repos.d
12
13 # NOTE: we're enabling util-vserver to allow it to help shutdown all slices
14 # before rebooting.  This has been problematic in the past.
15 # Thierry : I'm enabling network since, for some reason, it ends up turned off on fedora9
16 for service in network util-vserver; do
17     chroot ${vdir} /sbin/chkconfig $service on
18 done
19
20 # Remove unneeded services
21 # turn off firstboot if present, might cause the node to hang
22 chroot ${vdir} /sbin/chkconfig firstboot off || :
23 # this is to automatically restart vservers, let nm do that
24 chroot ${vdir} /sbin/chkconfig vservers-default off || :
25 # vprocunhide is required with kernels that have CONFIG_VSERVER_PROC_SECURE enabled
26 # which is the case for our k32 kernel
27 chroot ${vdir} /sbin/chkconfig vprocunhide on || :
28
29
30 # Disable splaying of cron.
31 echo > ${vdir}/etc/sysconfig/crontab
32
33 # Add site_admin account
34 chroot ${vdir} /usr/sbin/useradd -p "" -u 502 -m site_admin
35
36 # Remove 32bit packages from 64bit system (http://wiki.centos.org/FAQ/General#head-357346ff0bf7c14b0849c3bcce39677aaca528e9) 
37 # use rpm instead of yum as /proc is not mounted at that poing 
38 if echo ${vdir} | grep -q x86_64 ; then
39     chroot ${vdir} rpm -qa --qf '%{name}.%{arch}\n' | grep 'i[36]86$' | xargs chroot ${vdir} rpm -e
40 fi
41
42 # NOTE:  This is added to relieve one site's Cisco router configuration that
43 # fails to recognize the host once the arping is sent out.
44 # NOTE: this is pretty fragile, and fails on fedora 10 that as of today (oct. 20 2009) 
45 # has initscripts-8.86.3-1.i386 which reads almost identical but with /sbin/arping instead
46 cat <<\EOF | patch -d ${vdir}/etc/sysconfig/network-scripts/
47 --- ifup-eth    2008-07-08 13:19:49.000000000 -0400
48 +++ ifup-eth-orig       2008-07-08 13:20:02.000000000 -0400
49 @@ -263,10 +263,10 @@
50      fi
51      
52      if ! LC_ALL=C ip addr ls ${REALDEVICE} | LC_ALL=C grep -q "${IPADDR}/${PREFIX}" ; then
53 -        if ! arping -q -c 2 -w 3 -D -I ${REALDEVICE} ${IPADDR} ; then
54 -           echo $"Error, some other host already uses address ${IPADDR}."
55 -           exit 1
56 -        fi
57 +        #if ! arping -q -c 2 -w 3 -D -I ${REALDEVICE} ${IPADDR} ; then
58 +        #   echo $"Error, some other host already uses address ${IPADDR}."
59 +        #   exit 1
60 +        #fi
61          if ! ip addr add ${IPADDR}/${PREFIX} \
62             brd ${BROADCAST:-+} dev ${REALDEVICE} ${SCOPE} label ${DEVICE}; then
63             echo $"Error adding address ${IPADDR} for ${DEVICE}."
64 EOF