From 0e5b1be3ea356826c79fbdae01d6233542691176 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 22 Apr 2023 17:12:47 -0400 Subject: make work --- socat.sh | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/socat.sh b/socat.sh index 9d41445..76ec932 100755 --- a/socat.sh +++ b/socat.sh @@ -1,17 +1,9 @@ #!/bin/bash UNIT=socat-dns -DEST=${1:-149.56.44.185} -PORT=${2:-53} -LOCAL_PORT=${3:-$PORT} - -COMMAND="socat -v UDP-RECVFROM:$LOCAL_PORT,fork UDP-SENDTO:$DEST:$PORT" - verify_service_availability() { - true - return - dig . @localhost + dig . @127.0.0.1 >/dev/null 2>&1 } watchdog() @@ -30,6 +22,11 @@ main() { case "$1" in install) + shift + DEST=${1:-149.56.44.185} + PORT=${2:-53} + LOCAL_PORT=${3:-$PORT} + COMMAND="socat UDP-RECVFROM:$LOCAL_PORT,fork UDP-SENDTO:$DEST:$PORT" if systemctl is-active "$UNIT" >/dev/null then systemctl stop "$UNIT" @@ -38,17 +35,19 @@ main() systemd-run \ --unit "$UNIT" \ - --property Restart="on-failure" \ + --property Restart="always" \ --property WatchdogSec="5" \ -- \ - "$0" watchdog + "$0" watchdog "$COMMAND" ;; watchdog) + shift + COMMAND="$1" watchdog $$ & exec $COMMAND ;; *) - echo "Usage: $0 " >&2 + echo "Usage: $0 install [destination] [destination port] [local port]" >&2 exit 1 ;; esac -- cgit v1.2.3