#!/bin/sh 
#
#
#

KEEP="/dev/log
"


if [ Q$1 == "Q" -o Q$2 == "Q" ]
then
	echo "Usage: upratejail <config.file> <jail identifier>"
else

	JAIL=`cat $1 | grep Root: | grep $2 | awk '{print $2}'`
	echo "jail: " $JAIL
	echo "config: " $1
	read

	
	if test -d $JAIL
	then
		cd $JAIL

		find $JAIL -type b > /tmp/$$.updatejail
		find $JAIL -type c >> /tmp/$$.updatejail
		find $JAIL -type p >> /tmp/$$.updatejail
		find $JAIL -type f >> /tmp/$$.updatejail
		find $JAIL -type l >> /tmp/$$.updatejail
		find $JAIL -type s >> /tmp/$$.updatejail
		for i in `echo $KEEP`
		do
			cat /tmp/$$.updatejail | grep -v $JAIL$i > /tmp/$$.updatejail.tmp
			mv /tmp/$$.updatejail.tmp /tmp/$$.updatejail
		done
		for i in `cat /tmp/$$.updatejail`
		do
			rm $i
		done
		rm /tmp/$$.updatejail
		/usr/sbin/jailer.pl $1 $2
	else
		echo "This jail does not exist!"
	fi
fi
