cleanup gentoo/initpost; add fixes for syslog-ng.conf and net dependency in baselayou...
authorBenedikt Boehm <hollow@gentoo.org>
Tue, 23 Jan 2007 16:41:03 +0000 (16:41 +0000)
committerBenedikt Boehm <hollow@gentoo.org>
Tue, 23 Jan 2007 16:41:03 +0000 (16:41 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2471 94cd875c-1c1d-0410-91d2-eb244daf1a30

distrib/Makefile.am
distrib/gentoo/initpost
distrib/gentoo/initpre
distrib/gentoo/net.vserver [new file with mode: 0755]

index c83f344..8efb767 100644 (file)
@@ -33,7 +33,8 @@ nobase_distrib_SCRIPTS        =  redhat/initpost \
                           redhat/rc.sysinit \
                           gentoo/initpost \
                           gentoo/initpre \
-                          gentoo/init-vserver.sh
+                          gentoo/init-vserver.sh \
+                          gentoo/net.vserver
 
 nobase_distrib_DATA    =  defaults/devs \
                           defaults/apt.conf \
index e30455b..ad75b77 100755 (executable)
 
 ## Called as: initpost <cfgdir> <path of util-vserver-vars>
 
+# finish notice from initpre
+echo "ok"
+
+
+#setup environment
 cfgdir="$1"
 vdir="$cfgdir"/vdir
 . "$2"
 
-# portage stuff
+
+# 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 || :
-popd &>/dev/null
 
 
 # gentoo initstyle magic
@@ -33,16 +55,12 @@ initstyle=sysv
 test -e "$cfgdir"/apps/init/style && initstyle=$(<"$cfgdir"/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!"
@@ -55,67 +73,47 @@ fi
 
 
 # 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
 
 
 # setting hostname
-pushd "$vdir" &>/dev/null
-
 if test -r "$cfgdir"/uts/nodename && $_CHROOT_SH testfile /etc/conf.d/hostname; then
        echo ">>> Setting hostname ... "
-       hostnametmp=$($_MKTEMP hostname.XXXXXX)
-
-       $_CHROOT_SH cat /etc/conf.d/hostname | \
-       $_SED "s:HOSTNAME=\"\(.*\)\":HOSTNAME=\"$(< "$cfgdir"/uts/nodename)\":" > $hostnametmp
-       $_CHROOT_SH truncate /etc/conf.d/hostname  < $hostnametmp
-
-       $_RM -f $hostnametmp
+       chrootsed /etc/conf.d/hostname \
+               -e "s:HOSTNAME=\"\(.*\)\":HOSTNAME=\"$(< "$cfgdir"/uts/nodename)\":"
 fi
 
-popd &>/dev/null
-
-
-# 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
+# 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
-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
+       chrootsed /etc/inittab \
+               -e 's/\(^[^#].*getty.*$\)/#\1/'
 fi
 
-popd &>/dev/null
-
 
-# fix fstab for checkfs/localmount
-pushd "$vdir" &>/dev/null
+# fix fstab for checkfs/localmount in baselayout >= 1.13
+# (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 >= 1.13
+# (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
+
 popd &>/dev/null
index 24ffd80..4d18d69 100755 (executable)
@@ -21,17 +21,24 @@ vdir="$1"/vdir
 . "$2"
 
 # portage stuff
-
 echo ">>> Adding shared /usr/portage to fstab ... "
 
-if test -d /usr/portage; then
+hash portageq &>/dev/null
+
+if test $? -eq 0; then
+       _PORTDIR=$(portageq portdir)
+else
+       _PORTDIR=/usr/portage
+fi
+
+if test -d $_PORTDIR; then
        ( echo
          echo "# shared portage tree"
-         echo "/usr/portage           /usr/portage           none bind,ro 0 0"
-         echo "/usr/portage/distfiles /usr/portage/distfiles none bind,rw 0 0"
+         echo "${_PORTDIR}           /usr/portage           none bind,ro 0 0"
+         echo "${_PORTDIR}/distfiles /usr/portage/distfiles none bind,rw 0 0"
        ) >> "$1"/fstab
 else
-       echo "!!! Cannot find /usr/portage! You should definitely use a"
+       echo "!!! Cannot find a portage tree! You should definitely use a"
        echo "!!! shared portage tree if you have multiple Gentoo guests!"
 fi
 
@@ -46,3 +53,5 @@ if test "$initstyle" != "gentoo" -a "$initstyle" != "plain"; then
        echo "!!! The init-style you specified is not supported for Gentoo"
        echo "!!! Please use one of: plain, gentoo"
 fi
+
+echo -n ">>> Unpacking template ... "
diff --git a/distrib/gentoo/net.vserver b/distrib/gentoo/net.vserver
new file mode 100755 (executable)
index 0000000..8348277
--- /dev/null
@@ -0,0 +1,16 @@
+#!/sbin/runscript
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+depend() {
+        provide net
+}
+
+start() {
+        return 0
+}
+
+stop() {
+        return 0
+}