From de46a6c4a4eb39196a2f76cb9cedd6e247ac828b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20M=E4kinen?= Date: Tue, 7 May 2013 16:52:51 +0300 Subject: [PATCH] flexlm: Added support for running lmgrd servers. --- flexlm/Makefile | 19 +++++- flexlm/files/lmgrd.init | 82 ++++++++++++++++++++++++ flexlm/manifests/init.pp | 132 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 230 insertions(+), 3 deletions(-) create mode 100644 flexlm/files/lmgrd.init diff --git a/flexlm/Makefile b/flexlm/Makefile index 1eebe61..3ce3d3d 100644 --- a/flexlm/Makefile +++ b/flexlm/Makefile @@ -4,8 +4,10 @@ VERSION = 11.11.1.1 BASEURL = http://www.globes.com/products/utilities/v$(VERSION)/ all: manifest download -download: $(PACKAGES)/lmutil-${VERSION}.i386.Linux \ - $(PACKAGES)/lmutil-${VERSION}.x86_64.Linux +download: $(PACKAGES)/lmutil-$(VERSION).i386.Linux \ + $(PACKAGES)/lmgrd-$(VERSION).i386.Linux \ + $(PACKAGES)/lmutil-$(VERSION).x86_64.Linux \ + $(PACKAGES)/lmgrd-$(VERSION).x86_64.Linux manifest: $(MANIFESTS)/flexlm.pp $(PACKAGES)/lmutil-$(VERSION).i386.Linux: @@ -13,11 +15,22 @@ $(PACKAGES)/lmutil-$(VERSION).i386.Linux: test -f $@ || curl $(BASEURL)/lmutil-i86_lsb-$(VERSION).tar.gz | \ zcat | tar xf - -O > $@ +$(PACKAGES)/lmgrd-$(VERSION).i386.Linux: + @umask 022 ; echo $@; \ + test -f $@ || curl $(BASEURL)/lmgrd-i86_lsb-$(VERSION).tar.gz | \ + zcat | tar xf - -O > $@ + $(PACKAGES)/lmutil-$(VERSION).x86_64.Linux: @umask 022 ; echo $@; \ test -f $@ || curl $(BASEURL)/lmutil-x64_lsb-$(VERSION).tar.gz | \ zcat | tar xf - -O > $@ +$(PACKAGES)/lmgrd-$(VERSION).x86_64.Linux: + @umask 022 ; echo $@; \ + test -f $@ || curl $(BASEURL)/lmgrd-x64_lsb-$(VERSION).tar.gz | \ + zcat | tar xf - -O > $@ + $(MANIFESTS)/flexlm.pp: download @umask 022 ; echo $@; \ - echo '$$lmutil_package_latest = "$(VERSION)"' > $@ + echo '$$lmutil_package_latest = "$(VERSION)"' > $@ ; \ + echo '$$lmgrd_package_latest = "$(VERSION)"' >> $@ diff --git a/flexlm/files/lmgrd.init b/flexlm/files/lmgrd.init new file mode 100644 index 0000000..a177550 --- /dev/null +++ b/flexlm/files/lmgrd.init @@ -0,0 +1,82 @@ +#!/bin/bash +# +# lmgrd Starts lmgrd license daemon. +# +# chkconfig: - 99 01 +# description: Flexnet license manager daemon. + +# Source function library. +. /etc/init.d/functions + +PATH=${PATH}:/usr/local/lib/lmgrd + +# Determine license id +licid=`basename $0 | cut -d '.' -f 2-` +if [ -z ${licid} ]; then + licid=`hostname -s` +fi + +logdir="/var/log/lmgrd/${licid}" +logfile="${logdir}/lmgrd.${licid}.`date '+%Y%m%d-%H%M%S'`.log" +licfile="/etc/lmgrd/license.${licid}" +lockfile="/var/lock/lmgrd.${licid}" + +start() { + touch ${logfile} + chown licensed:root ${logfile} + chmod 640 ${logfile} + echo -n $"Starting lmgrd (${licid}): " + su - licensed -s /bin/sh -c "lmgrd -l ${logfile} -x lmdown -2 -p -c ${licfile}" + RETVAL=$? + if [ ${RETVAL} -eq 0 ]; then + lmstat -c ${licfile} > /dev/null 2>&1 + RETVAL=$? + fi + if [ ${RETVAL} -eq 0 ]; then + echo_success + touch ${lockfile} + else + echo_failure + fi + echo + return ${RETVAL} +} + +stop() { + echo -n $"Shutting down lmgrd (${licid}): " + pkill -u licensed -f "${logdir}/lmgrd.${licid}" + RETVAL=$? + if [ $RETVAL -eq 0 ]; then + echo_success + rm -f $lockfile + else + echo_failure + fi + echo + return ${RETVAL} +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + lmstat -c ${licfile} + ;; + restart) + stop + start + ;; + reload) + lmreread -c ${licfile} + ;; + *) + echo $"Usage: $0 {start|stop|restart|condrestart|reload|status}" + exit 2 + ;; +esac + +exit $? diff --git a/flexlm/manifests/init.pp b/flexlm/manifests/init.pp index a8b6282..814a19d 100644 --- a/flexlm/manifests/init.pp +++ b/flexlm/manifests/init.pp @@ -34,3 +34,135 @@ class flexlm::client { } } + + +# Install common files from FlexLM license server +# +class flexlm::lmgrd::common { + + require flexlm::client + + include user::system + realize([ User["licensed"], Group["licensed"], ]) + + file { "/usr/local/sbin/lmgrd": + ensure => present, + source => "puppet:///files/packages/lmgrd-${lmgrd_package_latest}.${::architecture}.${::kernel}", + mode => "0755", + owner => "root", + group => "root", + } + + file { [ "/etc/lmgrd", "/usr/local/lib/lmgrd", "/var/log/lmgrd", ]: + ensure => directory, + mode => "0755", + owner => "root", + group => "root", + } + +} + + +# Install new instance of lmgrd +# +# === Parameters +# +# $name: +# Instance name. +# $license: +# Source path for license file. +# $vendors: +# Array containing vendor daemon names to be installed. They are +# installed under /usr/local/lib/lmgrd from: +# puppet:///files/lmgrd/$name +# +# === Sample usage +# +# flexlm::lmgrd { "matlab": +# license => "puppet:///files/lmgrd/license.matlab", +# vendors => [ "lm_matlab", ], +# } +# +define flexlm::lmgrd($license, $vendors=[]) { + + require flexlm::lmgrd::common + + if ! ($::operatingsystem in ["CentOS","RedHat"]) { + fail("flexlm::lmgrd not supported in ${::operatingsystem}") + } + + file { "/etc/lmgrd/license.${name}": + ensure => present, + source => $license, + mode => "0644", + owner => "root", + group => "root", + notify => Service["lmgrd.${name}"], + } + + file { "/var/log/lmgrd/${name}": + ensure => directory, + mode => "0750", + owner => "root", + group => "licensed", + before => Service["lmgrd.${name}"], + } + + flexlm::vendor { $vendors: } + + file { "/etc/init.d/lmgrd.${name}": + ensure => present, + source => "puppet:///modules/flexlm/lmgrd.init", + mode => "0755", + owner => "root", + group => "root", + notify => Exec["chkconfig --add lmgrd.${name}"], + } + exec { "chkconfig --add lmgrd.${name}": + user => "root", + path => "/bin:/usr/bin:/sbin:/usr/sbin", + refreshonly => true, + before => Service["lmgrd.${name}"], + } + service { "lmgrd.${name}": + ensure => running, + enable => true, + hasstatus => true, + } + +} + + +# Install vendor daemon binary +# +# === Parameters: +# +# $name: +# Vendor daemon name. +# $source: +# Source path where daemon is found. Defaults to +# puppet:///files/lmgrd/${name}. +# +# === Sample usage: +# +# flexlm::lmgrd::vendor { "lm_matlab": +# source => "puppet:///files/lmgrd/lm_matlab", +# } +# +define flexlm::lmgrd::vendor($source=undef) { + + if !$source { + $source = "puppet:///files/lmgrd/${name}" + } + + file { "/usr/local/lib/lmgrd/${name}": + ensure => present, + source => $source, + mode => "0755", + owner => "root", + group => "root", + require => File["/usr/local/lib/lmgrd"], + } + +} +