3 # Copyright (C) 2006 Benedikt Boehm <hollow@gentoo.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; version 2 of the License.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 ## Called as: initpost <cfgdir> <path of util-vserver-vars>
30 # go to vdir for chroot-sh
31 pushd "$vdir" &>/dev/null
34 # helper for sed in chroot
39 sedtmp=$($_MKTEMP chrootsed.XXXXXX)
41 $_CHROOT_SH cat "$file" | $_SED "$@" > $sedtmp
42 $_CHROOT_SH truncate "$file" < $sedtmp
48 # create a locale.gen if needed.
49 if test -n "$LANG" && test "$LANG" != "C"; then
50 echo $LANG $(locale charmap) | $_CHROOT_SH append /etc/locale.gen
54 # make apt and friends work
55 $_CHROOT_SH truncate /etc/apt/sources.list <<EOF
56 deb $MIRROR/ $DISTRIBUTION main
57 deb-src $MIRROR/ $DISTRIBUTION main
59 deb http://security.debian.org $DISTRIBUTION/updates main
64 if test -r "$cfgdir"/uts/nodename; then
65 $_CHROOT_SH truncate /etc/hostname < "$cfgdir"/uts/nodename
69 # setting default /etc/hosts
70 $_CHROOT_SH truncate /etc/hosts <<EOF
75 # The following lines are desirable for IPv6 capable hosts
76 # (added automatically by netbase upgrade)
78 ::1 ip6-localhost ip6-loopback
80 ff00::0 ip6-mcastprefix
82 ff02::2 ip6-allrouters
87 # copy proxy server statement from host if any
88 if test -f /etc/apt/apt.conf; then
89 $_CHROOT_SH truncate /etc/apt/apt.conf < /etc/apt/apt.conf
93 # fix gettys in inittab
94 if $_CHROOT_SH testfile /etc/inittab; then
95 chrootsed /etc/inittab \
96 -e 's/\(^[^#].*getty.*$\)/#\1/'
100 # fix /proc/cmdline in sendsigs
101 if $_CHROOT_SH testfile /etc/init.d/sendsigs; then
102 chrootsed /etc/init.d/sendsigs \
103 -e 's/^\(\s\+splash_back\)$/#\1/'
107 echo ">>> Executing post install script ... "
110 # start vserver before we can exec anything inside it
111 $_VSERVER "$NAME" stop &>/dev/null || :
112 $_VSERVER "$NAME" start --rescue --rescue-init bash -c '
120 ( sleep 15; kill -s 9 -- -1 ) &
126 # run the configure commands from within the server
127 export LANG=C LC_ALL=C
129 $_CHROOT_SH testfile /usr/sbin/locale-gen && \
130 $_VSERVER "$NAME" exec /usr/sbin/locale-gen
132 for i in bootlogd checkfs checkroot halt hwclock.sh ifupdown klogd \
133 libdevmapper1.02 makedev module-init-tools mountall.sh \
134 mountdevsubfs.sh mountnfs.sh mountkernfs.sh mountvirtfs \
135 networking reboot setserial single stop-bootlogd \
136 stop-bootlogd-single umountfs umountnfs.sh umountroot \
138 $_VSERVER "$NAME" exec update-rc.d -f "$i" remove
142 $_VSERVER "$NAME" exec bash -c ': >/tmp/startwait' &>/dev/null || :
143 $_VSERVER "$NAME" stop &>/dev/null || :