export-notes/bin/uninstall.sh
2025-05-12 23:24:36 +03:00

49 lines
908 B
Bash
Executable file

#!/bin/bash
set -euo pipefail
DEBUG=false
ROOT_SRC=".."
TARGET_NAME="export-notes"
PREFIX="${PREFIX:-/usr/local}"
INSTALL_PATH="$PREFIX/bin/$TARGET_NAME"
while [[ $# -gt 0 ]]; do
case "$1" in
--debug)
DEBUG=true
shift
;;
--prefix)
PREFIX="$2"
INSTALL_PATH="$PREFIX/bin/$TARGET_NAME"
shift 2
;;
--help|-h)
echo "Usage: $0 [--prefix /custom/bin/path]" >&2
exit 0
;;
*)
echo "Unknown option $1" >&2
exit 1
;;
esac
done
if [[ "$DEBUG" == true ]]; then
echo "ROOT_SRC=$ROOT_SRC"
echo "TARGET_NAME=$TARGET_NAME"
echo "PREFIX=$PREFIX"
echo "INSTALL_PATH=$INSTALL_PATH"
fi
# check and remove
if [[ ! -f "$INSTALL_PATH" ]]; then
echo "$INSTALL_PATH not found. Nothing to uninstall."
exit 1
fi
echo "🗑️ Removing $INSTALL_PATH ..."
sudo rm "$INSTALL_PATH"
echo "✅ Uninstalled successfully."