3 # Copyright (C) 2006 Benedikt Boehm <hollow@gentoo.org>
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 ## Called as: initpost <cfgdir> <path of util-vserver-vars>
24 pushd "$vdir" &>/dev/null
25 $_CHROOT_SH mkdir /usr 2>/dev/null || :
26 $_CHROOT_SH mkdir /usr/portage 2>/dev/null || :
30 # gentoo initstyle magic
32 test -e "$1"/apps/init/style && initstyle=$(<"$1"/apps/init/style)
34 if test "$initstyle" == "gentoo"; then
35 pushd "$vdir" &>/dev/null
37 echo ">>> Installing special init-style magic ... "
39 $_CAT "$__DISTRIBDIR"/gentoo/init-vserver.sh | \
40 $_CHROOT_SH truncate /lib/rcscripts/sh/init-vserver.sh
41 $_CHROOT_SH chmod 0755 /lib/rcscripts/sh/init-vserver.sh
46 echo "!!! You have to install a service (e.g. syslog-ng) and add it to the"
47 echo "!!! default runlevel before you start the guest the first time!"
48 echo "!!! Otherwise the guest will die as soon as it has finished booting."
50 echo "!!! Consult the Gentoo Handbook on how to chroot and install"
51 echo "!!! packages into the guest environment."
56 # check for baselayout >= 1.13
57 pushd "$vdir" &>/dev/null
58 basever=$($_CHROOT_SH cat /etc/gentoo-release | $_AWK '{print $5}')
61 echo ">>> Found baselayout-$basever"
67 if test "$basemaj" -lt 1 -o "$basemin" -lt 13; then
68 echo "!!! Will not do automagic changes to baselayout < 1.13"
69 echo "!!! You have to take care for yourself ..."
74 # fix gettys in inittab
75 pushd "$vdir" &>/dev/null
77 if $_CHROOT_SH testfile /etc/inittab; then
78 echo ">>> Fixing inittab ... "
79 inittabtmp=$($_MKTEMP inittab.XXXXXX)
81 $_CHROOT_SH cat /etc/inittab | \
82 $_SED 's/\(^[^#].*getty.*$\)/#\1/' > $inittabtmp
83 $_CHROOT_SH truncate /etc/inittab < $inittabtmp
91 # unneeded runlevel scripts
92 pushd "$vdir" &>/dev/null
93 echo ">>> Fixing default runlevel scripts ... "
94 $_CHROOT_SH rm /etc/runlevels/boot/{clock,consolefont,keymaps,modules,net.lo} 2>/dev/null || :
95 $_CHROOT_SH rm /etc/runlevels/default/{hdparm,netmount} 2>/dev/null || :
99 # fix fstab for checkfs/localmount
100 pushd "$vdir" &>/dev/null
101 echo ">>> Fixing fstab ... "
102 echo "/dev/hdv1 / ufs defaults 0 0" | $_CHROOT_SH truncate /etc/fstab