Added checkboxes & radio buttons; Updated uninstall script
This commit is contained in:
48
uninstall.sh
48
uninstall.sh
@@ -1,5 +1,4 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
BINARY="ostiary"
|
||||
INSTALL_DIR="$HOME/.local/bin"
|
||||
@@ -12,49 +11,54 @@ info() { echo -e "${CYAN}[ostiary]${NC} $*"; }
|
||||
ok() { echo -e "${GREEN}[ostiary]${NC} $*"; }
|
||||
warn() { echo -e "${YELLOW}[ostiary]${NC} $*"; }
|
||||
|
||||
# Read from /dev/tty so the script works when piped through bash
|
||||
# (e.g. curl ... | bash), where stdin is the pipe, not the terminal.
|
||||
ask() {
|
||||
local answer
|
||||
read -rp "$1 [y/N] " answer </dev/tty
|
||||
[[ "$answer" =~ ^[Yy]$ ]]
|
||||
}
|
||||
|
||||
# ── 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
|
||||
info "Найден бинарник: $BINARY_PATH"
|
||||
if ask " Удалить?"; then
|
||||
rm "$BINARY_PATH"
|
||||
ok "Binary removed"
|
||||
ok "Бинарник удалён"
|
||||
else
|
||||
ok "Бинарник оставлен"
|
||||
fi
|
||||
else
|
||||
warn "Binary not found at $BINARY_PATH"
|
||||
warn "Бинарник не найден в $BINARY_PATH"
|
||||
fi
|
||||
|
||||
# ── Remove config ────────────────────────────────────────────────────────────
|
||||
echo ""
|
||||
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
|
||||
info "Найден конфиг: $CONFIG_DIR"
|
||||
if ask " Удалить конфиг и настройки?"; then
|
||||
rm -rf "$CONFIG_DIR"
|
||||
ok "Config removed"
|
||||
ok "Конфиг удалён"
|
||||
else
|
||||
ok "Config kept at $CONFIG_DIR"
|
||||
ok "Конфиг оставлен: $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
|
||||
if [ -f "$PROFILE" ] && grep -qF "# Added by ostiary installer" "$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"
|
||||
info "Найдена запись PATH в $PROFILE"
|
||||
if ask " Удалить строку PATH, добавленную установщиком?"; then
|
||||
sed -i '/# Added by ostiary installer/d' "$PROFILE"
|
||||
sed -i '/\.local\/bin.*PATH/d' "$PROFILE"
|
||||
ok "Запись PATH удалена из $PROFILE"
|
||||
fi
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
ok "Done"
|
||||
ok "Готово"
|
||||
|
||||
Reference in New Issue
Block a user