Add a patch to 'halt' that will shutdown all the processes within contexts
[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 # Add site_admin account
19 chroot ${vdir} /usr/sbin/useradd -p "" -u 502 -m site_admin
20
21 ( cat <<EOF ) | patch -d ${vdir}/etc/init.d/
22 --- halt        2007-10-08 19:18:54.000000000 +0000
23 +++ halt2       2008-05-07 17:52:42.000000000 +0000
24 @@ -65,8 +65,10 @@
25  # Kill all processes.
26  [ "\${BASH+bash}" = bash ] && enable kill
27
28 +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
29  action $"Sending all processes the TERM signal..." /sbin/killall5 -15
30  sleep 2
31 +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
32  action $"Sending all processes the KILL signal..."  /sbin/killall5 -9
33
34  # Write to wtmp file before unmounting /var
35 EOF