oxedyne/daimond/hand/install/uninstall.sh
1.3 KiB, 1 run
created by r2519314175:909, which is this file's identity for as long as the history lasts, whatever it is later renamed to
download · who wrote it · its history
| 1 | #!/usr/bin/env bash |
| 2 | # |
| 3 | # Unregisters Daimond's machine hand. |
| 4 | # |
| 5 | # Withdrawing the grant in the browser stops Daimond using the hand; this |
| 6 | # removes the browser's ability to start it at all. Both are worth having: the |
| 7 | # first is a decision, the second is a removal. |
| 8 | # |
| 9 | # ./uninstall.sh # every browser found |
| 10 | # ./uninstall.sh --dir DIR # one directory |
| 11 | # |
| 12 | # It removes the JSON manifests only. The binary is left where it is -- this |
| 13 | # script did not put it there and does not know what else uses it. |
| 14 | |
| 15 | set -euo pipefail |
| 16 | |
| 17 | HOST='com.oxedyne.daimond.hand' |
| 18 | HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 19 | |
| 20 | # From `install.sh --paths`, not from a copy of its table. A second list here |
| 21 | # would drift, and the browsers it forgot would keep a registration nobody could |
| 22 | # find -- snap and flatpak profiles are exactly the entries a stale copy misses. |
| 23 | mapfile -t DIRS < <(bash "$HERE/install.sh" --paths) |
| 24 | |
| 25 | if [ "${1:-}" = '--dir' ]; then |
| 26 | DIRS=("${2:?--dir needs a directory}") |
| 27 | fi |
| 28 | |
| 29 | gone=0 |
| 30 | for dir in "${DIRS[@]}"; do |
| 31 | f="$dir/$HOST.json" |
| 32 | if [ -f "$f" ]; then |
| 33 | rm -f "$f" |
| 34 | echo " removed $f" |
| 35 | gone=$((gone + 1)) |
| 36 | fi |
| 37 | done |
| 38 | |
| 39 | if [ "$gone" = 0 ]; then |
| 40 | echo "Nothing to remove: $HOST is not registered with any browser found here." |
| 41 | else |
| 42 | echo |
| 43 | echo "Removed from $gone browser(s). Restart the browser to be sure." |
| 44 | fi |