#!/bin/bash # Copyright (C) 2006 Benedikt Boehm # # 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 # setup environment cfgdir="$1" vdir="$cfgdir"/vdir . "$2" # vserver name NAME="$cfgdir" # 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 } # create a locale.gen if needed. if test -n "$LANG" && test "$LANG" != "C"; then echo $LANG $(locale charmap) | $_CHROOT_SH append /etc/locale.gen fi # make apt and friends work $_CHROOT_SH truncate /etc/apt/sources.list <>> Executing post install script ... " echo # start vserver before we can exec anything inside it $_VSERVER "$NAME" stop &>/dev/null || : $_VSERVER "$NAME" start --rescue --rescue-init bash -c ' exec > /dev/null exec 2> /dev/null set -x f=/tmp/startwait trap "rm -f $f" EXIT mkfifo $f ( sleep 15; kill -s 9 -- -1 ) & cat "$f" kill -s 9 -- -1 wait ' # run the configure commands from within the server export LANG=C LC_ALL=C $_CHROOT_SH testfile /usr/sbin/locale-gen && \ $_VSERVER "$NAME" exec /usr/sbin/locale-gen for i in bootlogd checkfs checkroot halt hwclock.sh ifupdown klogd \ libdevmapper1.02 makedev module-init-tools mountall.sh \ mountdevsubfs.sh mountnfs.sh mountkernfs.sh mountvirtfs \ networking reboot setserial single stop-bootlogd \ stop-bootlogd-single umountfs umountnfs.sh umountroot \ urandom; do $_VSERVER "$NAME" exec update-rc.d -f "$i" remove done # stop the vserver $_VSERVER "$NAME" exec bash -c ': >/tmp/startwait' &>/dev/null || : $_VSERVER "$NAME" stop &>/dev/null || : popd &>/dev/null