#! /bin/sh
#-----------------------------------------------------------------------
#;  Copyright (C) 1995
#;  Associated Universities, Inc. Washington DC, USA.
#;
#;  This program is free software; you can redistribute it and/or
#;  modify it under the terms of the GNU General Public License as
#;  published by the Free Software Foundation; either version 2 of
#;  the License, or (at your option) any later version.
#;
#;  This program is distributed in the hope that it will be useful,
#;  but WITHOUT ANY WARRANTY; without even the implied warranty of
#;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#;  GNU General Public License for more details.
#;
#;  You should have received a copy of the GNU General Public
#;  License along with this program; if not, write to the Free
#;  Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
#;  MA 02139, USA.
#;
#;  Correspondence concerning AIPS should be addressed as follows:
#;         Internet email: aipsmail@nrao.edu.
#;         Postal address: AIPS Project Office
#;                         National Radio Astronomy Observatory
#;                         520 Edgemont Road
#;                         Charlottesville, VA 22903-2475 USA
#-----------------------------------------------------------------------
#------------------------------------------------------------------------------
# Usage: SSSERVERS
#------------------------------------------------------------------------------
#
# Shell script to start the AIPS server processes on a SUN workstation.  It
# will normally be invoked via /AIPS/START_SERVERS which is responsible for
# defining essential AIPS logicals (including TVDEV, etc) via HOSTS.CSH,
# TVDEVS.CSH, and AIPSPATH.CSH.
#
# Starts the SSS screen server, TEKSERVER, and TAAC utilities.
#
# Original: MRC 90.04.11
# Modified: MRC 91.05.15
# Modified: PPM 91.12.10 NRAO/CV version
#------------------------------------------------------------------------------
#                                        Start sunview if necessary.
ps acx | grep -s sunview
if [ "$?" = 1 ] ; then
  sunview -b 79 0 0 -f 255 255 159 > /dev/null &
  exit
fi

#                                       Start the TV servers.
if [ "$TVDEV" != TVDEV00 ] ; then
#                                       Start SUN Screen Server if necessary.
   ps acx | grep -s SSS
   if [ "$?" = 1 ] ; then
#                                       What does this stuff do????? @@@
      WINDOW_PARENT=/dev/win0
      export WINDOW_PARENT
      WMGR_ENV_PLACEHOLDER=/dev/win1
      export WMGR_ENV_PLACEHOLDER
#                                       Start up SSS iconic, specify location
#                                       and size, and iconic location, choose
#                                       bg/fg colors (black, light brown)
      $LOAD/SSS -Wi -Wp 653 70 -Ws 530 543 -WP 572 0 \
                -Wb 0 0 0 -Wf 223 191 127 \
            -Wl "SUN Screen Server" > /dev/null &
   fi
fi

#                                       Start TEKSERVER if necessary.
if [ "$TKDEV" != "TKDEV00" ] ; then
   ps acx | grep -s tektool
   if [ "$?" = 1 ] ; then
#                                       tektool says Device busy opened iconic
      WINDOW_PARENT=/dev/win0
      export WINDOW_PARENT
      WMGR_ENV_PLACEHOLDER=/dev/win1
      export WMGR_ENV_PLACEHOLDER
#                                       Check version of operating system
      case `uname -r` in
        4.1.1)
#          SunOS 4.1.1
           /usr/etc/setsid -b tektool -WP 507 0 -Wb 0 0 0 -Wf 159 223 255 \
              -Wi -r TEKSERVER.EXE 2> /dev/null &
           ;;
        4.1)
#          SunOS 4.1
           /usr/etc/setsid tektool -WP 507 0 -Wb 0 0 0 -Wf 159 223 255 \
              -Wi -r TEKSERVER.EXE 2> /dev/null &
           ;;
        4.0*)
#          SunOS 4.0 and revisions.
           /usr/old/tektool -WP 507 0 -Wb 0 0 0 -Wf 159 223 255 \
              -Wi -r TEKSERVER.EXE 2> /dev/null &
           ;;
        3.*)
#          SunOS 3.x
           tektool -WP 507 0 -Wb 0 0 0 -Wf 159 223 255 \
              -Wi -r TEKSERVER.EXE 2> /dev/null &
           ;;
      esac
   fi
fi

#                                       Start TAAC utilities.  ATNF only.
#                                       (The TAAC is an obsolete Sun graphics
#                                       accellerator board for visualization)
if [ "$TAAC1" != "" -a -d "$TAAC1" ] ; then
   ps acx | grep -s tatool
   if [ "$?" = 1 ] ; then
      WINDOW_PARENT=/dev/win0; export WINDOW_PARENT
      WMGR_ENV_PLACEHOLDER=/dev/win1; export WMGR_ENV_PLACEHOLDER
      $TAAC1/bin/tatool -Wp 0 0 -WP 458 0 -Wi -t 2> /dev/null &
      $TAAC1/demo/bin/tademo -WP 393 0 -Wi 2> /dev/null &
   fi
fi
