#!/bin/sh -e

set -x
BASE=/media/snop/kristian/home-base
MYHOME=/home/kristian
MYUID=kristian
MYGID=kristian
TMPSIZE=500M
LINKS="Documents Source tmp"

mount tmpfs -t tmpfs -o mode=700,size=$TMPSIZE,uid=$MYUID,gid=$MYGID $BASE/sandbox
#unionfs-fuse -o cow -o allow_other $BASE/sandbox=RW:$BASE/base=RO $MYHOME
mount -t aufs aufs $MYHOME -o relatime,dirs=$BASE/sandbox=rw:$BASE/base=ro

for a in $LINKS; do
	if [ -f $MYHOME/$a ]; then
		echo "Warning: $a defined as link, but present in base files."
		continue
	fi
	ln -s $BASE/$a $MYHOME/$a
done

#mount -t unionfs unionfs -o dirs=$BASE/base=ro:$BASE/sandbox=rw $MYHOME
