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 # check for baselayout >= 1.13
31 pushd "$vdir" &>/dev/null
32 basever=$($_CHROOT_SH cat /etc/gentoo-release | $_AWK '{print $5}')
35 echo ">>> Found baselayout-$basever"
41 if test "$basemaj" -lt 1 -o "$basemin" -lt 13; then
42 echo "!!! Will not do automagic changes to baselayout < 1.13"
43 echo "!!! You have to take care for yourself ..."
48 # fix gettys in inittab
49 pushd "$vdir" &>/dev/null
51 if $_CHROOT_SH testfile /etc/inittab; then
52 echo ">>> Fixing inittab ... "
53 inittabtmp=$($_MKTEMP inittab.XXXXXX)
55 $_CHROOT_SH cat /etc/inittab | \
56 $_SED 's/\(^[^#].*getty.*$\)/#\1/' > $inittabtmp
57 $_CHROOT_SH truncate /etc/inittab < $inittabtmp
65 # unneeded runlevel scripts
66 pushd "$vdir" &>/dev/null
67 echo ">>> Fixing default runlevel scripts ... "
68 $_CHROOT_SH rm /etc/runlevels/boot/{clock,consolefont,keymaps,modules,net.lo} 2>/dev/null || :
69 $_CHROOT_SH rm /etc/runlevels/default/{hdparm,netmount} 2>/dev/null || :
73 # fix fstab for checkfs/localmount
74 pushd "$vdir" &>/dev/null
75 echo ">>> Fixing fstab ... "
76 echo "/dev/hdv1 / ufs defaults 0 0" | $_CHROOT_SH truncate /etc/fstab
80 # gentoo initstyle magic
82 test -e "$1"/apps/init/style && initstyle=$(<"$1"/apps/init/style)
84 if test "$initstyle" == "gentoo"; then
85 pushd "$vdir" &>/dev/null
87 echo ">>> Installing special init-style magic ... "
89 $_CAT "$__DISTRIBDIR"/gentoo/init-vserver.sh | \
90 $_CHROOT_SH truncate /lib/rcscripts/sh/init-vserver.sh
91 $_CHROOT_SH chmod 0755 /lib/rcscripts/sh/init-vserver.sh
96 echo "!!! You have to install a service (e.g. syslog-ng) and add it to the"
97 echo "!!! default runlevel before you start the guest the first time!"
98 echo "!!! Otherwise the guest will die as soon as it has finished booting."
100 echo "!!! Consult the Gentoo Handbook on how to chroot and install"
101 echo "!!! packages into the guest environment."