add more debug detail

This commit is contained in:
Gordon Grant-Stuart 2023-02-22 16:20:50 +00:00
parent 4d35eeae37
commit 91110e4a6e

View File

@ -45,6 +45,7 @@ function connect () {
case "$1" in case "$1" in
FORKSTART ) FORKSTART )
# echo -n $$ > "$BASEDIR/var/${2}.connected" # echo -n $$ > "$BASEDIR/var/${2}.connected"
$0 FORKWATCH $2 '#tunnelkeeper' &
if [[ $(grep -c "^$2" $PWCONF) -gt 0 ]]; then if [[ $(grep -c "^$2" $PWCONF) -gt 0 ]]; then
pass=$(awk "/^$2/ {print \$2}" ${PWCONF}) # password needed pass=$(awk "/^$2/ {print \$2}" ${PWCONF}) # password needed
screen -d -m -S "tk${2}" $0 FORKSCREEN $2 '#tunnelkeeper' screen -d -m -S "tk${2}" $0 FORKSCREEN $2 '#tunnelkeeper'
@ -64,16 +65,18 @@ case "$1" in
sleep 5 sleep 5
done done
fi fi
$0 FORKWATCH $2 '#tunnelkeeper' &
exit exit
;; ;;
FORKWATCH ) # makes sure the connection is still working, even if ssh doesn't drop it FORKWATCH ) # makes sure the connection is still working, even if ssh doesn't drop it
while true; do while true; do
sleep $TIMEOUT sleep $TIMEOUT
echo "tick $2" | dbg
if [[ $(timeout $TIMEOUT ssh localhost -S $BASEDIR/var/$2.tksock "echo tk") != "tk" ]]; then if [[ $(timeout $TIMEOUT ssh localhost -S $BASEDIR/var/$2.tksock "echo tk") != "tk" ]]; then
ssh localhost -O exit -S $BASEDIR/var/$2.tksock ssh localhost -O exit -S $BASEDIR/var/$2.tksock
echo "Killing connection to $2. Trying again." | dbg
fi fi
done done
exit
;; ;;
FORKSCREEN ) FORKSCREEN )
# while [[ -e "$BASEDIR/var/${2}.connected" ]]; do # while [[ -e "$BASEDIR/var/${2}.connected" ]]; do