Update master of plcapi.
[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 # Tweaking services
14 # turn OFF firstboot if present, might cause the node to hang
15 chroot ${vdir} /sbin/chkconfig firstboot off || :
16 # NOTE: we're enabling util-vserver to allow it to help shutdown all slices
17 # before rebooting.  This has been problematic in the past
18 chroot ${vdir} /sbin/chkconfig util-vserver off || :
19 # enabling network as it ends up turned off on systems that come with NetworkManager, starting with fedora9
20 chroot ${vdir} /sbin/chkconfig network on || :
21 # and turn off NetworkManager if present, as it quite obviously messes with network
22 chroot ${vdir} /sbin/chkconfig NetworkManager off || :
23
24 # turn OFF vservers-default ; this is to automatically restart vservers, let nm do that
25 chroot ${vdir} /sbin/chkconfig vservers-default off || :
26 # turn ON vprocunhide ; is required with kernels that have CONFIG_VSERVER_PROC_SECURE enabled
27 # which is the case for our k32 kernel
28 # chroot ${vdir} /sbin/chkconfig vprocunhide on || :
29
30 chroot ${vdir} /sbin/chkconfig fprobe-ulog on || :
31
32 # turn off cgconfig
33 chroot ${vdir} /sbin/chkconfig cgconfig off || :
34
35 # turn ON lxc-reference.
36 chroot ${vdir} /sbin/chkconfig lxc-reference on || :
37
38 # Change default target.
39 chroot ${vdir} ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target || :
40
41 # turn OFF selinux if set
42 # this may happen accidentally if you mention too much stuff in bootstrapfs.pkgs
43 for file in /etc/sysconfig/selinux /sbin/load_policy; do
44     [ -f ${vdir}/${file} ] || { echo "$file not found in $vdir - fine" ; continue; }
45     selinuxrpm=$(chroot ${vdir} rpm -qf ${file})
46     if [ -z "$selinuxrpm" ] ; then 
47         echo "SElinux: warning : could not rpm for file $file"
48     else
49         echo "Force-removing package ${selinuxrpm}" 
50         chroot ${vdir} rpm -e --nodeps ${selinuxrpm}
51     fi
52 done
53
54 # Disable splaying of cron.
55 echo > ${vdir}/etc/sysconfig/crontab
56
57 # Add site_admin account
58 chroot ${vdir} /usr/sbin/useradd -p "" -u 502 -m site_admin
59
60 # Remove 32bit packages from 64bit system (http://wiki.centos.org/FAQ/General#head-357346ff0bf7c14b0849c3bcce39677aaca528e9) 
61 # use rpm instead of yum as /proc is not mounted at that poing 
62 if echo ${vdir} | grep -q x86_64 ; then
63     chroot ${vdir} rpm -qa --qf '%{name}.%{arch}\n' | grep 'i[36]86$' | xargs chroot ${vdir} rpm -e
64 fi
65
66 # Add a logrotate script for btmp, which logs failed ssh logins, which can
67 # grow unbounded on public plnodes and fill the root fs.
68 cat <<EOF > ${vdir}/etc/logrotate.d/btmp
69 /var/log/btmp {
70     weekly
71     minsize 1M
72     create 0600 root utmp
73     rotate 2
74     compress
75     notifempty
76 }
77 EOF
78
79 # NOTE:  This is added to relieve one site's Cisco router configuration that
80 # fails to recognize the host once the arping is sent out.
81 # NOTE: this is pretty fragile, and fails on fedora 10 that as of today (oct. 20 2009) 
82 # has initscripts-8.86.3-1.i386 which reads almost identical but with /sbin/arping instead
83 # NOTE: this might work with fedora8 and centos5
84 # the other distros will probably just fail to add this patch
85 cat <<\EOF | patch -d ${vdir}/etc/sysconfig/network-scripts/
86 --- ifup-eth    2008-07-08 13:19:49.000000000 -0400
87 +++ ifup-eth-orig       2008-07-08 13:20:02.000000000 -0400
88 @@ -263,10 +263,10 @@
89      fi
90      
91      if ! LC_ALL=C ip addr ls ${REALDEVICE} | LC_ALL=C grep -q "${IPADDR}/${PREFIX}" ; then
92 -        if ! arping -q -c 2 -w 3 -D -I ${REALDEVICE} ${IPADDR} ; then
93 -           echo $"Error, some other host already uses address ${IPADDR}."
94 -           exit 1
95 -        fi
96 +        #if ! arping -q -c 2 -w 3 -D -I ${REALDEVICE} ${IPADDR} ; then
97 +        #   echo $"Error, some other host already uses address ${IPADDR}."
98 +        #   exit 1
99 +        #fi
100          if ! ip addr add ${IPADDR}/${PREFIX} \
101             brd ${BROADCAST:-+} dev ${REALDEVICE} ${SCOPE} label ${DEVICE}; then
102             echo $"Error adding address ${IPADDR} for ${DEVICE}."
103 EOF