#!/bin/bash # Start/stop the ssh port forwarding tunnel daemon. DAEMON=/usr/local/sbin/tunneld SHOOTER=/usr/local/sbin/mtunnel TUNNEL=(su - ossi -c '/usr/bin/ssh -x -L 50025:irz301:25 -L 50143:irz301:143 irz601 \~/bin/tunnelk') ARGS=(-q "${TUNNEL[@]}") case "$1" in shoot) start-stop-daemon --stop --signal 1 --exec $DAEMON || $SHOOTER "${TUNNEL[@]}" ;; start) echo -n "Starting SSH mail tunnel: " start-stop-daemon --start --exec $DAEMON -- "${ARGS[@]}" && echo "done." || echo "failed!" ;; stop) echo -n "Stopping SSH mail tunnel: " start-stop-daemon --stop --exec $DAEMON && echo "done." || echo "failed!" ;; restart) echo -n "Re-loading SSH mail tunnel: " start-stop-daemon --stop --quiet --exec $DAEMON start-stop-daemon --start --exec $DAEMON -- "${ARGS[@]}" && echo "done." || echo "failed!" ;; reload|force-reload) echo -n "Re-starting SSH mail tunnel: " start-stop-daemon --stop --signal 1 --exec $DAEMON && echo "done." || echo "failed!" ;; *) echo "Usage: /etc/init.d/tunnel start|stop"; exit 1 ;; esac exit 0