#!/bin/sh # Denshin uninstaller, served at https://denshin.dev/uninstall: # # curl -fsSL https://denshin.dev/uninstall | sh # # On a Mac, it quits Denshin and removes Denshin.app from Applications. Then, # on any machine, it hands over to the command line's own `denshin uninstall`: # the background service, the command and its toolchain go, your sessions' # state stays in ~/.denshind, unless: # DENSHIN_PURGE=1 removes that state too (`denshin uninstall --purge --yes`) # DENSHIN_APP_DIR=./there removes the app from that folder instead of # Applications; nothing is quit # # The whole script is one function, called on its last line: `curl | sh` reads # it to the end before anything runs. set -eu main() { BUNDLE_ID="run.denshin.accounts" SITE="https://denshin.dev" [ "$(id -u)" != 0 ] || fail "run this as yourself, without sudo: curl -fsSL $SITE/uninstall | sh" if [ "$(uname -s)" = Darwin ]; then if [ -n "${DENSHIN_APP_DIR:-}" ]; then apps="$DENSHIN_APP_DIR/Denshin.app" else apps="/Applications/Denshin.app $HOME/Applications/Denshin.app" osascript -e "tell application id \"$BUNDLE_ID\" to quit" >/dev/null 2>&1 || true for _ in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do running || break sleep 0.5 done ! running || fail "Denshin is still running 10 seconds after it was asked to quit: quit it from its menu, then run this again. Nothing was removed." fi for app in $apps; do [ ! -d "$app" ] || { rm -rf "$app" && say "Removed $app"; } done fi cli="${DENSHIN_INSTALL_ROOT:-$HOME/.denshin}/bin/denshin" [ -x "$cli" ] || cli=$(command -v denshin 2>/dev/null || true) if [ -n "$cli" ]; then if [ "${DENSHIN_PURGE:-}" = 1 ]; then "$cli" uninstall --purge --yes else "$cli" uninstall say "Your sessions' state is still in ~/.denshind" say "To remove it too: curl -fsSL $SITE/uninstall | DENSHIN_PURGE=1 sh" fi fi say "Denshin is uninstalled." } say() { printf '%s\n' "$*"; } fail() { printf '%s\n' "denshin: $*" >&2; exit 1; } running() { [ "$(osascript -e "application id \"$BUNDLE_ID\" is running" 2>/dev/null || echo false)" = true ]; } main "$@"