fix runlevel scripts for older baselayouts too; set hostname inside the guest
authorBenedikt Boehm <hollow@gentoo.org>
Sat, 20 Jan 2007 17:31:44 +0000 (17:31 +0000)
committerBenedikt Boehm <hollow@gentoo.org>
Sat, 20 Jan 2007 17:31:44 +0000 (17:31 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2465 94cd875c-1c1d-0410-91d2-eb244daf1a30

distrib/gentoo/initpost

index 2d2dd4c..e30455b 100755 (executable)
@@ -17,7 +17,8 @@
 
 ## Called as: initpost <cfgdir> <path of util-vserver-vars>
 
-vdir="$1"/vdir
+cfgdir="$1"
+vdir="$cfgdir"/vdir
 . "$2"
 
 # portage stuff
@@ -29,7 +30,7 @@ popd &>/dev/null
 
 # gentoo initstyle magic
 initstyle=sysv
-test -e "$1"/apps/init/style && initstyle=$(<"$1"/apps/init/style)
+test -e "$cfgdir"/apps/init/style && initstyle=$(<"$cfgdir"/apps/init/style)
 
 if test "$initstyle" == "gentoo"; then
        pushd "$vdir" &>/dev/null
@@ -53,6 +54,31 @@ if test "$initstyle" == "gentoo"; then
 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
+fi
+
+popd &>/dev/null
+
+
 # check for baselayout >= 1.13
 pushd "$vdir" &>/dev/null
 basever=$($_CHROOT_SH cat /etc/gentoo-release | $_AWK '{print $5}')
@@ -88,14 +114,6 @@ 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 ... "