From d210ac58757fc568bd9ddb713cc40487c96b6451 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 2 Aug 2012 18:20:40 -0700 Subject: [PATCH] Move tickets to their own dir and make everything much much much faster --- .../Scripts/dnscrypt-prefpane-postinstall.sh | 6 +++++- .../DNSCrypt/extra/usr/scripts/common.inc | 2 +- .../DNSCrypt/extra/usr/scripts/gui-pop-conf-change.sh | 4 ++-- .../DNSCrypt/extra/usr/scripts/gui-push-conf-change.sh | 2 +- .../DNSCrypt/extra/usr/scripts/handle-console-change.sh | 3 ++- .../DNSCrypt/extra/usr/scripts/handle-control-change.sh | 6 ++++-- .../DNSCrypt/extra/usr/scripts/handle-network-change.sh | 2 ++ 7 files changed, 17 insertions(+), 8 deletions(-) diff --git a/DNSCrypt-OSX-Installer/Scripts/dnscrypt-prefpane-postinstall.sh b/DNSCrypt-OSX-Installer/Scripts/dnscrypt-prefpane-postinstall.sh index 8430921..a8759c4 100755 --- a/DNSCrypt-OSX-Installer/Scripts/dnscrypt-prefpane-postinstall.sh +++ b/DNSCrypt-OSX-Installer/Scripts/dnscrypt-prefpane-postinstall.sh @@ -5,6 +5,7 @@ exec 2>/dev/null /bin/mkdir -p '/Library/Application Support/DNSCrypt/control' /bin/mkdir -p '/Library/Application Support/DNSCrypt/dnscrypt-proxy' /bin/mkdir -p '/Library/Application Support/DNSCrypt/probes' +/bin/mkdir -p '/Library/Application Support/DNSCrypt/tickets' /bin/mkdir -p '/Library/Application Support/DNSCrypt/states' /usr/sbin/chown -R 0:0 '/Library/Application Support/DNSCrypt' /bin/chmod 710 '/Library/Application Support/DNSCrypt' @@ -12,7 +13,10 @@ exec 2>/dev/null eval $(/usr/bin/stat -s '/dev/console') if [ $? != 0 ]; then wanted_uid="$st_uid" - /usr/sbin/chown -R "${wanted_uid}:0" '/Library/Application Support/DNSCrypt/control' + /usr/sbin/chown -R "${wanted_uid}:0" \ + '/Library/Application Support/DNSCrypt/control' + /usr/sbin/chown -R "${wanted_uid}:0" \ + '/Library/Application Support/DNSCrypt/tickets' fi /bin/launchctl load -D local diff --git a/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/common.inc b/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/common.inc index cb1cf49..c2986c3 100644 --- a/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/common.inc +++ b/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/common.inc @@ -5,7 +5,7 @@ DNSCRYPT_VAR_BASE_DIR='/Library/Application Support/DNSCrypt' cd -- "${DNSCRYPT_USR_BASE_DIR}/scripts" || exit 1 CONTROL_DIR="${DNSCRYPT_VAR_BASE_DIR}/control" -TICKETS_DIR="${CONTROL_DIR}/tickets" +TICKETS_DIR="${DNSCRYPT_VAR_BASE_DIR}/tickets" DNSCRYPT_PROXY_BASE_DIR="${DNSCRYPT_VAR_BASE_DIR}/dnscrypt-proxy" PROXY_PID_FILE="${DNSCRYPT_PROXY_VAR_BASE_DIR}/dnscrypt-proxy.pid" STATES_DIR="${DNSCRYPT_VAR_BASE_DIR}/states" diff --git a/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/gui-pop-conf-change.sh b/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/gui-pop-conf-change.sh index 584c4fd..a842fb9 100755 --- a/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/gui-pop-conf-change.sh +++ b/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/gui-pop-conf-change.sh @@ -12,8 +12,8 @@ case "$pname" in esac changed='no' -if [ -e "${CONTROL_DIR}/gui-change-${pname}" ]; then - rm -f "${CONTROL_DIR}/gui-change-${pname}" +if [ -e "${TICKETS_DIR}/gui-change-${pname}" ]; then + rm -f "${TICKETS_DIR}/gui-change-${pname}" changed='yes' fi diff --git a/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/gui-push-conf-change.sh b/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/gui-push-conf-change.sh index e37027e..e35e16e 100755 --- a/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/gui-push-conf-change.sh +++ b/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/gui-push-conf-change.sh @@ -11,4 +11,4 @@ case "$pname" in *) exit 1;; esac -touch "${CONTROL_DIR}/gui-change-${pname}" +touch "${TICKETS_DIR}/gui-change-${pname}" diff --git a/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/handle-console-change.sh b/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/handle-console-change.sh index 17867ef..92761ea 100755 --- a/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/handle-console-change.sh +++ b/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/handle-console-change.sh @@ -8,7 +8,8 @@ if [ ! -d "$DNSCRYPT_VAR_BASE_DIR" ]; then mkdir -p "$DNSCRYPT_VAR_BASE_DIR" || exit 1 chown -R 0:0 "$DNSCRYPT_VAR_BASE_DIR" fi +mkdir -p "$CONTROL_DIR" || exit 1 mkdir -p "$TICKETS_DIR" || exit 1 -eval $(stat -s "$CONTROL_DIR") || exit 1 chown -R "${wanted_uid}:0" "$CONTROL_DIR" +chown -R "${wanted_uid}:0" "$TICKETS_DIR" find "$DNSCRYPT_VAR_BASE_DIR" -type d -exec chmod 755 {} \; 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 be9bbcd..b480d1f 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 @@ -19,12 +19,14 @@ update() { touch "${STATES_DIR}/updating" +updated='no' while :; do find "$TICKETS_DIR" -type f -name 'ticket-*' > "$PROCESSED_TICKETS_FILE" - update - if [ ! -s "$PROCESSED_TICKETS_FILE" ]; then + if [ ! -s "$PROCESSED_TICKETS_FILE" -a "$updated" = 'yes' ]; then break fi + update + updated='yes' while read ticket_file; do rm -f "$ticket_file" done < "$PROCESSED_TICKETS_FILE" diff --git a/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/handle-network-change.sh b/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/handle-network-change.sh index 2552cd3..c5a8bc5 100755 --- a/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/handle-network-change.sh +++ b/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/handle-network-change.sh @@ -2,6 +2,8 @@ . ./common.inc +tickets_count=$(./get-tickets_count) +[ "$tickets_count" != '0' ] && exit 0 [ ! -e "$FALLBACK_FILE" ] && exit 0 ./check-network-change.sh || exit 0