remove comments in conf files

This commit is contained in:
Gordon Grant-Stuart 2022-12-07 16:17:15 +00:00
parent 9b6eeb6073
commit 8348e58edb
2 changed files with 10 additions and 4 deletions

View File

@ -10,7 +10,7 @@ debug 0
# User ubuntu
# LocalForward 10001 127.0.0.1:22
#
# Host server1
# Host server2
# Hostname 123.45.67.90
# User ubuntu
# LocalForward 10002 127.0.0.1:22

View File

@ -7,7 +7,7 @@ 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
!/^[#\[]/ {print >> dir"/"sec".conf"}' < $BASEDIR/etc/tunnelkeeper.conf &>/dev/null
fi
SSHCONF="$BASEDIR/var/[ssh].conf"
@ -33,7 +33,7 @@ function dbg () {
case "$1" in
FORKSTART )
touch "$BASEDIR/var/${2}.connected"
echo -n $$ > "$BASEDIR/var/${2}.connected"
while [[ -e "$BASEDIR/var/${2}.connected" ]]; do
ssh -F "${SSHCONF}" $dbgopt -N $2 2>&1 | dbg
sleep 5
@ -51,7 +51,13 @@ case "$1" in
cat "$SSHCONF" | awk '/^Host / {print $2}' | sed 's/^Host //' | xargs -I% -P0 $0 FORKDEL %
cat "$SSHCONF" | grep -o 'LocalForward [0-9]* ' | grep -o '[0-9]*' | xargs -I% -P0 $0 FORKKILL %
;;
restart) $0 stop; sleep 2; $0 start ;;
restart)
if systemctl status tunnelkeeper &>/dev/null; then
systemctl restart tunnelkeeper
else
$0 stop; sleep 2; $0 start
fi
;;
install )
ruroot
mkdir -p /opt/tunnelkeeper/var