Skip to content

Commit

Permalink
Update clean-app.sh to work on macOS Sonoma and include NetP containe…
Browse files Browse the repository at this point in the history
…rs (#1988)

Task/Issue URL: https://app.asana.com/0/1201037661562251/1205976611183945/f

Description:
Update the script to actually only remove the Data subdirectory of the container.
Also update to find NetP containers and clear them the same way.
  • Loading branch information
ayoy authored Dec 19, 2023
1 parent fa6b08e commit d30f00b
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions clean-app.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
#!/bin/bash

delete_data() {
bundle_id="$1"

printf '%s' "Deleting data for ${bundle_id}..."

if defaults read "${bundle_id}" &>/dev/null; then
defaults delete "${bundle_id}"
fi
rm -rf "${HOME}/Library/Containers/${bundle_id}/Data"

echo " Done."
}

bundle_id=

case "$1" in
debug)
bundle_id="com.duckduckgo.macos.browser.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*review"
;;
debug-appstore)
bundle_id="com.duckduckgo.mobile.ios.debug"
Expand All @@ -21,9 +36,18 @@ case "$1" in
;;
esac

printf '%s' "Removing data for ${bundle_id}..."

defaults delete "${bundle_id}"
rm -rf "${HOME}/Library/Containers/${bundle_id}"
delete_data "${bundle_id}"

echo " 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
fi

0 comments on commit d30f00b

Please sign in to comment.