#! /bin/sh -e
#
# Last finishing touch before rebooting into the installed system.

# Avoid warnings when running perl programs using chroot /target
unset LANG
unset LANGUAGE

## Test if base-config is avalible in the chroot, and if so, run trust
## that base-config will be run after the installation is done
## if not (etch install?), then run base-config after other things are done
## FIXME - need to mount the CD before running this if doing a CD-install

# Make sure that proc is mounted for the cfengine run
if [ ! -d /target/proc/bus ] ; then
  mount /target/proc proc -t proc || true
fi

# Make sure that the interfaces are there for the cfengine run
chroot /target /etc/init.d/networking start || true

if [ ! -x /target/usr/sbin/base-config ] ; then 
  # libnss-ldap seem to remove this while when it is installed.  Reinsert it to
  # make cfengine can do its stuff without hanging.
  touch /target/var/lib/nss-ldap/bind_policy_soft

  chroot /target cfengine-debian-edu -D installation || true
fi

exit 0
