#!/bin/bash # Copyright (C) 2007 Natanael Copa # # 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 cfgdir="$1" vdir="$cfgdir"/vdir . "$2" echo ">>> Installing busybox links..." # create fake /proc/self/exe mkdir -p "$vdir/proc/self" ln -s /bin/busybox "$vdir/proc/self/exe" chroot "$vdir" /bin/busybox --install -s rm -r "$vdir/proc/self" echo ">>> Creating missing dirs..." for dir in proc sys dev home; do mkdir -p "$vdir/$dir" done echo ">>> Installing boot services..." chroot "$vdir" rc_add -s 20 -k syslog if test -r "$cfgdir"/uts/nodename; then echo ">>> Setting hostname..." cp "$cfgdir/uts/nodename" "$vdir/etc/hostname" fi # remove mtab which is a link rm -f "$vdir/etc/mtab" # set up cmd.start and cmd stop echo "/etc/init.d/rcL" > "$cfgdir/apps/init/cmd.start" echo "/etc/init.d/rcK" > "$cfgdir/apps/init/cmd.stop" # check grsec chroot_caps if [ "$(cat /proc/sys/kernel/grsecurity/chroot_caps 2>/dev/null)" = "1" ]; then echo "!!!" echo "!!! You need to turn off chroot_caps in grsecurity to be able to start" echo "!!! the guest. To do this, run:" echo "!!!" echo "!!! echo 'kernel.grsecurity.chroot_caps = 0' >> /etc/sysctl.conf" echo "!!! sysctl -p /etc/sysctl.conf" echo "!!!" fi