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