From 43588248614f988b3cb266f52a034632ef3353ac Mon Sep 17 00:00:00 2001 From: Alexey Martemyanov Date: Tue, 10 Dec 2024 18:45:34 +0600 Subject: [PATCH 1/3] include config dir clearance in clean-app script --- clean-app.sh | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/clean-app.sh b/clean-app.sh index 2bba9829e3..70809c1189 100755 --- a/clean-app.sh +++ b/clean-app.sh @@ -8,27 +8,32 @@ delete_data() { if defaults read "${bundle_id}" &>/dev/null; then defaults delete "${bundle_id}" fi - rm -rf "${HOME}/Library/Containers/${bundle_id}/Data" + rm -r "${HOME}/Library/Containers/${bundle_id}/Data" echo " Done." } bundle_id= +config_id= case "$1" in debug) bundle_id="com.duckduckgo.macos.browser.debug" + config_ids="*com.duckduckgo.macos.browser.app-configuration.debug" netp_bundle_ids_glob="*com.duckduckgo.macos.browser.network-protection*debug" ;; review) bundle_id="com.duckduckgo.macos.browser.review" + config_ids="*com.duckduckgo.macos.browser.app-configuration.review" netp_bundle_ids_glob="*com.duckduckgo.macos.browser.network-protection*review" ;; debug-appstore) bundle_id="com.duckduckgo.mobile.ios.debug" + config_ids="*com.duckduckgo.mobile.ios.app-configuration.debug" ;; review-appstore) bundle_id="com.duckduckgo.mobile.ios.review" + config_ids="*com.duckduckgo.mobile.ios.app-configuration.review" ;; *) echo "usage: clean-app debug|review|debug-appstore|review-appstore" @@ -38,6 +43,21 @@ esac delete_data "${bundle_id}" +# shellcheck disable=SC2046 +read -r -a config_bundle_ids <<< $( + find "${HOME}/Library/Group Containers/" \ + -type d \ + -maxdepth 1 \ + -name "${config_ids}" \ + -exec basename {} \; +) +for config_id in "${config_bundle_ids[@]}"; do + path="${HOME}/Library/Group Containers/${config_id}" + printf '%s' "Deleting data at ${path}... " + rm -r "${path}" + echo "Done." +done + if [[ -n "${netp_bundle_ids_glob}" ]]; then # shellcheck disable=SC2046 read -r -a netp_bundle_ids <<< $( From 41efeb3e5620b2720ce2354669e42be045e479b8 Mon Sep 17 00:00:00 2001 From: Alexey Martemyanov Date: Tue, 10 Dec 2024 20:11:29 +0600 Subject: [PATCH 2/3] add extra checks and info --- clean-app.sh | 86 +++++++++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 38 deletions(-) diff --git a/clean-app.sh b/clean-app.sh index 70809c1189..648fbf1565 100755 --- a/clean-app.sh +++ b/clean-app.sh @@ -1,44 +1,49 @@ #!/bin/bash delete_data() { - bundle_id="$1" + bundle_id="$1" - printf '%s' "Deleting data for ${bundle_id}..." + printf '%s' "Deleting data for ${bundle_id}..." - if defaults read "${bundle_id}" &>/dev/null; then - defaults delete "${bundle_id}" - fi - rm -r "${HOME}/Library/Containers/${bundle_id}/Data" + if defaults read "${bundle_id}" &>/dev/null; then + defaults delete "${bundle_id}" + fi - echo " Done." + data_path="${HOME}/Library/Containers/${bundle_id}/Data" + if [ -d "${data_path}" ]; then + rm -r "${data_path}" || { echo "Failed to delete ${data_path}"; exit 1; } + echo " Done." + else + printf '\nnothing to do for %s\n' "${data_path}" + fi } bundle_id= config_id= case "$1" in - debug) - bundle_id="com.duckduckgo.macos.browser.debug" + debug) + bundle_id="com.duckduckgo.macos.browser.debug" config_ids="*com.duckduckgo.macos.browser.app-configuration.debug" - netp_bundle_ids_glob="*com.duckduckgo.macos.browser.network-protection*debug" - ;; - review) - bundle_id="com.duckduckgo.macos.browser.review" + netp_bundle_ids_glob="*com.duckduckgo.macos.browser.network-protection*debug" + ;; + review) + bundle_id="com.duckduckgo.macos.browser.review" config_ids="*com.duckduckgo.macos.browser.app-configuration.review" - netp_bundle_ids_glob="*com.duckduckgo.macos.browser.network-protection*review" - ;; - debug-appstore) - bundle_id="com.duckduckgo.mobile.ios.debug" + netp_bundle_ids_glob="*com.duckduckgo.macos.browser.network-protection*review" + ;; + debug-appstore) + bundle_id="com.duckduckgo.mobile.ios.debug" config_ids="*com.duckduckgo.mobile.ios.app-configuration.debug" - ;; - review-appstore) - bundle_id="com.duckduckgo.mobile.ios.review" + ;; + review-appstore) + bundle_id="com.duckduckgo.mobile.ios.review" config_ids="*com.duckduckgo.mobile.ios.app-configuration.review" - ;; - *) - echo "usage: clean-app debug|review|debug-appstore|review-appstore" - exit 1 - ;; + ;; + *) + echo "usage: clean-app debug|review|debug-appstore|review-appstore" + exit 1 + ;; esac delete_data "${bundle_id}" @@ -54,20 +59,25 @@ read -r -a config_bundle_ids <<< $( for config_id in "${config_bundle_ids[@]}"; do path="${HOME}/Library/Group Containers/${config_id}" printf '%s' "Deleting data at ${path}... " - rm -r "${path}" - echo "Done." + if [ -d "${path}" ]; then + rm -r "${path}" || { echo "Failed to delete ${path}"; exit 1; } + echo "Done." + else + printf '\nnothing to do for %s\n' "${path}" + fi + done if [[ -n "${netp_bundle_ids_glob}" ]]; then - # shellcheck disable=SC2046 - read -r -a netp_bundle_ids <<< $( - find "${HOME}/Library/Containers/" \ - -type d \ - -maxdepth 1 \ - -name "${netp_bundle_ids_glob}" \ - -exec basename {} \; - ) - for netp_bundle_id in "${netp_bundle_ids[@]}"; do - delete_data "${netp_bundle_id}" - done + # shellcheck disable=SC2046 + read -r -a netp_bundle_ids <<< $( + find "${HOME}/Library/Containers/" \ + -type d \ + -maxdepth 1 \ + -name "${netp_bundle_ids_glob}" \ + -exec basename {} \; + ) + for netp_bundle_id in "${netp_bundle_ids[@]}"; do + delete_data "${netp_bundle_id}" + done fi From 76a096d70e8b198e16f7004404089ce81fd8b6f7 Mon Sep 17 00:00:00 2001 From: Alexey Martemyanov Date: Tue, 10 Dec 2024 21:03:28 +0600 Subject: [PATCH 3/3] make Nothing start with a capital letter --- clean-app.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clean-app.sh b/clean-app.sh index 648fbf1565..47b624c160 100755 --- a/clean-app.sh +++ b/clean-app.sh @@ -14,7 +14,7 @@ delete_data() { rm -r "${data_path}" || { echo "Failed to delete ${data_path}"; exit 1; } echo " Done." else - printf '\nnothing to do for %s\n' "${data_path}" + printf '\nNothing to do for %s\n' "${data_path}" fi } @@ -63,7 +63,7 @@ for config_id in "${config_bundle_ids[@]}"; do rm -r "${path}" || { echo "Failed to delete ${path}"; exit 1; } echo "Done." else - printf '\nnothing to do for %s\n' "${path}" + printf '\nNothing to do for %s\n' "${path}" fi done