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>
27 NAME=$(< "$cfgdir"/name)
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/'
106 # from here on we need to do things live in the server
107 $_CHROOT_SH truncate /vserver-config.sh < "$__DISTRIBDIR"/etch/vserver-config.sh
108 $_CHROOT_SH chmod 0755 /vserver-config.sh
111 echo ">>> Executing post install script ... "
114 # start vserver before we can exec anything inside it
117 # run the configure commands from within the server
118 vserver $NAME exec /vserver-config.sh
119 $_CHROOT_SH rm /vserver-config.sh