3 # Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; version 2 of the License.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 ## HACK: this script is full of races...
25 test ! -e "$2" -o -L "$2" || mv -f "$2"{,.orig}
29 ## Usage: subst <file> <regexp>
32 tmp=$(mktemp /tmp/initpost-subst.XXXXXX)
36 (*) $_CHROOT_SH cat "$1";;
37 esac | sed -e "$2" >$tmp
38 cmp -s $tmp "$1" || $_CHROOT_SH truncate "$1" <$tmp
45 ## Do some magic to set the vserver into a defined state
46 $_VSERVER "$vserver" stop &>/dev/null || :
47 $_VSERVER "$vserver" start --rescue bash -c '
55 ( sleep 10; kill -s 9 -- -1 ) &
61 pushd "$vdir"/etc/init.d &>/dev/null ||
62 pushd "$vdir"/etc/rc.d/init.d &>/dev/null || exit 1
65 test -e "$i" || continue
67 functions|halt|killall|single) ;;
70 $_VSERVER "$1" chkconfig "$i" off
77 pushd "$vdir"/sbin &>/dev/null
78 relink /bin/true new-kernel-pkg
81 pushd "$vdir"/usr/bin &>/dev/null
82 relink /bin/true rhgb-client
85 pushd "$vdir" &>/dev/null
86 echo 'NETWORKING=yes' | $_CHROOT_SH append /etc/sysconfig/network
89 pushd "$vdir" &>/dev/null
90 cat <<EOF | $_CHROOT_SH truncate /etc/init.d/halt
93 exec /sbin/killall5 -15
95 # TODO: remove race/symlink-attack
96 chmod +x etc/init.d/halt
98 : | $_CHROOT_SH truncate /etc/sysctl.conf
99 echo "none / none defaults" | $_CHROOT_SH truncate /etc/fstab
100 cat "$__DISTRIBDIR"/redhat/rc.sysinit | $_CHROOT_SH truncate /etc/rc.d/rc.sysinit.vserver
101 # TODO: remove race/symlink-attack
102 chmod +x etc/rc.d/rc.sysinit.vserver
103 subst etc/inittab 's!^\([^#].*:respawn:.* tty\)!#\1!;
104 s!si::sysinit:/etc/rc.d/rc.sysinit!si::sysinit:/etc/rc.d/rc.sysinit.vserver!'
107 $_VSERVER "$vserver" exec bash -c ': >/tmp/startwait' &>/dev/null || :
108 $_VSERVER "$vserver" stop &>/dev/null || :