#!/bin/sh

# sets up an environment so that daemons don't actually get run,
# and proc is mounted for package installs which may require it.

# copyright 2004 vagrant@freegeek.org, distributed under the terms of the
# GNU General Public License version 2 or any later version.

if [ -r /etc/lessdisks-install.conf ]; then
  . /etc/lessdisks-install.conf
fi

if [ -r /etc/lessdisks/server.config ]; then
  . /etc/lessdisks/server.config
fi

if [ -z "$lessdisks_path" -o ! -d "$lessdisks_path" ]; then
  exit 1
fi

# some package installs make use of /proc, so mount it
chroot $lessdisks_path mount -t proc proc /proc

# set start-stop-daemon to behave like fake daemon
# so that packages which attempt to start servers don't do so while
# in the chroot.
export LESSDISKS_START_STOP_DAEMON=fake
chroot $lessdisks_path $@

# unmount /proc
chroot $lessdisks_path umount /proc
