61 lines
2.1 KiB
Bash
Executable File
61 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
BINARY="ostiary"
|
|
INSTALL_DIR="$HOME/.local/bin"
|
|
CONFIG_DIR="$HOME/.config/$BINARY"
|
|
|
|
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'
|
|
CYAN='\033[0;36m'; NC='\033[0m'
|
|
|
|
info() { echo -e "${CYAN}[ostiary]${NC} $*"; }
|
|
ok() { echo -e "${GREEN}[ostiary]${NC} $*"; }
|
|
warn() { echo -e "${YELLOW}[ostiary]${NC} $*"; }
|
|
|
|
# ── Remove binary ────────────────────────────────────────────────────────────
|
|
BINARY_PATH="$INSTALL_DIR/$BINARY"
|
|
|
|
if [ -f "$BINARY_PATH" ]; then
|
|
info "Found binary: $BINARY_PATH"
|
|
read -rp " Remove it? [y/N] " answer
|
|
if [[ "$answer" =~ ^[Yy]$ ]]; then
|
|
rm "$BINARY_PATH"
|
|
ok "Binary removed"
|
|
fi
|
|
else
|
|
warn "Binary not found at $BINARY_PATH"
|
|
fi
|
|
|
|
# ── Remove config ────────────────────────────────────────────────────────────
|
|
if [ -d "$CONFIG_DIR" ]; then
|
|
echo ""
|
|
info "Config directory: $CONFIG_DIR"
|
|
read -rp " Remove config and saved settings? [y/N] " answer
|
|
if [[ "$answer" =~ ^[Yy]$ ]]; then
|
|
rm -rf "$CONFIG_DIR"
|
|
ok "Config removed"
|
|
else
|
|
ok "Config kept at $CONFIG_DIR"
|
|
fi
|
|
fi
|
|
|
|
# ── Remove PATH entry from shell profile ─────────────────────────────────────
|
|
for PROFILE in "$HOME/.bashrc" "$HOME/.bash_profile" "$HOME/.profile"; do
|
|
if [ -f "$PROFILE" ] && grep -qF ".local/bin" "$PROFILE"; then
|
|
echo ""
|
|
info "Found PATH entry in $PROFILE"
|
|
read -rp " Remove the PATH line added by ostiary installer? [y/N] " answer
|
|
if [[ "$answer" =~ ^[Yy]$ ]]; then
|
|
# Remove the comment and the export line added by install.sh
|
|
sed -i.bak '/# Added by ostiary installer/d' "$PROFILE"
|
|
sed -i.bak '/\.local\/bin.*PATH/d' "$PROFILE"
|
|
rm -f "${PROFILE}.bak"
|
|
ok "PATH entry removed from $PROFILE"
|
|
fi
|
|
break
|
|
fi
|
|
done
|
|
|
|
echo ""
|
|
ok "Done"
|