This file is indexed.

/usr/lib/util-vserver/distributions/gentoo/initpost is in util-vserver 0.30.216-pre2864-2ubuntu1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash

# Copyright (C) 2006 Benedikt Boehm <hollow@gentoo.org>
#  
# 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 <cfgdir> <path of util-vserver-vars>

# finish notice from initpre
echo "ok"


#setup environment
cfgdir="$1"
vdir="$cfgdir"/vdir
. "$2"


# 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 || :


# check if we have openrc
have_openrc=0
$_CHROOT_SH testfile /lib/rc/bin/is_older_than && have_openrc=1


# 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 ... "

	# force /lib/rc/sh even if we don't have it in older stages
	$_CHROOT_SH mkdir /lib 2>/dev/null || :
	$_CHROOT_SH mkdir /lib/rc 2>/dev/null || :
	$_CHROOT_SH mkdir /lib/rc/sh 2>/dev/null || :

	$_CAT "$__DISTRIBDIR"/gentoo/init-vserver.sh | \
	$_CHROOT_SH truncate   /lib/rc/sh/init-vserver.sh
	$_CHROOT_SH chmod 0755 /lib/rc/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 "!!!"
else
	# fix gettys in inittab
	if $_CHROOT_SH testfile /etc/inittab; then
		echo ">>> Fixing inittab ... "
		chrootsed /etc/inittab \
			-e 's/\(^[^#].*getty.*$\)/#\1/'
	fi
fi

# unneeded runlevel scripts
if test $have_openrc -ne 1; then
	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 || :
fi

# 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\)=\"\(.*\)\":\1=\"$(< "$cfgdir"/uts/nodename)\":i"
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 fstab for checkfs/localmount in baselayout-2
# (does not affect any previous versions)
if test $have_openrc -ne 1; then
	echo ">>> Fixing fstab ... "
	echo "/dev/hdv1 / ufs defaults 0 0" | $_CHROOT_SH truncate /etc/fstab
fi

# always satisfy net dependency in baselayout-2
# (does not affect any previous versions)
if test $have_openrc -ne 1; then
	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
fi

popd &>/dev/null