#! /bin/sh
set -e
set -x
echo installing to: $1
if [ -z "$1" ] ; then
  echo >&2 "need directory: e.g., 020901"
else

if [  -r "/afs/sipb.mit.edu/project/mozilla/.build.sgi_65/installations/$1" ] ; then
  echo >&2 "already exists /afs/sipb.mit.edu/project/mozilla/.build.sgi_65/installations/$1"
else
if [ -r "$HOME/.mozilla" ] ; then
  echo >&2 "remove .mozilla"
else
mkdir /afs/sipb.mit.edu/project/mozilla/.build.sgi_65/installations/$1
cd /afs/sipb.mit.edu/project/mozilla/.build.sgi_65/installations/$1

pwd

time gtar xzf /tmp/do-install/mozilla-mips-sgi-irix6.5.tar.gz
cd mozilla

#patch -p0 <  /mit/mozilla/random-stuff/usr_athena_lib.patch
patch -p0 <  /mit/mozilla/random-stuff/disk_cache.patch
patch -p0 <  /afs/sipb.mit.edu/project/mozilla/random-stuff/smoothScroll.patch

patch -p0 <  /mit/mozilla/random-stuff/enable_tabbed_browsing.patch
#patch -p0 < /mit/mozilla/random-stuff/acrobat_launch_moz_acro.patch 
patch -p0 < /mit/mozilla/random-stuff/mailcap_and_mime_types.patch  
cd ..
mkdir bin
cd bin
perl /afs/sipb.mit.edu/project/mozilla/random-stuff/create_starter_script.pl $1 sgi_65 > mozilla-beta
#perl /afs/sipb.mit.edu/project/mozilla/random-stuff/create_starter_script.pl $1 sgi_65 /afs/sipb.mit.edu/project/mozilla/MESSAGES/announcement-of-mozbeta > mozilla-with-announcement
chmod ugo+rx mozilla-beta
#chmod ugo+rx mozilla-with-announcement
echo Now running
./mozilla-beta file:///mit/mozilla/random-stuff/start_file.html

cd ../mozilla/plugins
#ln -s /afs/athena.mit.edu/software/java/current/jre/plugin/@sys/ns600/libjavaplugin_oji.so 
#gln -s /var/athena/infoagents/arch/sgi_65/MIT-only/netscape/plugins/ShockwaveFlash.class
#gln -s /var/athena/infoagents/arch/sgi_65/MIT-only/netscape/plugins/libflashplayer.so
#gln -s /var/athena/infoagents/arch/sgi_65/te/PlugIn/nptchexp.so
#gln -s /var/athena/infoagents/arch/sgi_65/MIT-only/netscape/plugins/raclass.zip
#gln -s /var/athena/infoagents/arch/sgi_65/MIT-only/netscape/plugins/rpnp.so
ls -l
cd ../../bin
#no need to run again if no plugins
#./mozilla file:///mit/mozilla/random-stuff/start_file.html
cd ../..
gchmod -R go+rX $1
#gchmod -R ugo-w sgi_65
fi
fi
fi
