Sign inSign up

kutena/sls_saltd

By kutena

Updated over 1 year ago

FlexLM / Saltd Siemens License Server Saltd for SolidEdge 2024+

Image
Security
Web servers
0

226

kutena/sls_saltd repository overview

Run FlexLM / Saltd Siemens License Server in Docker container

Applicable to the Siemens license server Saltd to provide floating licenses for SolidEdge

Version history

v4.2.0.0: SiemensLicenseServer_v4.2.0.0 for SolidEdge 2024 and later (01/27/2025)

v2.4.0.0: SiemensLicenseServer_v2.4.0.0 for SolidEdge 2024 (02/03/2024)

Usage

Lets assume your server's hostname is "licserv", the MAC address of your network adapter is "10:20:30:40:50" and your license file is "SELicenseFileV224-SALTD.dat"

Edit license file
SERVER licserv COMPOSITE=746833B71127 29000
VENDOR saltd port=29001
Start from command line
docker pull kutena/sls_saltd:v4.2.0.0
docker run -d --name se2025_sls  -p 29001:29001 -p 29000:29000 -e "HOSTNAME=licserv" -e "MACADDR=10:20:30:40:50" --mount type=bind,source="$(pwd)"/SELicenseFileV224-SALTD.dat,target=/opt/Siemens/LicenseServer/ActiveLicenses/ugslmd.lic --privileged kutena/sls_saltd:v4.2.0.0
Alternatively: Run docker container on Synology NAS

Login to your NAS and start Docker UI. Upload your image to NAS e.g. using file station. In the Docker UI choose "Import image from file". Alternatively register from Docker Hub.

Launch image sls_saltd and set the following preferences:

General settings:

-> Execute container using high privilege

Advanced Settings:

-> Enable auto-restart

Volume:

-> Add file

-> Mount path: /opt/Siemens/LicenseServer/ActiveLicenses/ugslmd.lic

-> File/Folder: [Path to your license file]

Port Settings:

-> Local Port: 29000, Container Port: 29000

-> Local Port: 29001, Container Port: 29001

Environment:

-> HOSTNAME: [hostname of your license server]

-> MACADDR: [MAC address used to obtain the composite host ID]

Hit Apply and your are done!

Build docker image

In case the provided image does not work for several reasons you can build it according to the following instructions.

Prerequisites
  1. Valid license file
  2. FlexLM Linux installer SiemensLicenseServer_v4.2.0.0_Lnx64_x86-64.bin
Create a directory for the new Docker image and cd into it:
mkdir sls_saltd
cd sls_saltd
Extract installer:
chmod +x ./SiemensLicenseServer_v4.2.0.0_Lnx64_x86-64.bin
./SiemensLicenseServer_v4.2.0.0_Lnx64_x86-64.bin -text -unzip ./unzip
Create docker file:
cat > Dockerfile <<EOF 
FROM opensuse/leap:15

# expose ports
EXPOSE 29000
EXPOSE 29001

# hostname and mac will be set during runtime
ENV HOSTNAME=licserv
ENV MACADDR=10:20:30:40:50:60

COPY ./unzip/ /opt/Siemens/LicenseServer/
COPY ./setcid /opt/Siemens/LicenseServer/setcid
COPY ./init /usr/local/sbin/init
COPY ./sls_saltd /etc/init.d/sls_saltd

RUN zypper install -y insserv vim iproute2 iputils libgthread-2_0-0

RUN chmod +x /usr/local/sbin/init;\
    chmod +x /etc/init.d/sls_saltd;\
    chmod +x /opt/Siemens/LicenseServer/setcid;\
    groupadd -r -g 1001 saltd;\
    useradd -r  -g saltd -u 1001 saltd -s /usr/sbin/nologin;\
    mkdir -p /usr/tmp/.flexlm;\
    chown -R saltd:saltd /usr/tmp/.flexlm;\
    chown -R saltd:saltd /opt/Siemens;\
    chown saltd:saltd /etc/init.d/sls_saltd;\
    chkconfig sls_saltd on
 
CMD ["/usr/local/sbin/init"]
EOF
Create init script:
cat > init <<EOF 
#!/bin/bash

# set hostname & mac addr
/opt/Siemens/LicenseServer/setcid

# set owner of mounted license 
if [ -d "/opt/Siemens/LicenseServer/ActiveLicenses" ]; then
  chown -R saltd:saltd /opt/Siemens/LicenseServer/ActiveLicenses
fi

# cleanup lock files
if [ -f "/var/tmp/locksaltd" ]; then
  echo "Removing lock files"    
  rm /var/tmp/lock*
fi


# start license server
service sls_saltd start
tail -f /opt/Siemens/LicenseServer/saltd.log
EOF
Create helper script:
cat > setcid <<EOF 
#!/bin/bash

# set hostname
old_hostname=$(uname -n)
new_hostname=$(env |grep -i hostname | cut -d '=' -f 2)
if [ ! -z $new_hostname ]; then 
    echo $new_hostname > /proc/sys/kernel/hostname
    echo $new_hostname > /etc/hostname
    cp /etc/hosts /etc/hosts.tmp
    sed -i "s/$old_hostname/$new_hostname/" /etc/hosts.tmp
    cat /etc/hosts.tmp > /etc/hosts
    rm /etc/hosts.tmp
fi
echo "Hostname set to "$(uname -n)

# set mac address
macaddr=$(env |grep -i macaddr | cut -d '=' -f 2)
if [ ! -z "$(echo $macaddr | grep -E '^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$')" ]; then
    ip link set dev eth0 down
    ip link set dev eth0 address $macaddr
    ip link set dev eth0 up
fi
echo "MAC addr set to "$(cat /sys/class/net/eth0/address)
EOF
Create service for sysVinit:
cat > sls_saltd <<EOF 
#!/bin/sh
#
# Copyright (c) 2024-2024   Siemens PLM Software Inc. All rights reserved
# *************************************************************************
# Title:    sls_saltd
# Purpose:  Siemens License Server run control (rc) script.
# *************************************************************************
#
# /etc/init.d/sls_saltd
#
#
#
### BEGIN INIT INFO
# Provides: sls_saltd
# Required-Start: $ALL
# Required-Stop: 
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: Start the lmgrd and saltd daemon
### END INIT INFO

#Version of Siemens PLM Server
LICENSE_VER=2.4.0.0

# Installation directory of Siemens PLM License Server files.
LICENSE_DIR="/opt/Siemens/LicenseServer"

# License file supplied by Siemens PLM Software.
LICENSE_FILE="$LICENSE_DIR/ActiveLicenses/ugslmd.lic"

# Log file for startup and lmgrd messages.
LOG_FILE="$LICENSE_DIR/saltd.log"

# License User
LICENSE_USER="saltd"

#Vendor Daemon Name
VENDOR_DAEMON=saltd

#License Manager Daemon
LICENSE_DAEMON=lmgrd

#Scriptname
SCRIPTNAME=`basename $0`

PATH=/sbin:/usr/sbin:/usr/bin:/bin:"$LICENSE_DIR":$PATH ; export PATH

RESTARTED=0

# Unset any aliases to preclude any colisions.
unalias -a >/dev/null 2>&-


init() {
    # First, verify user is root 
    [ `id | awk -F\= '{print $2}'|awk -F\( '{print $1}'` = "0" ] || {
        echo "ERROR: You need to be a user with root privilege to run $SCRIPTNAME"
        exit 1 
    } # End of root check.

    # Do a quick check to make sure LICENSE_DIR is still there at runtime. It
    # may have been deleted after the install, so just exit as a no-op.
    [ -d "${LICENSE_DIR}" ] || {
        echo "ERROR: cannot find $LICENSE_DIR"
        exit 1
    }

    # Check whether we can find the license file.  Won't run without it.
    if [ ! -f "${LICENSE_FILE}" ] || [ ! -r "${LICENSE_FILE}" ]  # Check for the file.
    then
        echo "ERROR: cannot find $LICENSE_FILE"
        exit 1
    fi

    if [ -f "$LOG_FILE" ] && [ ! -w "$LOG_FILE" ] ;
    then
        echo "ERROR: You do not have enough permission to perform the requested operation"
        exit 1
    fi

    cd "$LICENSE_DIR"
}

#Returns pid and ppid for a process
#Takes process name as argument
get_pid_and_ppid() {

    set -- `ps -ef | grep -v grep | grep "$1"`
    echo $2 $3

}

#checks if a process is running or not
is_process_running() {

    ps -ef | grep -v grep | grep "$1" > /dev/null

}

#print serivce error if any
print_service_status() {
    exit_code=$1
    [ $exit_code -ne 0 ] && {
       echo "ERROR: Could not $2 service $3"
       exit $exit_code
    }
}

print_status() {

    is_process_running "$LICENSE_DIR/$LICENSE_DAEMON" && {
        echo "Checking for service $LICENSE_DAEMON  : RUNNING"
    } || {
        echo "Checking for service $LICENSE_DAEMON  : STOPPED"
    }

    is_process_running " $VENDOR_DAEMON " && {
        echo "Checking for service $VENDOR_DAEMON : RUNNING"
    } || {
        echo "Checking for service $VENDOR_DAEMON : STOPPED"
    }
}

start_daemon() {

    #check if vendor daemon is already running
    is_process_running " $VENDOR_DAEMON " && {
        echo "Service saltd is already running"
        exit 0
    }

    echo "Starting service saltd. Please wait..."

    #If restarted wait for additional time
    [ $RESTARTED -eq 1 ] && {
        RESTARTED=0
        sleep 10
    }

    #"$LICENSE_DIR"/lmgrd -c "$LICENSE_FILE"  >>  "$LOG_FILE" 2>&1
    su "$LICENSE_USER" -s /bin/bash -c "$LICENSE_DIR/$LICENSE_DAEMON -z -reuseaddr -c $LICENSE_FILE -l $LOG_FILE -local &"


    print_service_status $? "start" "$VENDOR_DAEMON"


    #Wait for vendor daemon to be up
    sleep 5

    is_process_running "$LICENSE_DIR/$LICENSE_DAEMON" || {
        echo "ERROR: License manager daemon could not be started, please refer to $LOG_FILE for more information"
        exit 1
    }

    is_process_running " $VENDOR_DAEMON " || {
        echo "NOTE: Please wait for a few minutes to fully initialize the vendor daemon (saltd)"
        exit 0
    }
    echo "Vendor deamon successfully started."
}

stop_daemon() {
    is_process_running " $VENDOR_DAEMON " || is_process_running "$LICENSE_DIR/$LICENSE_DAEMON" || {
        echo "Service saltd is already stopped"
        exit 0
    }

    echo "Stopping service saltd. Please wait..."
    $LICENSE_DIR/lmutil lmdown -q -force -c $LICENSE_FILE

    is_process_running " $VENDOR_DAEMON " || is_process_running "$LICENSE_DIR/$LICENSE_DAEMON" && echo "Could not stop saltd" || echo "Service saltd was stopped"

}


case "$1" in
    start)
        init
        start_daemon
        exit $?
        ;;
    stop)
        init
        stop_daemon
        exit $?
        ;;
    restart)
        init
        is_process_running " $VENDOR_DAEMON " || {
            start_daemon
            exit 0
        }
        RESTARTED=1
        stop_daemon
        start_daemon
        exit $?
        ;;
    status)
        print_status
        exit $?
        ;;
    *)
        echo "Usage: $SCRIPTNAME {start|stop|restart|status}"
        exit 1
        ;;
esac
EOF
Build image:
docker build -t sls_saltd:v4.2.0.0 -f Dockerfile .
Run & test:
docker run -d --name se2025_sls  -p 29001:29001 -p 29000:29000 -e "HOSTNAME=licserv" -e "MACADDR=10:20:30:40:50" --mount type=bind,source="$(pwd)"/SELicenseFileV224-SALTD.dat,target=/opt/Siemens/LicenseServer/ActiveLicenses/ugslmd.lic --privileged sls_saltd:v4.2.0.0
Attach to the running container:
docker container exec -it se2025_sls /bin/bash
Check that lmgrd and saltd is running:
ps -ef
service sls_saltd status
Output from log file:
cat /opt/Siemens/LicenseServer/saltd.log
Check composite host ID:
/opt/Siemens/LicenseServer/ugslmd_utils/getcid
Composite HostID Value(s):

  Multiple composite hostids (CIDs) indicate you have multiple network adapters.
  You should select the first CID or the most appropriate CID based on the network
  adapter which is currently active. The Siemens PLM Software Licensing CIDs 
  for this host "licserv" are:

  COMPOSITE=746833B71127 - eth0
                         (MAC : 102030405060)


Press the ENTER key to continue...
Check licenses issued:
/opt/Siemens/LicenseServer/lmutil lmstat -a -c /opt/Siemens/LicenseServer/ActiveLicenses/ugslmd.lic
Close shell and continue on host:
exit
Check connection from host to container:
telnet 172.17.0.2 29000
Trying 172.17.0.2...
Connected to 172.17.0.2.
Escape character is '^]'.

Connection closed by foreign host.

and:

$> telnet 172.17.0.2 29001
Trying 172.17.0.2...
Connected to 172.17.0.2.
Escape character is '^]'.




Connection closed by foreign host.

Tag summary

Content type

Image

Digest

sha256:fd0bb5ef8

Size

322.3 MB

Last updated

over 1 year ago

docker pull kutena/sls_saltd:v4.2.0.0