This commit is contained in:
Gordon Grant-Stuart 2022-12-06 16:46:54 +00:00
parent 94b160d33a
commit 9b6eeb6073

View File

@ -3,13 +3,15 @@
REALPATH="$(realpath $0)"
BASEDIR="${REALPATH%/*}"
rm $BASEDIR/var/*.conf &>/dev/null # Create separate .conf files in var/ from etc/tunnelkeeper.conf
awk -v "dir=$BASEDIR/var" '
/^\[/ {sec=$1; gsub("[\[\]]","",sec)}
!/^\[/ {print >> dir"/"sec".conf"}' < $BASEDIR/etc/tunnelkeeper.conf &>/dev/null
if [[ "${1}" == "start" ]]; then
rm $BASEDIR/var/*.conf &>/dev/null # Create separate .conf files in var/ from etc/tunnelkeeper.conf
awk -v "dir=$BASEDIR/var" '
/^\[/ {sec=$1}
!/^\[/ {print >> dir"/"sec".conf"}' < $BASEDIR/etc/tunnelkeeper.conf &>/dev/null
fi
SSHCONF="$BASEDIR/var/ssh.conf"
TKCONF="$BASEDIR/var/settings.conf"
SSHCONF="$BASEDIR/var/[ssh].conf"
TKCONF="$BASEDIR/var/[settings].conf"
function ruroot () {
if [[ $UID -ne 0 ]]; then
@ -18,7 +20,7 @@ function ruroot () {
fi
}
DEBUGLEVEL=$(cat $TKCONF | grep -i "debug" | grep -o [0-9])
DEBUGLEVEL=$(grep -i -m1 "debug" $TKCONF | grep -o [0-9])
case "$DEBUGLEVEL" in
2) dbgopt='-v';;
3) dbgopt='-vvv';;
@ -26,9 +28,7 @@ case "$DEBUGLEVEL" in
esac
function dbg () {
if [[ $DEBUGLEVEL != "0" ]]; then
logger -t tunnelkeeper
fi
[[ $DEBUGLEVEL != "0" ]] && logger -t tunnelkeeper
}
case "$1" in
@ -39,7 +39,7 @@ case "$1" in
sleep 5
done
;;
FORKKILL ) kill $(sudo netstat -tnlp | grep "127.0.0.1:${2}" | grep -o '[0-9]*/ssh' | grep -o '[0-9]*') &>/dev/null ;;
FORKKILL ) kill $(sudo netstat -tnlp | grep "127[0-9\.]*:${2}" | grep -o '[0-9]*/ssh' | grep -o '[0-9]*') &>/dev/null ;;
FORKDEL ) rm "$BASEDIR/var/${2}.connected" ;;
start)
[[ -e "$BASEDIR/var/tunnelkeeper.pid" ]] && exit