diff --git a/wg-watch.sh b/wg-watch.sh index f9345ff0..1a911112 100755 --- a/wg-watch.sh +++ b/wg-watch.sh @@ -114,7 +114,7 @@ speedtest(){ exe_file='/var/tmp/warp'; result_file='/var/tmp/result.csv' if [ ! -f "$exe_file" ]; then - curl -Sfo "$exe_file" "https://git.tink.ltd:8443/netlist.git/tree/warp-$1?raw=true&h=better-warp-ip" + curl -Sfo "$exe_file" "https://git.tink.ltd:8443/netlist.git/tree/warp-$1?raw=true&h=better-warp-ip"; fi; ulimit -n 102400; chmod +x "$exe_file" && "$exe_file" -file "$2" -output "$result_file" >/dev/null 2>&1; @@ -131,7 +131,7 @@ speedtest(){ }; get_ip_cadidates(){ - limit=100 + limit=100; ip_file='/var/tmp/ip.txt' for item in $(generate_ips $limit $1); do echo "$item" >> "$ip_file"; @@ -180,7 +180,7 @@ main(){ arch=$(archAffix); if [ $? -ne 0 ]; then retry=$dl_retry_times; - fi + fi; echo "Running on $arch" loss=$(get_ping_loss $WATCH_ADD); while [ $loss -ge $LOSS_THR ]; do @@ -195,7 +195,7 @@ main(){ if [ $? -ne 0 ]; then retry=$(($retry + 1)); continue; - fi + fi; else cadidates=$(resolve_ip_addresses "$ENDPOINTS" $DEFAULT_PORT); fi; @@ -236,33 +236,33 @@ main(){ pfSsh.php playback wgpeer $CONFIG $(echo $endpoint|awk -F: '{print $1}') $(echo $endpoint|awk -F: '{print $2}') || true; fi; else - sed -i -r 's/Endpoint =.*/Endpoint = '$endpoint'/' $CONFIG + sed -i -r 's/Endpoint =.*/Endpoint = '$endpoint'/' $CONFIG; fi; }; pids=$(pgrep -afl $0); if [ $(echo $pids|grep -o $0|wc -l) -gt 1 ]; then - echo "Another process is already running." + echo "Another process is already running."; exit; fi; usage(){ echo "Usage: $0 [OPTIONS]"; - echo "Options:" - echo " -4 IPv4 (default)" - echo " -6 IPv6" - echo " -i Interface" - echo " -c Config" - echo " -a
Watch address (default: $WATCH_ADD)" - echo " -l Loss threshold (default: $LOSS_THR)" - echo " -p endpoint's default port (default: $DEFAULT_PORT)" - echo " -e File of endpoint's addresses" - echo " -k Interface peer's public key (default: $PUB_KEY)" - echo " -t Speed test only" - echo " -d Dry run" - echo "Note: If -e is not set, generate endpoints for warp, else resolve addresses and use default port." + echo "Options:"; + echo " -4 IPv4 (default)"; + echo " -6 IPv6"; + echo " -i Interface"; + echo " -c Config"; + echo " -a
Watch address (default: $WATCH_ADD)"; + echo " -l Loss threshold (default: $LOSS_THR)"; + echo " -p endpoint's default port (default: $DEFAULT_PORT)"; + echo " -e File of endpoint's addresses"; + echo " -k Interface peer's public key (default: $PUB_KEY)"; + echo " -t Speed test only"; + echo " -d Dry run"; + echo "Note: If -e is not set, generate endpoints for warp, else resolve addresses and use default port."; } FAMILY=4; @@ -319,8 +319,8 @@ while getopts ":h46i:c:a:l:p:e:k:td" opt; do ?) echo "Invalid Option: -$OPTARG"; exit 1;; - esac -done + esac; +done; -main +main;