Created
June 17, 2022 14:27
-
-
Save tenforward/c96966f0d3769357009cc611dc6a3d0a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. /lib/lsb/init-functions | |
stop_child_sshd(){ | |
err=0 | |
if [ -f /run/sshd.pid ]; then | |
pids=$(pgrep -P $(cat /run/sshd.pid)) | |
for p in $pids | |
do | |
kill $p | |
err=$? | |
done | |
sleep ${KILLDELAY} | |
if [ $err -eq 1 ]; then | |
pids=$(pgrep -P $(cat /run/sshd.pid)) | |
for p in $pids | |
do | |
kill -9 $p | |
err=$? | |
done | |
fi | |
else | |
killall sshd | |
err=$? | |
sleep ${KILLDELAY} | |
if [ $err -ne 0 ]; then | |
killall -9 sshd | |
err=$? | |
fi | |
fi | |
return $err | |
} | |
case "${1}" in | |
stop) | |
log_info_msg "Disconnecting ssh connection..." | |
stop_child_sshd | |
evaluate_retval | |
;; | |
*) | |
echo "Usage: ${0} stop" | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment