From bb108bdb18a7980eb8d15f65aa39868b1b789483 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sun, 29 Jul 2012 23:29:47 -0700 Subject: [PATCH] Add a simple handler for control changes. --- CU2/common.inc | 2 ++ CU2/handle-control-change.sh | 7 +++++++ CU2/switch-to-dhcp.sh | 2 -- CU2/switch-to-dnscrypt.sh | 1 - 4 files changed, 9 insertions(+), 3 deletions(-) create mode 100755 CU2/handle-control-change.sh diff --git a/CU2/common.inc b/CU2/common.inc index cecd5bc..6ae148c 100644 --- a/CU2/common.inc +++ b/CU2/common.inc @@ -6,6 +6,8 @@ DNSCRYPT_PROXY_BASE_DIR="${DNSCRYPT_BASE_DIR}/dnscrypt-proxy" PROXY_PID_FILE="${DNSCRYPT_PROXY_BASE_DIR}/dnscrypt-proxy.pid" STATES_DIR="${DNSCRYPT_BASE_DIR}/states" +DNSCRYPT_FILE="${CONTROL_DIR}/dnscrypt" + INTERFACE_UNBOUND="127.0.0.53" INTERFACE_UNBOUND_MASK="24" INTERFACE_PROXY="127.0.0.54" diff --git a/CU2/handle-control-change.sh b/CU2/handle-control-change.sh new file mode 100755 index 0000000..f0836a5 --- /dev/null +++ b/CU2/handle-control-change.sh @@ -0,0 +1,7 @@ +#! /bin/sh + +if [ -e $DNSCRYPT_FILE ]; then + exec ./switch-to-dnscrypt.sh +else + exec ./switch-to-dhcp.sh +fi diff --git a/CU2/switch-to-dhcp.sh b/CU2/switch-to-dhcp.sh index 26df2e2..4d6f85b 100755 --- a/CU2/switch-to-dhcp.sh +++ b/CU2/switch-to-dhcp.sh @@ -2,8 +2,6 @@ . common.inc -DNSCRYPT_FILE="${CONTROL_DIR}/dnscrypt" - [ -e "$DNSCRYPT_FILE" ] && exit 0 ./set-dns-to-dhcp.sh diff --git a/CU2/switch-to-dnscrypt.sh b/CU2/switch-to-dnscrypt.sh index ebdb4d6..b12b13c 100755 --- a/CU2/switch-to-dnscrypt.sh +++ b/CU2/switch-to-dnscrypt.sh @@ -4,7 +4,6 @@ PAUSE_MAX=10 PAUSE_INCREMENT=0.1 -DNSCRYPT_FILE="${CONTROL_DIR}/dnscrypt" [ ! -e "$DNSCRYPT_FILE" ] && exit 0