diff --git a/etc/tunnelkeeper.conf b/etc/tunnelkeeper.conf index 97b4493..0cbea3d 100644 --- a/etc/tunnelkeeper.conf +++ b/etc/tunnelkeeper.conf @@ -1,12 +1,4 @@ # Everything in this file obeys the same rules as ~/.ssh/config, except for the Password, Watch and Debug directives - -Host * - ExitOnForwardFailure yes - TCPKeepAlive yes - ServerAliveInterval 15 - ServerAliveCountMax 3 - ControlMaster auto - StrictHostKeyChecking no # Examples # diff --git a/tunnelkeeper b/tunnelkeeper index 4ac8c31..e9c0211 100755 --- a/tunnelkeeper +++ b/tunnelkeeper @@ -10,7 +10,17 @@ DEBUGCONF="$BASEDIR/var/debug.conf" function genconfig () { mkdir -p "$BASEDIR/var" - cat "$BASEDIR/etc/tunnelkeeper.conf" | grep -Eiv '^ *(watch|password|debug)' > "$SSHCONF" + cat < "$SSHCONF" +Host * + ExitOnForwardFailure yes + TCPKeepAlive yes + ServerAliveInterval 15 + ServerAliveCountMax 3 + ControlMaster auto + StrictHostKeyChecking no + +EOF + cat "$BASEDIR/etc/tunnelkeeper.conf" | grep -Eiv '^ *(watch|password|debug)' >> "$SSHCONF" cat "$BASEDIR/etc/tunnelkeeper.conf" | grep -Ei '^( *watch|Host)' | awk '{print $1 " " $2}' | grep -i -B1 --no-group-separator watch | tr '\n' ' ' | sed 's/Host /\n/g; s/ *[Ww]atch//g' > "$WATCHCONF" cat "$BASEDIR/etc/tunnelkeeper.conf" | grep -Ei '^( *password|Host)' | awk '{print $1 " " $2}' | grep -i -B1 --no-group-separator password | tr '\n' ' ' | sed 's/Host /\n/g; s/ *[Pp]assword//g' > "$PWCONF" cat "$BASEDIR/etc/tunnelkeeper.conf" | grep -Ei '^( *debug|Host)' | awk '{print $1 " " $2}' | grep -i -B1 --no-group-separator debug | tr '\n' ' ' | sed 's/Host /\n/g; s/ *[Dd]ebug//g' > "$DEBUGCONF" @@ -88,7 +98,7 @@ case "$1" in [[ -e "$BASEDIR/var/tunnelkeeper.pid" ]] && exit genconfig echo $$ > "$BASEDIR/var/tunnelkeeper.pid" - cat "$SSHCONF" | awk '/^Host / {print $2}' | grep -v \* | xargs -I% -P0 $0 FORKSTART % '#tunnelkeeper' & + cat "$BASEDIR/etc/tunnelkeeper.conf" | awk '/^Host / {print $2}' | xargs -I% -P0 $0 FORKSTART % '#tunnelkeeper' & ;; stop ) rm -f "$BASEDIR/var/tunnelkeeper.pid"