From f55054fae194b611b6f49d015304ed92628f01a3 Mon Sep 17 00:00:00 2001
From: Gerhard <info@tinned-software.net>
Date: Mon, 8 Jun 2015 20:32:53 +0200
Subject: [PATCH] seperated init script from actual script due to issues caused
 by symbolic link in sysv init system

---
 ssh-tunnel-manager.sh              | 21 +--------
 ssh-tunnel-manager.sysv-initscript | 69 ++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+), 20 deletions(-)
 create mode 100644 ssh-tunnel-manager.sysv-initscript

diff --git a/ssh-tunnel-manager.sh b/ssh-tunnel-manager.sh
index e9643d5..a6ed253 100755
--- a/ssh-tunnel-manager.sh
+++ b/ssh-tunnel-manager.sh
@@ -2,7 +2,7 @@
 #
 # @author Gerhard Steinbeis (info [at] tinned-software [dot] net)
 # @copyright Copyright (c) 2013
-version=0.6.6
+version=0.6.7
 # @license http://opensource.org/licenses/GPL-3.0 GNU General Public License, version 3
 # @package net
 #
@@ -11,25 +11,6 @@ version=0.6.6
 # the ssh-tunnel-manager.conf in the same directory as the script itself.
 #
 
-# ssh-tunnel-manager	Start up the ssh-tunnel-manager manager
-#
-# chkconfig: 2345 60 20
-# description: SSH-Tunnel-Manager to manager multiple SSH connections to different servers.
-#
-# config: /etc/ssh-tunnel-manager.conf
-
-### BEGIN INIT INFO
-# Provides: ssh-tunnel-manager
-# Required-Start: $network sshd
-# Required-Stop: $network sshd
-# Should-Start:
-# Should-Stop:
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Start up the ssh-tunnel-manager manager
-# Description:       SSH-Tunnel-Manager to manager multiple SSH connections to different servers.
-### END INIT INFO
-
 #
 # Define names for the tunnel to identify them. The list needs to be configured 
 # in the same order as the tunnel config in the TUNELS list.
diff --git a/ssh-tunnel-manager.sysv-initscript b/ssh-tunnel-manager.sysv-initscript
new file mode 100644
index 0000000..ce6d3f9
--- /dev/null
+++ b/ssh-tunnel-manager.sysv-initscript
@@ -0,0 +1,69 @@
+#!/bin/sh
+#
+# ssh-tunnel-manager	Start up the ssh-tunnel-manager manager
+#
+# chkconfig: 2345 60 20
+# description: SSH-Tunnel-Manager to manager multiple SSH connections to different servers.
+#
+# config: /etc/ssh-tunnel-manager.conf
+
+### BEGIN INIT INFO
+# Provides: ssh-tunnel-manager
+# Required-Start: $network sshd
+# Required-Stop: $network sshd
+# Should-Start:
+# Should-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Start up the ssh-tunnel-manager manager
+# Description:       SSH-Tunnel-Manager to manager multiple SSH connections to different servers.
+### END INIT INFO
+
+# Source function library.
+#. /etc/rc.d/init.d/functions
+
+exec="/usr/sbin/ssh-tunnel-manager"
+prog="ssh-tunnel-manager"
+config="/etc/ssh-tunnel-manager.conf"
+
+
+start() {
+    [ -x $exec ] || exit 5
+    [ -f $config ] || exit 6
+    $exec start
+}
+
+stop() {
+    $exec start
+}
+
+restart() {
+    stop
+    start
+}
+
+rh_status() {
+    $exec status
+}
+
+
+case "$1" in
+    start)
+        rh_status_q && exit 0
+        $1
+        ;;
+    stop)
+        rh_status_q || exit 0
+        $1
+        ;;
+    restart)
+        $1
+        ;;
+    status)
+        rh_status
+        ;;
+    *)
+        echo $"Usage: $0 {start|stop|status|restart}"
+        exit 2
+esac
+exit $?
\ No newline at end of file
-- 
GitLab