#!/bin/sh
# Copyright 2008 The Foundry
#
# chkconfig: 345 99 06
# description: Foundry FLEXlm Server

FLEX_DIR=/usr/local/foundry/FLEXlm

#NOTE : The Foundry Server Utility uses this element to locate lmutil, 
#if you alter this ensure it still points to the FFT tools dir 
TOOL_DIR=/usr/local/foundry/FLEXlmTools5.0

BIN_DIR=${TOOL_DIR}/bin
LIC_DIR=${FLEX_DIR}
LOG_DIR=${FLEX_DIR}/log

case "$1" in
'start')
  echo Starting lmgrd
  ${BIN_DIR}/lmgrd.foundry -c ${LIC_DIR} -l ${LOG_DIR}/foundry.log -local 2>&1 >> ${LOG_DIR}/boot.log
  ${BIN_DIR}/lmutil lmdiag -n -c ${LIC_DIR}/ 2>&1 >> ${LOG_DIR}/boot.log
  ;;

'stop')
  echo Stopping lmgrd
  ${BIN_DIR}/lmutil lmdown -q -c ${LIC_DIR} 2>&1 >> ${LOG_DIR}/boot.log << End_Of_Session
  1
End_Of_Session
  
  ;;

'reload')
  echo Reloading licenses
  ${BIN_DIR}/lmutil lmreread -c ${LIC_DIR} -vendor foundry -all 2>&1 >> ${LOG_DIR}/boot.log
  ;;

'restart')
  $0 stop
  $0 start
  ;;

*)
   echo "usage: $0 {start|stop|reload|restart}"
   ;;
esac
