#!/bin/csh

########################################################################
#
# FILE:		setup
#
# PURPOSE:	This script should be run from it's location directory
#		at installation time.
#		1. It resets MAZEMANHOME in the file mazeman.
#		2. It resets the list of Top 10 players and scores.
#		3. It sets the file permissions so that all users can
#		   run mazeman and high scores can be retained.
#
########################################################################


# 1. Reset MAZEMANHOME in mazeman
echo "Resetting MAZEMANHOME..."
set home = `pwd`
sed '/^setenv MAZEMANHOME.*$/c\\
setenv MAZEMANHOME '"$home" mazeman > tmp
/bin/mv -f tmp mazeman
echo "...done."


# 2. Top 10 Maze Men
echo "Updating list of Top 10 Maze Man..."
if (-e scripts/top0names) /bin/cp scripts/top0names scripts/top10names
if (-e scripts/top0scores) /bin/cp scripts/top0scores scripts/top10scores
echo "...done."


# 3. File Permissions
echo "Updating file permissions for Maze Man..."

# mazeman executable
/bin/chmod a+rx .
/bin/chmod a+rx mazeman

# tk objects
/bin/chmod -R a+r bitmaps
/bin/chmod    a+x bitmaps
/bin/chmod -R a+r elevators
/bin/chmod    a+x elevators
/bin/chmod -R a+r ghosts
/bin/chmod    a+x ghosts
/bin/chmod -R a+r man
/bin/chmod    a+x man

# interpreter executable
/bin/chmod a+rx src
if (-e src/mazewish) /bin/chmod a+rx src/mazewish

# tcl/tk scripts
/bin/chmod -R a+r scripts
/bin/chmod a+wx scripts
if (-e scripts/gamespeed.tcl) /bin/chmod a+rw scripts/gamespeed.tcl
if (-e scripts/top10names) /bin/chmod a+rw scripts/top10names
if (-e scripts/top10scores) /bin/chmod a+rw scripts/top10scores

echo "...done."

