X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=distrib%2Fgentoo%2Finitpost;h=af89200cb3dff3e5953f60432f00d84b413162fd;hb=04ef51194afd5168dee1924d85d02acffc80b2e0;hp=66e0f2061944a87c1c7cb8683d951542ed07a8a8;hpb=b7524644f70b0b0c4fba7f11b7e9ad3fb1c783da;p=util-vserver.git diff --git a/distrib/gentoo/initpost b/distrib/gentoo/initpost index 66e0f20..af89200 100755 --- a/distrib/gentoo/initpost +++ b/distrib/gentoo/initpost @@ -1,6 +1,6 @@ -#! /bin/bash +#!/bin/bash -# Copyright (C) 2005 Enrico Scholz +# 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 @@ -17,12 +17,113 @@ ## Called as: initpost +# finish notice from initpre +echo "ok" + + +#setup environment +cfgdir="$1" +vdir="$cfgdir"/vdir . "$2" -$_MKDIR -p "$1"/vdir/usr/portage -$_CAT <> "$1"/fstab -# shared portage tree -/usr/portage /usr/portage none bind,ro 0 0 -/usr/portage/distfiles /usr/portage/distfiles none bind,rw 0 0 -EOF +# go to vdir for chroot-sh +pushd "$vdir" &>/dev/null + + +# helper for sed in chroot +chrootsed() { + local file="$1" + shift + + sedtmp=$($_MKTEMP chrootsed.XXXXXX) + + $_CHROOT_SH cat "$file" | $_SED "$@" > $sedtmp + $_CHROOT_SH truncate "$file" < $sedtmp + + $_RM -f $sedtmp +} + + +# portage stuff +$_CHROOT_SH mkdir /usr 2>/dev/null || : +$_CHROOT_SH mkdir /usr/portage 2>/dev/null || : +$_CHROOT_SH mkdir /usr/portage/distfiles 2>/dev/null || : + + +# gentoo initstyle magic +initstyle=sysv +test -e "$cfgdir"/apps/init/style && initstyle=$(<"$cfgdir"/apps/init/style) + +if test "$initstyle" == "gentoo"; then + 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 + + $_CAT "$__DISTRIBDIR"/gentoo/reboot.sh | \ + $_CHROOT_SH truncate /etc/init.d/reboot.sh + $_CHROOT_SH chmod 0755 /etc/init.d/reboot.sh + + $_CAT "$__DISTRIBDIR"/gentoo/shutdown.sh | \ + $_CHROOT_SH truncate /etc/init.d/shutdown.sh + $_CHROOT_SH chmod 0755 /etc/init.d/shutdown.sh + + echo "!!!" + echo "!!! You have to install a service (e.g. syslog/cron) 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 + + +# unneeded runlevel scripts +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 || : + + +# setting hostname +if test -r "$cfgdir"/uts/nodename && $_CHROOT_SH testfile /etc/conf.d/hostname; then + echo ">>> Setting hostname ... " + chrootsed /etc/conf.d/hostname \ + -e "s:HOSTNAME=\"\(.*\)\":HOSTNAME=\"$(< "$cfgdir"/uts/nodename)\":" +fi + + +# fix syslog-ng.conf +if $_CHROOT_SH testfile /etc/syslog-ng/syslog-ng.conf; then + echo ">>> Fixing syslog-ng.conf ... " + chrootsed /etc/syslog-ng/syslog-ng.conf \ + -e 's:pipe("/proc/kmsg"); ::' \ + -e 's:\(.*console_all.*\):#\1:g' +fi + + +# fix gettys in inittab +if $_CHROOT_SH testfile /etc/inittab; then + echo ">>> Fixing inittab ... " + chrootsed /etc/inittab \ + -e 's/\(^[^#].*getty.*$\)/#\1/' +fi + + +# fix fstab for checkfs/localmount in baselayout-2 +# (does not affect any previous versions) +echo ">>> Fixing fstab ... " +echo "/dev/hdv1 / ufs defaults 0 0" | $_CHROOT_SH truncate /etc/fstab + + +# always satisfy net dependency in baselayout-2 +# (does not affect any previous versions) +echo ">>> Providing dummy net dependency ... " +$_CAT "$__DISTRIBDIR"/gentoo/net.vserver | \ +$_CHROOT_SH truncate /etc/init.d/net.vserver +$_CHROOT_SH chmod 0755 /etc/init.d/net.vserver +$_CHROOT_SH link /etc/init.d/net.vserver /etc/runlevels/boot/net.vserver + +popd &>/dev/null