aboutsummaryrefslogtreecommitdiff
path: root/net/autossh/files/autossh.init
diff options
context:
space:
mode:
Diffstat (limited to 'net/autossh/files/autossh.init')
-rw-r--r--net/autossh/files/autossh.init16
1 files changed, 8 insertions, 8 deletions
diff --git a/net/autossh/files/autossh.init b/net/autossh/files/autossh.init
index 0e7b08666..2c1890532 100644
--- a/net/autossh/files/autossh.init
+++ b/net/autossh/files/autossh.init
@@ -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}