#!/bin/sh
#Mounts top level directories of a shared chroot file system into a chroot jail
#copyright 2004 Gyepi Sam <gyepi@praxis-sw.com>

source_root=$1

if [ -z "$source_root" ]; then
  echo "source root directory required"
  exit 1
fi


target_root=$2

if [ -z "$target_root" ]; then
  echo "target root directory required"
  exit 1
fi

SRC_DIRS=`find $source_root -type d -mindepth 1 -maxdepth 1`

for d in $SRC_DIRS; do
 dest="$target_root/$(basename $d)"
 test -d $dest || mkdir -p $dest
 umount $dest 2> /dev/null
 mount --bind $d $dest
done

