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>
24 . "$_LIB_VSERVER_BUILD_FUNCTIONS"
31 # go to vdir for chroot-sh
32 pushd "$vdir" &>/dev/null
35 # helper for sed in chroot
40 sedtmp=$($_MKTEMP chrootsed.XXXXXX)
42 $_CHROOT_SH cat "$file" | $_SED "$@" > $sedtmp
43 $_CHROOT_SH truncate "$file" < $sedtmp
49 # create a locale.gen if needed.
50 if test -n "$LANG" && test "$LANG" != "C"; then
51 echo $LANG $(locale charmap) | $_CHROOT_SH append /etc/locale.gen
55 # make apt and friends work
56 $_CHROOT_SH truncate /etc/apt/sources.list <<EOF
57 deb $MIRROR/ $DISTRIBUTION main
58 deb-src $MIRROR/ $DISTRIBUTION main
60 deb http://security.debian.org $DISTRIBUTION/updates main
65 if test -r "$cfgdir"/uts/nodename; then
66 $_CHROOT_SH truncate /etc/hostname < "$cfgdir"/uts/nodename
70 # setting default /etc/hosts
71 $_CHROOT_SH truncate /etc/hosts <<EOF
76 # The following lines are desirable for IPv6 capable hosts
77 # (added automatically by netbase upgrade)
79 ::1 ip6-localhost ip6-loopback
81 ff00::0 ip6-mcastprefix
83 ff02::2 ip6-allrouters
88 # copy proxy server statement from host if any
89 if test -f /etc/apt/apt.conf; then
90 $_CHROOT_SH truncate /etc/apt/apt.conf < /etc/apt/apt.conf
94 # fix gettys in inittab
95 if $_CHROOT_SH testfile /etc/inittab; then
96 chrootsed /etc/inittab \
97 -e 's/\(^[^#].*getty.*$\)/#\1/'
101 # fix /proc/cmdline in sendsigs
102 if $_CHROOT_SH testfile /etc/init.d/sendsigs; then
103 chrootsed /etc/init.d/sendsigs \
104 -e 's/^\(\s\+splash_back\)$/#\1/'
108 echo ">>> Executing post install script ... "
111 # start vserver before we can exec anything inside it
112 $_VSERVER "$NAME" stop &>/dev/null || :
113 startSleepingGuest "$NAME" 30
115 # run the configure commands from within the server
116 export LANG=C LC_ALL=C
118 $_CHROOT_SH testfile /usr/sbin/locale-gen && \
119 $_VSERVER "$NAME" exec /usr/sbin/locale-gen
122 test "$(cat "$cfgdir"/apps/init/style 2>/dev/null)" != "plain" || \
125 pushd etc/init.d &>/dev/null
128 (sysklogd|syslog-ng|README|skeleton|sendsigs|single|rc|rc.local|rcS)
133 $_VSERVER "$NAME" exec update-rc.d -f "$i" remove
140 stopSleepingGuest "$NAME" &>/dev/null || :