#!/bin/sh
#
# scmscm:       Starts the available SCMS Servers (currently CM) 
#
# description: This script will browse through the ~scmscm/setup 
#              directory and launch/stop all servers configured from this 
#              location.
#              The servers are named RUN_x_YYY where x is an order digit
#              (0 is first, then 1 etc) and YYY is the name of the server,
#              and similarly STOP_x_YYY for stopping on shutdown.


CM=`csh -c "echo ~scmscm"`
export CM

LANG=en_US
export LANG

if [ -n "${CM}" -a -d "${CM}" ]; then

  PATH="${CM}/bin:${CM}/setup:${PATH}"
  export PATH

  # See how we were called.
case $0 in
    *S*scmscm)
    echo  "Starting SCMS servers ... "
    ( cd ${CM}/setup ; \

      for run_server in RUN_* ; do \
          su scmscm -c "${run_server}" > /dev/null 2>&1 ; \
          echo  "${run_server} " ; \
      done )
    echo

    ;;

    *K*scmscm)
    echo  "Shutting down SCMS configured servers: "
        ( cd ${CM}/setup ; \

          for stop_server in STOP_* ; do \
              su scmscm -c "${stop_server}" > /dev/null 2>&1 ; \
              echo  "${stop_server} " ; \
          done )
        echo

    ;;
  esac

fi

exit 0


