#!/bin/sh
#
# MATLAB FLEXlm Network License Manager Daemon
#
# 	For boot-time initialization on glxn86
#
# Steps: (as root)
#
#    If the following links do not exist create them:
#
#    ln -s $MATLAB/etc/lmboot /etc/lmboot_TMW
#    ln -s $MATLAB/etc/lmdown /etc/lmdown_TMW
#    
#    Then:
#
#    cp $MATLAB/etc/rc.lm.glnx86 /etc/init.d/flexlm       (Debian)
#    cp $MATLAB/etc/rc.lm.glnx86 /etc/rc.d/init.d/flexlm  (Red Hat)
#
#    CRITICAL: replace username argument to lmboot_TMW
#	       by a real usename OTHER than root!
#
#    Look in /etc/inittab for the default runlevel. Create
#    a link in the rc directory associated with that run
#    level. For example if it is 5, then
#
#    cd /etc/rc5.d;      ln -s ../init.d/flexlm S90Flexlm (Debian)
#    cd /etc/rc.d/rc5.d; ln -s ../init.d/flexlm S90Flexlm (Red Hat)
#
case "$1" in
  start)
        if [ -f /etc/lmboot_TMW ]; then
            /etc/lmboot_TMW -u username && echo 'MATLAB_lmgrd'
        fi
        ;;
  stop)
	if [ -f /etc/lmdown_TMW ]; then
            /etc/lmdown_TMW  > /dev/null 2>&1
	fi
        ;;
  *)
	echo "Usage: $0 {start|stop}"
	exit 1
	;;
esac

exit 0
