#!/bin/sh -f
# This is TAPE version

unknown () {
    echo "This system $unamestr is not known to me."
    echo "Please report this problem to Hangul & Computer Co. Ltd."
    exit 1
}

binname=install
runargs=

run () {
    binfile="./etc/$binname$binext"
    if [ ! -x $binfile ] ; then
	echo "$0: binary file for your OS, '$binfile' does not exist."
	exit 1
    fi

    if [ $# -eq 1 ]; then
      case $1 in
      *license)
    	  exec $binfile -tape $runargs;;
      *tape)
    	  exec $binfile -tape $runargs;;
      *cdrom)
    	  exec $binfile -cdrom $runargs;;
      esac
    else
      if [ -f ./etc/install.lst ]; then
          exec $binfile -cdrom $runargs
      else
          exec $binfile -tape $runargs
      fi
    fi
}

#
# for each platform
#
sunos4x () {
    binext="_sunos"
    run $@
}

solaris () {
    binext="_sunos"
    run $@
}

solarisx86 () {
    binext="_solx86"
    runargs="-list etc/install_solx86.lst"
    run $@
}

linux () {
    binext="_linux"
    runargs="-list etc/install_linux.lst"
    run $@
}

sco () {
    binext="_sco"
    runargs="-list etc/install_sco.lst"
    run $@
}

hpux () {
    binext="_hp"
    run $@
}

aix () {
    binext="_ibm"
    run $@
}

osf () {
    binext="_alpha"
    run $@
}

ultrix () {
    binext="_ultrix"
    run $@
}

sgi () {
    binext="_sgi"
    run $@
}

#

sunos () {
    revision=`uname -r`
    case $revision in
        5.*) arch=`uname -p`
    	     case $arch in
		i386) solarisx86 $@ ;;
		sparc) solaris $@ ;;
                *) unknown ;;
       	     esac ;;
        4.*) sunos4x $@ ;;
        *) unknown ;;
    esac
}

unamestr=`uname -a`

case $unamestr in
    SunOS*) sunos $@ ;;
    HP-UX*) hpux $@ ;;
    AIX*) aix $@ ;;
    OSF*) osf $@ ;;
    ULTRIX*) ultrix $@ ;;
    IRIX*) sgi $@ ;;
    Linux*) linux $@ ;;
    SCO*) sco $@ ;;
    *) unknown ;;
esac
