autossh: make forwarding optional
authorkkubicki <krzysiek.kubicki@gmail.com>
Fri, 12 Jan 2024 21:26:17 +0000 (21:26 +0000)
committerRosen Penev <rosenp@gmail.com>
Wed, 7 Feb 2024 22:11:35 +0000 (14:11 -0800)
- previously localport option was required, which broke older configs
- now in-config forwarding is only optional
- ssh option still can be used for forwarding as in sample config

Signed-off-by: kkubicki <krzysiek.kubicki@gmail.com>
net/autossh/Makefile
net/autossh/files/autossh.init

index 9889378f82f423c66e92eb27775d7295fc347710..6bf2a1dda32f7e7a6188d3c96ff7cbd382672154 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=autossh
 PKG_VERSION:=1.4g
-PKG_RELEASE:=4
+PKG_RELEASE:=5
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tgz
 PKG_SOURCE_URL:=https://www.harding.motd.ca/autossh/
index 0e7b08666d4932b4a627c790a84e8bd3240437c7..2c18905320cbb48571a8448f064894ab6e89c88b 100644 (file)
@@ -34,17 +34,17 @@ start_instance() {
        config_get path            "$section" path
        config_get pidfile         "$section" pidfile
 
-       if [ -z "$localport" ]; then
-               echo "autossh: localport option is required"
+       if [ -n "$localport" ] && [ -n "$remoteport" ]; then
+               if [ -n "$remotehost" ]; then
+                       forwarding="-L ${localport}:${remotehost}:${remoteport}"
+               else
+                       forwarding="-R ${remoteport}:${localhost}:${localport}"
+               fi
+       elif [ -n "$localport" ] || [ -n "$remoteport" ]; then
+               echo "autossh: both localport and remoteport options are required"
                return 1
        fi
 
-       if [ -n "$remotehost" ]; then
-               forwarding="-L ${localport}:${remotehost}:${remoteport}"
-       else
-               forwarding="-R ${remoteport}:${localhost}:${localport}"
-       fi
-
        procd_open_instance "$section"
        procd_set_param command /usr/sbin/autossh ${forwarding} ${ssh}
        procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}