-
Notifications
You must be signed in to change notification settings - Fork 9
/
clean-app.sh
executable file
·53 lines (45 loc) · 1.14 KB
/
clean-app.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/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"
;;
review-appstore)
bundle_id="com.duckduckgo.mobile.ios.review"
;;
*)
echo "usage: clean-app debug|review|debug-appstore|review-appstore"
exit 1
;;
esac
delete_data "${bundle_id}"
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