Last active
December 10, 2015 01:34
-
-
Save ayanamist/4358761 to your computer and use it in GitHub Desktop.
OpenDNS DNSCrypt Watch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
PIDFILE=/var/run/dnscryptwatch.pid | |
BINPATH=/usr/sbin/dnscrypt-proxy -a 127.0.0.1:40 | |
DNSCRYPT_PIDFILE=/var/run/dnscrypt.pid | |
# Check whether script is running, and if running, exit directly | |
if [ -s $PIDFILE ] && [ -s /proc/$(cat $PIDFILE)/exe ]; then | |
exit 0 | |
fi | |
# Fork current script to background daemon | |
if [ -z "$_BACKGROUNDED" ]; then | |
_BACKGROUNDED=1 nohup $0 > /var/log/dnscryptwatch 2>&1 & | |
exit 0 | |
fi | |
# Main script | |
echo $$ > $PIDFILE | |
while : | |
do | |
if [ -s $DNSCRYPT_PIDFILE ] && [ -s /proc/$(cat $DNSCRYPT_PIDFILE)/exe ]; then | |
exit 0 | |
fi | |
$BINPATH -p $DNSCRYPT_PIDFILE | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment