#!/bin/sh

# =====================================================
# flexlmd: service for the FlexLM license server daemon
# =====================================================

# WARNING!: this file is to be used as a template for the actual service starting
# and stopping the FlexLM license server. It is provided as is without any warranty.

# Uncomment and edit the following lines to reflect your actual configuration
#flexlmInstallDir=/opt/globetrotter                   # Directory into which FlexLM is installed
#flexlmBinDir=$flexlmInstallDir/bin                   # Directory into which FlexLM binaries (lmgrd, lmutil) reside
#flexlmLogFile=$flexlmInstallDir/log/debug.log        # Path to the debug log for the license server
#flexlmUser=flexlm                                    # User who will actually run FlexLM license server ('root' *NOT* recommended)
                                                      # MAKE SURE THIS USER CAN EXECUTE THE FLEXLM BINARIES!
#flexlmLicenseFile=$flexlmInstallDir/etc/pragmad.lic  # Path to your license file

# No further editing needed
case "$1" in
  start)
    echo "Starting FlexLM license server"
    su $flexlmUser -c "$flexlmBinDir/lmgrd -c $flexlmLicenseFile -l $flexlmLogFile"
    echo ""
    ;;

  stop)
    echo "Stopping FlexLM license server"
    su $flexlmUser -c "$flexlmBinDir/lmutil lmdown -c $flexlmLicenseFile -q"
    echo ""
    ;;

  restart)
    $0 stop
    $0 start
    ;;

  status)
    su $flexlmUser -c "$flexlmBinDir/lmutil lmstat -c $flexlmLicenseFile -a -A"
    ;;

  *)
    echo "Usage: $0 {start|stop|restart|status}"
    exit 1
esac

exit 0
