#! /bin/sh

# This script tidies up bcnu file permissions.
# it should normally be run by root

BCNUHOME=${BCNUHOME:=/usr/local/bcnu} 

if [ ! -d $BCNUHOME ]
	then
		echo "bcnu home directory ($BCNUHOME) doesn't exist"
		exit
	fi

. $BCNUHOME/etc/bcnuenv
. $BCNUHOME/etc/bcnuenv.$BCNUSERVER
. $BCNUHOME/etc/bcnulocal

chown -R $BCNUUSER $BCNUHOME
chgrp -R $BCNUGROUP $BCNUHOME
chmod -R +rx $BCNUHOME
chmod -R 700 $BCNUHOME/bin $BCNUHOME/platform $BCNUHOME/scripts
chmod -R a+rw $BCNUHOME/flags $BCNUHOME/logs $BCNUHOME/data/files $BCNUHOME/retry

for CHLOG in `ls $BCNUHOME/logs/*.log 2>/dev/null`
do
	chmod 777 $CHLOG
done
