3 # Copyright (C) 2007 Natanael Copa <ncopa@alpinelinux.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>
26 echo ">>> Creating missing dirs..."
27 $_CHROOT_SH mkdir proc sys dev home etc etc/rcL.d etc/rcK.d 2>/dev/null
29 # remove mtab which is a link
30 if test -e "$vdir/etc/mtab"; then
31 $_CHROOT_SH rm /etc/mtab 2>/dev/null
34 # trick to install busybox links and boot services
35 echo ">>> Installing boot services..."
37 $_VSERVER "$vserver" stop &>/dev/null || true
38 $_VSERVER "$vserver" start --rescue --rescue-init /bin/busybox sh -c '
39 /bin/busybox --install -s
40 /sbin/rc_add -s 20 -k syslog
44 if test -r "$cfgdir"/uts/nodename; then
45 echo ">>> Setting hostname..."
46 $_CHROOT_SH truncate /etc/hostname < "$cfgdir/uts/nodename"
50 echo -e "none\t/\tnone\tdefaults" | $_CHROOT_SH truncate /etc/fstab
52 # create busybox style inittab
53 cat <<EOF | $_CHROOT_SH truncate /etc/inittab
54 ::wait:/etc/init.d/rcL
55 ::ctrlaltdel:/etc/init.d/rcK
56 ::ctrlaltdel:/usr/bin/killall5 -15
59 # set up cmd.start and cmd stop if needed
60 test -e "$1"/apps/init/style && initstlye=$(cat "$1"/apps/init/style)
61 if test "$initstlye" != "plain"; then
62 echo "/etc/init.d/rcL" > "$cfgdir/apps/init/cmd.start"
63 echo "/etc/init.d/rcK" > "$cfgdir/apps/init/cmd.stop"
66 # vserver should not be running at this point but lets be sure
67 $_VSERVER "$vserver" stop &>/dev/null || true