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...
22 . "$_LIB_VSERVER_BUILD_FUNCTIONS"
26 test ! -e "$2" -o -L "$2" || mv -f "$2"{,.orig}
30 ## Usage: subst <file> <regexp>
33 tmp=$(mktemp /tmp/initpost-subst.XXXXXX)
37 (*) $_CHROOT_SH cat "$1";;
38 esac | sed -e "$2" >$tmp
39 cmp -s $tmp "$1" || $_CHROOT_SH truncate "$1" <$tmp
46 ## Do some magic to set the vserver into a defined state
47 $_VSERVER "$vserver" stop &>/dev/null || :
48 startSleepingGuest "$vserver" 15
50 pushd "$vdir"/etc/init.d &>/dev/null ||
51 pushd "$vdir"/etc/rc.d/init.d &>/dev/null || exit 1
54 test -e "$i" || continue
56 functions|halt|killall|single) ;;
58 $_VSERVER "$1" chkconfig "$i" on
61 $_VSERVER "$1" chkconfig "$i" off
68 pushd "$vdir"/sbin &>/dev/null
69 relink /bin/true new-kernel-pkg
72 pushd "$vdir"/usr/bin &>/dev/null
73 relink /bin/true rhgb-client
76 pushd "$vdir" &>/dev/null
77 echo 'NETWORKING=yes' | $_CHROOT_SH append /etc/sysconfig/network
80 pushd "$vdir" &>/dev/null
81 cat <<EOF | $_CHROOT_SH truncate /etc/init.d/halt
84 exec /sbin/killall5 -15
86 $_CHROOT_SH chmod 0755 /etc/init.d/halt
88 : | $_CHROOT_SH truncate /etc/sysctl.conf
89 echo "none / none defaults" | $_CHROOT_SH truncate /etc/fstab
90 cat "$__DISTRIBDIR"/redhat/rc.sysinit | $_CHROOT_SH truncate /etc/rc.d/rc.sysinit.vserver
91 $_CHROOT_SH chmod 0755 /etc/rc.d/rc.sysinit.vserver
92 subst etc/inittab 's!^\([^#].*:respawn:.* tty\)!#\1!;
93 s!si::sysinit:/etc/rc.d/rc.sysinit!si::sysinit:/etc/rc.d/rc.sysinit.vserver!'
95 if $_CHROOT_SH testfile /sbin/initctl; then
96 cat "$__DISTRIBDIR"/redhat/initctl | $_CHROOT_SH truncate /sbin/initctl.vserver
97 $_CHROOT_SH chmod 0755 /sbin/initctl.vserver
98 subst etc/rc.d/rc 's!^\(.*\)/proc/cmdline\(.*\)$!\1/proc/cmdline 2>/dev/null \2!;s!/sbin/initctl!/sbin/initctl.vserver!'
99 subst etc/event.d/rcS 's!/etc/rc.d/rc.sysinit!/etc/rc.d/rc.sysinit.vserver!'
100 $_CHROOT_SH rm /etc/event.d/tty{1,2,3,4,5,6}
104 stopSleepingGuest "$vserver" &> /dev/null || :