是咁的,dnscrypt好似成日有問題.......寫左個簡單script做monitor+restart
#!/bin/bash
DNS_TIMEOUT=5
RESET_WHEN_FAIL_COUNT=5
SLEEP_INTERVAL=3
RESTART_SERVICES="[email protected] dnscrypt-proxy@securedns dnsmasq"
fail_count=0
while true; do
while true; do
ping -c 1 8.8.8.8 > /dev/null && break
echo Network not yet working...
sleep 1
done
timeout ${DNS_TIMEOUT} dig $(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1).wtako.net > /dev/null
if [ $? -eq 0 ]; then
fail_count=0
else
fail_count=$((fail_count + 1))
echo DNS FAIL $fail_count
fi
if [ $fail_count -ge ${RESET_WHEN_FAIL_COUNT} ]; then
echo Reset dnscrypt proxies
systemctl restart ${RESTART_SERVICES}
fail_count=0
fi
sleep ${SLEEP_INTERVAL}
done