Changed the patch to reflect current ifup-eth script.
[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 # Remove unneeded services
11 for service in util-vserver vprocunhide vservers-default; do
12     chroot ${vdir} /sbin/chkconfig $service off
13 done
14
15 # Disable splaying of cron.
16 echo > ${vdir}/etc/sysconfig/crontab
17
18 # sss
19 # update /etc/sysconfig/network-scripts/ifup
20 #  #if ! arping -q -c 2 -w 3 -D -I ${REALDEVICE} ${IPADDR} ; then
21       #echo $"Error, some other host already uses address ${IPADDR}."
22       #exit 1
23    #fi
24
25 # Add site_admin account
26 chroot ${vdir} /usr/sbin/useradd -p "" -u 502 -m site_admin
27
28 # NOTE: this is added to ensure that processes running within the slices that
29 # may have special permissions and other parts of the filesystem engated are
30 # killed before shutdown.  We experienced hangs when rebooting without this
31 # step.
32 ( cat <<EOF ) | patch -d ${vdir}/etc/init.d/
33 --- halt        2007-10-08 19:18:54.000000000 +0000
34 +++ halt2       2008-05-07 17:52:42.000000000 +0000
35 @@ -65,8 +65,10 @@
36  # Kill all processes.
37  [ "\${BASH+bash}" = bash ] && enable kill
38
39 +action $"Sending all VServers the TERM signal..."  ls -d /proc/virtual/[0-9]* | awk -F '/' '{print \$4}' | xargs -I{} /usr/sbin/vkill -s 15 --xid {} -- 0
40  action $"Sending all processes the TERM signal..." /sbin/killall5 -15
41  sleep 2
42 +action $"Sending all VServers the KILL signal..."  ls -d /proc/virtual/[0-9]* | awk -F '/' '{print \$4}' | xargs -I{} /usr/sbin/vkill -s 9 --xid {} -- 0
43  action $"Sending all processes the KILL signal..."  /sbin/killall5 -9
44
45  # Write to wtmp file before unmounting /var
46 EOF
47
48 # NOTE:  This is added to relieve one site's Cisco router configuration that
49 # fails to recognize the host once the arping is sent out.
50 cat <<\EOF | patch -d ${vdir}/etc/sysconfig/network-scripts/
51 --- ifup-eth    2008-07-08 13:19:49.000000000 -0400
52 +++ ifup-eth-orig       2008-07-08 13:20:02.000000000 -0400
53 @@ -263,10 +263,10 @@
54      fi
55      
56      if ! LC_ALL=C ip addr ls ${REALDEVICE} | LC_ALL=C grep -q "${IPADDR}/${PREFIX}" ; then
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 ! arping -q -c 2 -w 3 -D -I ${REALDEVICE} ${IPADDR} ; then
62 +        #   echo $"Error, some other host already uses address ${IPADDR}."
63 +        #   exit 1
64 +        #fi
65          if ! ip addr add ${IPADDR}/${PREFIX} \
66             brd ${BROADCAST:-+} dev ${REALDEVICE} ${SCOPE} label ${DEVICE}; then
67             echo $"Error adding address ${IPADDR} for ${DEVICE}."
68 EOF
69