[packages] sshtunnel: bug fix
git-svn-id: svn://svn.openwrt.org/openwrt/packages@24807 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
8cf514a8b0
commit
d5391e6226
@ -135,11 +135,11 @@ load_server() {
|
||||
[ -n "$error" ] && { logger -p user.err -t "sshtunnel" "tunnels to $server not started - $error"; return; }
|
||||
[ "$count" -eq 0 ] && { logger -p user.err -t "sshtunnel" "tunnels to $server not started - no tunnels defined"; return; }
|
||||
|
||||
append_params CheckHostIP Compression CompressionLevel IdentityFile LogLevel PKCS11Provider ServerAliveCountMax ServerAliveInterval StrickHostKeyChecking TCPKeepAlive VerifyHostKeyDNS
|
||||
append_params CheckHostIP Compression CompressionLevel IdentityFile LogLevel PKCS11Provider ServerAliveCountMax ServerAliveInterval StrictHostKeyChecking TCPKeepAlive VerifyHostKeyDNS
|
||||
ARGS="$ARGS_options -o ExitOnForwardFailure=yes -o BatchMode=yes -nN $ARGS_tunnels $user@$hostname"
|
||||
|
||||
/usr/bin/sshtunnel.sh "$ARGS" "$retrydelay" "$server" &
|
||||
echo $! >> "$PIDFILE".pids
|
||||
echo $! >> "${PIDFILE}.pids"
|
||||
logger -p user.info -t "sshtunnel" "started tunnels to $server (pid=$!;retrydelay=$retrydelay)"
|
||||
}
|
||||
|
||||
@ -150,13 +150,18 @@ stop() {
|
||||
|
||||
while read pid
|
||||
do
|
||||
start-stop-daemon -K -p "$PIDFILE"_"$pid".pid
|
||||
kill $pid
|
||||
logger -p daemon.info -t "sshtunnel[$pid]" "tunnel stopped"
|
||||
rm "$PIDFILE"_"$pid".pid
|
||||
done < "$PIDFILE".pids
|
||||
kill "$pid" # kill mother process first
|
||||
|
||||
rm "$PIDFILE".pids
|
||||
[ -f "${PIDFILE}_${pid}.pid" ] && { # if ssh was running, kill it also (mother process could be in retry wait)
|
||||
start-stop-daemon -K -p "${PIDFILE}_${pid}.pid"
|
||||
rm "${PIDFILE}_${pid}.pid"
|
||||
}
|
||||
|
||||
logger -p daemon.info -t "sshtunnel[$pid]" "tunnel stopped"
|
||||
|
||||
done < "${PIDFILE}.pids"
|
||||
|
||||
rm "${PIDFILE}.pids"
|
||||
|
||||
logger -p user.info -t "sshtunnel" "all tunnels stopped"
|
||||
else
|
||||
@ -165,7 +170,7 @@ stop() {
|
||||
}
|
||||
|
||||
start() {
|
||||
[ -f "$PIDFILE".pids ] && stop
|
||||
[ -f "${PIDFILE}.pids" ] && stop
|
||||
|
||||
config_load sshtunnel
|
||||
if [ -n "$(uci show sshtunnel.@server[0])" ] # at least one server section exists
|
||||
|
@ -10,11 +10,12 @@ while true
|
||||
do
|
||||
logger -p daemon.info -t "sshtunnel[$$][$server]" "connection started"
|
||||
|
||||
start-stop-daemon -S -p "$PIDFILE"_"$$".pid -mx ssh -- $args &>/tmp/log/sshtunnel_$$
|
||||
start-stop-daemon -S -p "${PIDFILE}_${$}.pid" -mx ssh -- $args &>/tmp/log/sshtunnel_$$
|
||||
|
||||
logger -p daemon.err -t "sshtunnel[$$][$server]" < /tmp/log/sshtunnel_$$
|
||||
rm /tmp/log/sshtunnel_$$
|
||||
logger -p daemon.info -t "sshtunnel[$$][$server]" "ssh exited with code $?, retrying in $retrydelay seconds"
|
||||
rm "${PIDFILE}_${$}.pid"
|
||||
|
||||
sleep "$retrydelay" & wait
|
||||
done
|
||||
|
Loading…
x
Reference in New Issue
Block a user