From 9530c272a3a76716eaf2f351a11be3c1b4e423d6 Mon Sep 17 00:00:00 2001 From: Alter Step Date: Thu, 9 Feb 2017 10:47:34 +0100 Subject: [PATCH] Find config differences to do less reloads This is not 100% fail proof , because the configuration can change and come back to the original one during the server restart but at the end of the day it's a better user experience. --- .../extra/usr/scripts/handle-control-change.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/handle-control-change.sh b/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/handle-control-change.sh index c76ea61..c626eda 100755 --- a/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/handle-control-change.sh +++ b/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/handle-control-change.sh @@ -4,6 +4,8 @@ PROCESSED_TICKETS_FILE="${STATES_DIR}/processed-tickets" +logger_debug handle_control_change + update() { lockfile -1 -r 30 "$HANDLERS_LOCK_FILE" || exit 1 @@ -19,15 +21,21 @@ update() { touch "${STATES_DIR}/updating" -logger_debug "DNSCrypt-OSXClient configuration changed" - updated='no' while :; do find "$TICKETS_DIR" -type f -name 'ticket-*' > "$PROCESSED_TICKETS_FILE" if [ ! -s "$PROCESSED_TICKETS_FILE" -a "$updated" = 'yes' ]; then break fi - update + logger_debug "New tickets found" + find "$CONTROL_DIR" -type f -name '[a-zA-Z0-9]*' \! -name '*.tmp' \ + -exec md5 {} \; > "${STATES_DIR}/controls.cksum.new" + if cmp -s "${STATES_DIR}/controls.cksum.new" "${STATES_DIR}/controls.cksum"; then + logger_debug "Content of the controls dir actually didn't change" + else + update + mv -f "${STATES_DIR}/controls.cksum.new" "${STATES_DIR}/controls.cksum" + fi updated='yes' while read ticket_file; do rm -f "$ticket_file"