guix-config

Guix system and home config for XIII (librebooted T480)
git clone https://g1rls.strangled.net/guix-config.git
Log | Files | Refs | README

linkwatch.sh (763B)


      1 #!/bin/sh
      2 # linkwatch: wait until the VPS answers, refresh mihomo's rule lists (their
      3 # pulls fail at boot because mihomo starts before wifi has an address), then
      4 # log ping loss to the VPS once a minute so stalls can be matched to the line.
      5 VPS=${1:?usage: linkwatch.sh VPS-IP}
      6 until ping -c 1 -w 3 $VPS >/dev/null 2>&1; do sleep 5; done
      7 S=$(sed -n 's/^secret: *//p' /etc/mihomo/config.yaml | tr -d "\"'")
      8 for p in games-direct geosite-ru geoip-ru ru-inline-banned; do
      9   c=$(curl -s -o /dev/null -w '%{http_code}' -m 30 -X PUT -H "Authorization: Bearer $S" http://127.0.0.1:9090/providers/rules/$p)
     10   echo "$(date '+%F %T') provider $p -> $c"
     11 done
     12 while :; do
     13   out=$(ping -c 60 -i 1 $VPS 2>/dev/null | tail -2 | tr '\n' ' ')
     14   echo "$(date '+%F %T') $out"
     15 done