From 140c47af352c89ef43ac745747a5bd61f63d3fe6 Mon Sep 17 00:00:00 2001
From: Aroy-Art <Aroy-Art@pm.me>
Date: Fri, 28 Feb 2025 11:04:54 +0100
Subject: [PATCH] Add: startup script to handle a Licence server

---
 startup.sh | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100755 startup.sh

diff --git a/startup.sh b/startup.sh
new file mode 100755
index 0000000..61c70c8
--- /dev/null
+++ b/startup.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+service codesysedge start
+
+printf "Vertiv EMS"
+
+# start tunnel to license server or start codemeter
+if [ ! -z ${LICENSE_SERVER} ]; then
+    echo "[codemeter] connecting to network server ${LICENSE_SERVER}."
+    echo "[codemeter] you need to forward port 22350 on the server *locally* to 22357."
+    echo "e.g.: socat tcp-listen:22357,fork,reuseaddr tcp:localhost:22350&"
+    socat tcp-listen:22350,fork,reuseaddr,bind=127.0.0.1 tcp:${LICENSE_SERVER}:22357 &
+
+    # one potential other possible solutions to use a network server
+    #/etc/init.d/codemeter start
+    #cmu --add-server ${LICENSE_SERVER}
+else
+    service codemeter start
+fi
+
+export LD_LIBRARY_PATH=/opt/codesys/lib
+/opt/codesys/bin/codesyscontrol.bin -d /etc/CODESYSControl.cfg