#! /bin/sh
# the magic number is different for the 386 raster
ARCTYPE=`arch`
if [ "$ARCTYPE" = "sun386" ]
	then
	  RASMAGIC="-1788172711"
	else
	  RASMAGIC="0x59a66a95"
fi
echo "This shell script sets up file type rules for the File Manager."
echo "It will have to be run as root.  It will append entries to"
echo "/etc/magic and create the rules database: /etc/filetype."
echo "You must have the environment variable OPENWINHOME set"
echo -n "Press return to continue "
read L

installer=`whoami`
if [ "$installer" != "root" ]
then
    echo
    echo "You must be user \"root\" to run this installation script. Exiting.."
    exit
fi

if [ "$OPENWINHOME" = "" ]
	then
	  echo
	  echo "Your OPENWINHOME variable is not set. Exiting..."
	  exit
	else
	  echo
	  echo "Your OPENWINHOME variable is set to : $OPENWINHOME"
	  echo "If this is correct, press return to continue,"
	  echo "otherwise Ctrl-c to quit."
	  read L
fi
IDIR=\$OPENWINHOME/include/images
status=0
grep -s "mail folder" /etc/magic
status=$?
if [ $status != 0 ]
 then
	echo "Appending to /etc/magic...."
	echo "0	string		From		mail folder" >> /etc/magic
	echo "0	short		0436		vfont definition" >> /etc/magic
	echo "0	long		$RASMAGIC	raster file" >> /etc/magic
	echo "3	string		pgscriptver	SunWrite document" >> /etc/magic
	echo "10	string		sundraw		SunDraw document" >> /etc/magic
fi

echo "Creating /etc/filetype rules database..."
echo "8768769" > /etc/filetype
echo "binder,,,$IDIR/bind.icon" >> /etc/filetype
echo "calctool,,,$IDIR/calctool.icon" >> /etc/filetype
echo "clock,,,$IDIR/fm_clock.icon" >> /etc/filetype
echo "cmdtool,,,$IDIR/fm_cmdtool.icon" >> /etc/filetype
echo "dbxtool,,,$IDIR/fm_dbxtool.icon" >> /etc/filetype
echo "filemgr,,,$IDIR/filemgr.icon" >> /etc/filetype
echo "fontedit,,,$IDIR/fm_fontedit.icon" >> /etc/filetype
echo "iconedit,,,$IDIR/fm_iconedit.icon" >> /etc/filetype
echo "mailtool,,,$IDIR/fm_mailtool.icon" >> /etc/filetype
echo "maze,,,$IDIR/maze.icon" >> /etc/filetype
echo "perfmeter,,,$IDIR/perfmeter.icon" >> /etc/filetype
echo "printtool,,,$IDIR/printer.icon" >> /etc/filetype
echo "shelltool,,,$IDIR/fm_cmdtool.icon" >> /etc/filetype
echo "snapshot,,,$IDIR/snapshot.icon" >> /etc/filetype
echo "sundraw,,,$IDIR/sundraw.icon" >> /etc/filetype
echo "sunpaint,,,$IDIR/sunpaint.icon" >> /etc/filetype
echo "sunwrite,,,$IDIR/sunwrite.icon" >> /etc/filetype
echo "tapetool,,,$IDIR/tapetool.icon" >> /etc/filetype
echo "textedit,,,$IDIR/fm_textedit.icon" >> /etc/filetype
echo "traffic,,,$IDIR/fm_traffic.icon" >> /etc/filetype
echo "xcalc,,,$IDIR/calctool.icon" >> /etc/filetype
echo "xpuzzle,,,$IDIR/puzzle.icon" >> /etc/filetype
echo "xsol,,,$IDIR/xsol.icon" >> /etc/filetype
echo "*.icon,,iconedit -Wb 255 225 225,$IDIR/icondoc.icon,255 225 255" >> /etc/filetype
echo "*.wk?,,dos -c 123,$IDIR/spreadsheet.icon,255 225 255" >> /etc/filetype
echo "core*,,,$IDIR/coredoc.icon,255 0 0" >> /etc/filetype
echo "*.exe,,dos -c,$IDIR/dos.icon,206 192 255" >> /etc/filetype
echo "*.Z,,uncompress,$IDIR/compress.icon,255 0 0" >> /etc/filetype
echo ",Frame Maker document,,$IDIR/framedoc.icon,255 255 194" >> /etc/filetype
echo ",mail folder,,$IDIR/maildoc.icon,0 255 204" >> /etc/filetype
echo ",raster file,sunpaint,$IDIR/paintdoc.icon,255 255 160" >> /etc/filetype
echo ",SunWrite document,sunwrite,$IDIR/writedoc.icon,255 198 192" >> /etc/filetype
echo ",vfont definition,/usr/bin/fontedit,$IDIR/fontdoc.icon,206 192 255" >> /etc/filetype
echo ",SunDraw document,sundraw,$IDIR/drawdoc.icon,192 255 255" >> /etc/filetype

echo
echo "File Manager set up complete."





