May 282010

Here is a start-up script for a flexlm license based software.

Using the start option the script will call itself only to start the daemon as a limited right user called flexlm, it will (switch users) with su. While the startsu will simply start it as the actual current user.

The things you might need to change in that script are:

  • PATH=   # you local path
  • APPS=    # the name of your software
  • LIC=        # path to your license_file.dat  (eys you can name it whatever you want to)
  • PORT=    # tcp port number you want
  • USER=    # user other than root who should start the service as
  • LOG=       # where ever you want to put your log file

So this is the start-up script I am using for many license server. I simply adjust some tweak.

#!/bin/sh
# Copyright (c) Rejean Lepage.
#
#ident  “@(#)daemon, server 3.5  2010/05/27 RL”

PATH=/usr/bin:/usr/sbin:/usr/sfw/bin:/usr/local/bin
LD_LIBRARY_PATH=/usr/lib:/usr/openwin/lib:/usr/ccs/lib:/usr/dt/lib:/usr/local/lib

APPS=ANY-SOFT
LIC=/usr/local/flexlm/dat/SOFT_licenses.dat
LOG=/tmp/${APPS}.$$.log
PORT=52800
SRV_PATH=/usr/local/flexlm/bin
SRV=”${SRV_PATH}/lmgrd -2 -p ”
USER=flexlm

#
# Start/stop $APPS server on port $PORT
#

case “$1” in

‘start’)

if [ -f $LIC ] ; then
ulimit -n 1024
ulimit -H -n 1024

# start me with startsu option
/usr/bin/su $USER -c “$0 startsu”
else
echo “** File not found $LIC for $APPS on port $PORT **”
fi
;;

‘startsu’)

if [ “$USER” = “root” ] ; then
echo “Do not run flexlm as root.”
fi

if [ -f $LIC ] ; then
ulimit -n 1024
ulimit -H -n 1024

# Those 3 LD vars should allows to run Solaris 10 daemon on Solaris 9
LD_NOVERSION=1
LD_NOVERSION_32=1
LD_NOVERSION_64=1
export LD_NOVERSION LD_NOVERSION_32 LD_NOVERSION_64

echo “Staring server $APPS on port $PORT with process number $$ log = $LOG
umask 022
$SRV -c $LIC -local -l $LOG

else
echo “** File not found $LIC for $APPS on port $PORT **”
fi
;;

‘stop’)

echo Arret du serveur $APPS
echo y | ${SRV_PATH}/lmdown -c $LIC
;;

‘status’)

echo Etat de $APPS deamon
${SRV_PATH}/lmstat -c $LIC
;;

‘fullstatus’)

echo Etat de $APPS deamon
${SRV_PATH}/lmstat -a -c $LIC
;;

‘reread’)

echo Lecture des licenses de $APPS deamon
${SRV_PATH}/lmreread -c $LIC
;;

env)

echo PATH=$PATH
echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH
;;

*)

echo “Usage: /etc/init.d/$0 { start | stop | status | reread }”
;;

esac

Hopefully this might be useful, it’s a good wrapper I do use it for all license server I got.

Finally I can point out the latest version flexlm (lmgrd, lmutil) is 11.8 and is available for download on the Flexera site.

Also here is two small script to create or remove soft links for each flexlm sub commands.

#!/bin/sh
#
# Create links to make use of the FlexLM tools easier.
#
PATH=/usr/ucb:/usr/bin:/bin; export PATH

if [ -f lmhostid ]; then
echo “The links appear to exist already!”
exit 1
fi

ln -s lmutil lmhostid
ln -s lmutil lmver
ln -s lmutil lmcksum
ln -s lmutil lmdown
ln -s lmutil lmremove
ln -s lmutil lmreread
ln -s lmutil lmswitchr
ln -s lmutil lmstat
ln -s lmutil lmdiag
ln -s lmutil lminstall
ln -s lmutil lmborrow
ln -s lmutil lmnewlog
ln -s lmutil lmpath
ln -s lmutil lmswitch

echo “Links now made”

and to remove links…

#!/bin/sh
#
# Remove links
#

PATH=/usr/ucb:/usr/bin:/bin; export PATH

if [ ! -f lmhostid ]; then
echo “The links do not exist!”
exit 1
fi

rm -f lmhostid
rm -f lmver
rm -f lmcksum
rm -f lmdown
rm -f lmremove
rm -f lmreread
rm -f lmswitchr
rm -f lmstat
rm -f lmdiag
rm -f lminstall
rm -f lmborrow
rm -f lmnewlog
rm -f lmpath
rm -f lmswitch

echo “Links removed”

Rejean.

No Responses to “Unix based flexlm startup script”

  1. […] in following the QC Embedded Systems job market ? Unix based flexlm startup script May […]

Leave a Reply

(required)

(required)

Return to Panoramic Solution