Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
ssh-tunnel-manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
ssh-tunnel-manager
Commits
0f871784
Commit
0f871784
authored
7 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Clean up forwarded sockets before re-forwarding
parent
d45eda49
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ssh-tunnel-manager.conf.example
+11
-1
11 additions, 1 deletion
ssh-tunnel-manager.conf.example
ssh-tunnel-manager.sh
+13
-4
13 additions, 4 deletions
ssh-tunnel-manager.sh
with
24 additions
and
5 deletions
ssh-tunnel-manager.conf.example
+
11
−
1
View file @
0f871784
...
...
@@ -13,7 +13,7 @@
#
# 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.
# in the same order as the tunnel config in the TUN
N
ELS list.
#
#TUNNEL_NAMES=(
# "Tunnel-A"
...
...
@@ -30,6 +30,16 @@
# "-p 1234 username@host2.example.com -L 10002:127.0.0.1:3306 -L 10012:127.0.0.1:27017"
#)
#
# The SOCKETS array is used to configure sockets forwarded by individual
# ports. Each forwarded socket must be removed before it can be forwarded
# again, which this handles.
#
#SOCKETS=(
# ""
# ""
#)
#
# The RECONNECT_TIMER is used in case of a tunnel connection to be lost. After
# the script is detecting that the connection was lost, the time defines the
...
...
This diff is collapsed.
Click to expand it.
ssh-tunnel-manager.sh
+
13
−
4
View file @
0f871784
...
...
@@ -270,7 +270,7 @@ SCRIPT_PID=$$
# start procedure according to the action
#
case
$COMMAND
in
restart
)
restart
)
echotime
"COMM - Execute RESTART procedure ... "
$0
--config
$CONFIG_FILE
stop
$COMMAND_INDEX_NAME
sleep
2
...
...
@@ -313,8 +313,13 @@ case $COMMAND in
kill
$PID
&>/dev/null
done
if
[
-e
"
${
SOCKETS
[
$idx
]
}
"
]
;
then
echo
"Removing socket '
${
SOCKETS
[
$idx
]
}
' ..."
rm
${
SOCKETS
[
$idx
]
}
fi
echotime
"STOP - Stopped tunnel '
${
TUNNEL_NAMES
[
$idx
]
}
' (ID
$idx
) ... PID:
$RESULT_PID
"
# check if the tunnels really down
sleep
"0.3"
TUNNELS_COUNT
=
0
...
...
@@ -402,6 +407,11 @@ case $COMMAND in
echotime
"START - Already running tunnel '
${
TUNNEL_NAMES
[
$idx
]
}
' (ID
$idx
) ... PID:
$RESULT_PID
"
echo
"Starting tunnel '
${
TUNNEL_NAMES
[
$idx
]
}
' ... Already running"
else
if
[
-e
"
${
SOCKETS
[
$idx
]
}
"
]
;
then
echo
"Removing socket '
${
SOCKETS
[
$idx
]
}
' ..."
rm
${
SOCKETS
[
$idx
]
}
fi
$0
--config
$CONFIG_FILE
manage
$idx
&
sleep
"0.2"
RESULT_PID
=
`
ps aux |
grep
-v
grep
|
grep
"
$0
--config
$CONFIG_FILE
manage
$idx
"
|
awk
'{print $2}'
|
tr
'\n'
' '
`
...
...
@@ -409,7 +419,7 @@ case $COMMAND in
echotime
"START - Starting tunnel '
${
TUNNEL_NAMES
[
$idx
]
}
' (ID
$idx
) ... PID:
$RESULT_PID
"
echo
"Starting tunnel '
${
TUNNEL_NAMES
[
$idx
]
}
' ... Done"
fi
# sleep before every cycle to aviod overloading
# sleep before every cycle to aviod overloading
done
echotime
"COMM - Execute START procedure ... Done"
echotime
""
...
...
@@ -430,4 +440,3 @@ case $COMMAND in
done
;;
esac
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment