X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=distrib%2Fgentoo%2Finitpost;fp=distrib%2Fgentoo%2Finitpost;h=2d2dd4ce58cc2b74c96662e4e9978c9a890788ea;hb=3b34449070c0846fdc49436d1edd5916512f1644;hp=0000000000000000000000000000000000000000;hpb=7370d748ee384dd549f2947c60ebc9a647907d06;p=util-vserver.git diff --git a/distrib/gentoo/initpost b/distrib/gentoo/initpost new file mode 100755 index 0000000..2d2dd4c --- /dev/null +++ b/distrib/gentoo/initpost @@ -0,0 +1,103 @@ +#!/bin/bash + +# Copyright (C) 2006 Benedikt Boehm +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +## Called as: initpost + +vdir="$1"/vdir +. "$2" + +# portage stuff +pushd "$vdir" &>/dev/null +$_CHROOT_SH mkdir /usr 2>/dev/null || : +$_CHROOT_SH mkdir /usr/portage 2>/dev/null || : +popd &>/dev/null + + +# gentoo initstyle magic +initstyle=sysv +test -e "$1"/apps/init/style && initstyle=$(<"$1"/apps/init/style) + +if test "$initstyle" == "gentoo"; then + pushd "$vdir" &>/dev/null + + echo ">>> Installing special init-style magic ... " + + $_CAT "$__DISTRIBDIR"/gentoo/init-vserver.sh | \ + $_CHROOT_SH truncate /lib/rcscripts/sh/init-vserver.sh + $_CHROOT_SH chmod 0755 /lib/rcscripts/sh/init-vserver.sh + + popd &>/dev/null + + echo "!!!" + echo "!!! You have to install a service (e.g. syslog-ng) and add it to the" + echo "!!! default runlevel before you start the guest the first time!" + echo "!!! Otherwise the guest will die as soon as it has finished booting." + echo "!!!" + echo "!!! Consult the Gentoo Handbook on how to chroot and install" + echo "!!! packages into the guest environment." + echo "!!!" +fi + + +# check for baselayout >= 1.13 +pushd "$vdir" &>/dev/null +basever=$($_CHROOT_SH cat /etc/gentoo-release | $_AWK '{print $5}') +popd &>/dev/null + +echo ">>> Found baselayout-$basever" + +basemaj=${basever/.*} +basemin=${basever#*.} +basemin=${basemin/.*} + +if test "$basemaj" -lt 1 -o "$basemin" -lt 13; then + echo "!!! Will not do automagic changes to baselayout < 1.13" + echo "!!! You have to take care for yourself ..." + exit 0 +fi + + +# fix gettys in inittab +pushd "$vdir" &>/dev/null + +if $_CHROOT_SH testfile /etc/inittab; then + echo ">>> Fixing inittab ... " + inittabtmp=$($_MKTEMP inittab.XXXXXX) + + $_CHROOT_SH cat /etc/inittab | \ + $_SED 's/\(^[^#].*getty.*$\)/#\1/' > $inittabtmp + $_CHROOT_SH truncate /etc/inittab < $inittabtmp + + $_RM -f $inittabtmp +fi + +popd &>/dev/null + + +# unneeded runlevel scripts +pushd "$vdir" &>/dev/null +echo ">>> Fixing default runlevel scripts ... " +$_CHROOT_SH rm /etc/runlevels/boot/{clock,consolefont,keymaps,modules,net.lo} 2>/dev/null || : +$_CHROOT_SH rm /etc/runlevels/default/{hdparm,netmount} 2>/dev/null || : +popd &>/dev/null + + +# fix fstab for checkfs/localmount +pushd "$vdir" &>/dev/null +echo ">>> Fixing fstab ... " +echo "/dev/hdv1 / ufs defaults 0 0" | $_CHROOT_SH truncate /etc/fstab +popd &>/dev/null