-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsshWrapper.sh
More file actions
40 lines (31 loc) · 785 Bytes
/
sshWrapper.sh
File metadata and controls
40 lines (31 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# Enable job control
set -m
SSHD_KILL_GRACE_TIME=3
RUNNING_SSHD=""
function restartSshd() {
echo "USR1 signal received. Restarting SSH server"
if [ -n "$RUNNING_SSHD" ]; then
kill $RUNNING_SSHD
sleep $SSHD_KILL_GRACE_TIME
kill -9 $RUNNING_SSHD 2&>1 /dev/null
fi
/usr/sbin/sshd -D -e &
RUNNING_SSHD=$!
}
function exitWrapper() {
echo "Quit signal received. Exiting"
if [ -n "$RUNNING_SSHD" ]; then
kill $RUNNING_SSHD
sleep $SSHD_KILL_GRACE_TIME
kill -9 $RUNNING_SSHD 2&>1 /dev/null
fi
exit 0
}
trap "restartSshd" USR1
trap "exitWrapper" SIGINT SIGTERM
/usr/sbin/sshd -D -e &
RUNNING_SSHD=$!
while true ; do
sleep 5; # This script is not really doing anything.
done