lockfile -l acts weird - Do not use it. Add some logging for the HTTP hijack test

This commit is contained in:
Alter Step
2014-04-28 18:53:28 -07:00
parent fb416bf21e
commit 89e8c923fa
4 changed files with 10 additions and 4 deletions
@@ -62,7 +62,7 @@ logger_debug() {
[ -f "$DEBUG_ENABLED_FILE" ] || return
local msg="$1"
local now="$(date)"
lockfile "$DEBUG_LOG_FILE_LOCK" -1 -r 1 -l 5
lockfile -1 -r 1 "$DEBUG_LOG_FILE_LOCK"
echo "$now - $msg" >> "$DEBUG_LOG_FILE"
rm -f "$DEBUG_LOG_FILE_LOCK"
}
@@ -5,7 +5,7 @@
PROCESSED_TICKETS_FILE="${STATES_DIR}/processed-tickets"
update() {
lockfile -1 -r 30 -l 60 "$HANDLERS_LOCK_FILE" || exit 1
lockfile -1 -r 30 "$HANDLERS_LOCK_FILE" || exit 1
if [ -e "$DNSCRYPT_FILE" ]; then
./switch-to-dnscrypt-if-required.sh
@@ -13,7 +13,7 @@ fi
logger_debug "Network configuration changed"
lockfile -1 -r 30 -l 60 "$HANDLERS_LOCK_FILE" || exit 1
lockfile -1 -r 30 "$HANDLERS_LOCK_FILE" || exit 1
./set-dns-to-dhcp.sh
if [ ! -e "$DNSCRYPT_FILE" ]; then
rm -f "$HANDLERS_LOCK_FILE"
@@ -23,7 +23,13 @@ while [ -e "$DNSCRYPT_FILE" ]; do
pause=$((pause + $PAUSE_INCREMENT))
fi
sleep $pause
./check-hijacking.sh || continue
logger_debug "Checking if the router hijacks HTTP queries"
if ./check-hijacking.sh; then
logger_debug "The router doesn't hijack HTTP queries"
else
logger_debug "The router hijacks HTTP queries - DNSCrypt is likely to be blocked"
continue
fi
./start-dnscrypt-proxy.sh || continue
./check-local-dns.sh || continue
./set-dns.sh "$INTERFACE_PROXY"