#!/bin/sh

LAYERFS="unionfs"
[ "`lsmod | grep '^aufs'`" != "" ] && LAYERFS="aufs"

mkdir /pup_rw
mkdir /pup_ro1
mkdir /pup_new

mount -o ro,rbind / /pup_ro1

if [ "$LAYERFS" = "aufs" ];then
 mount -t aufs -o br:/pup_rw:/pup_ro1 aufs /pup_new
else
 mount -t unionfs -o dirs=/pup_rw:/pup_ro1 unionfs /pup_new
fi

echo '#!/bin/sh' > /pup_new/etc/rc.d/rc.sysinit

#exec chroot /pup_new
