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>
25 pushd "$vdir" &>/dev/null
26 $_CHROOT_SH mkdir /usr 2>/dev/null || :
27 $_CHROOT_SH mkdir /usr/portage 2>/dev/null || :
31 # gentoo initstyle magic
33 test -e "$cfgdir"/apps/init/style && initstyle=$(<"$cfgdir"/apps/init/style)
35 if test "$initstyle" == "gentoo"; then
36 pushd "$vdir" &>/dev/null
38 echo ">>> Installing special init-style magic ... "
40 $_CAT "$__DISTRIBDIR"/gentoo/init-vserver.sh | \
41 $_CHROOT_SH truncate /lib/rcscripts/sh/init-vserver.sh
42 $_CHROOT_SH chmod 0755 /lib/rcscripts/sh/init-vserver.sh
47 echo "!!! You have to install a service (e.g. syslog-ng) and add it to the"
48 echo "!!! default runlevel before you start the guest the first time!"
49 echo "!!! Otherwise the guest will die as soon as it has finished booting."
51 echo "!!! Consult the Gentoo Handbook on how to chroot and install"
52 echo "!!! packages into the guest environment."
57 # unneeded runlevel scripts
58 pushd "$vdir" &>/dev/null
59 echo ">>> Fixing default runlevel scripts ... "
60 $_CHROOT_SH rm /etc/runlevels/boot/{clock,consolefont,keymaps,modules,net.lo} 2>/dev/null || :
61 $_CHROOT_SH rm /etc/runlevels/default/{hdparm,netmount} 2>/dev/null || :
66 pushd "$vdir" &>/dev/null
68 if test -r "$cfgdir"/uts/nodename && $_CHROOT_SH testfile /etc/conf.d/hostname; then
69 echo ">>> Setting hostname ... "
70 hostnametmp=$($_MKTEMP hostname.XXXXXX)
72 $_CHROOT_SH cat /etc/conf.d/hostname | \
73 $_SED "s:HOSTNAME=\"\(.*\)\":HOSTNAME=\"$(< "$cfgdir"/uts/nodename)\":" > $hostnametmp
74 $_CHROOT_SH truncate /etc/conf.d/hostname < $hostnametmp
82 # check for baselayout >= 1.13
83 pushd "$vdir" &>/dev/null
84 basever=$($_CHROOT_SH cat /etc/gentoo-release | $_AWK '{print $5}')
87 echo ">>> Found baselayout-$basever"
93 if test "$basemaj" -lt 1 -o "$basemin" -lt 13; then
94 echo "!!! Will not do automagic changes to baselayout < 1.13"
95 echo "!!! You have to take care for yourself ..."
100 # fix gettys in inittab
101 pushd "$vdir" &>/dev/null
103 if $_CHROOT_SH testfile /etc/inittab; then
104 echo ">>> Fixing inittab ... "
105 inittabtmp=$($_MKTEMP inittab.XXXXXX)
107 $_CHROOT_SH cat /etc/inittab | \
108 $_SED 's/\(^[^#].*getty.*$\)/#\1/' > $inittabtmp
109 $_CHROOT_SH truncate /etc/inittab < $inittabtmp
117 # fix fstab for checkfs/localmount
118 pushd "$vdir" &>/dev/null
119 echo ">>> Fixing fstab ... "
120 echo "/dev/hdv1 / ufs defaults 0 0" | $_CHROOT_SH truncate /etc/fstab