#!/bin/sh # # Yaria Desktop App — FreeBSD Uninstall Script # Usage: sh <(curl -fsSL https://yaria.live/uninstall-freebsd.sh) # # Removes the Yaria desktop app from FreeBSD. # No root/sudo required — everything lives under $HOME. # # System packages (webkit2-gtk_41, gtk3, ffmpeg, python3, aria2, mpv) are NOT # removed: they are shared with other software and removing them could break it. # PKG_REMOVE=1 opts in to removing them. # # POSIX sh — FreeBSD's /bin/sh, no bash required. set -u # FreeBSD's default PATH already includes ~/bin INSTALL_DIR="${INSTALL_DIR:-$HOME/bin}" DESKTOP_DIR="$HOME/.local/share/applications" ICON_DIR="$HOME/.local/share/icons/hicolor" USER_DATA_DIR="$HOME/.yaria" USER_CONFIG_DIR="$HOME/.config/yaria" MANTOREX_CONFIG_DIR="$HOME/.config/mantorex" # Optional: also remove the pkg-managed dependencies. PKG_REMOVE="${PKG_REMOVE:-0}" YARIA_PKGS="webkit2-gtk_41 gtk3 dbus ffmpeg python3 aria2 mpv" RED=''; GREEN=''; YELLOW=''; CYAN=''; PURPLE=''; NC='' if [ -t 1 ]; then RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m' CYAN='\033[0;36m'; PURPLE='\033[0;35m'; NC='\033[0m' fi info() { printf '%b\n' "${CYAN}[INFO]${NC} $1"; } ok() { printf '%b\n' "${GREEN}[OK]${NC} $1"; } warn() { printf '%b\n' "${YELLOW}[WARN]${NC} $1"; } printf '\n' printf ' %b\n' "${PURPLE}Yaria Desktop App Uninstaller — FreeBSD${NC}" printf '\n' # --- Stop any running instance --- if pgrep -x yaria-app >/dev/null 2>&1 || pgrep -x yaria-app.bin >/dev/null 2>&1; then info "Stopping running Yaria..." pkill -x yaria-app >/dev/null 2>&1 || true pkill -x yaria-app.bin >/dev/null 2>&1 || true sleep 1 fi # --- Remove installed files --- # The installer creates: yaria-app (launcher), yaria-app.bin (real binary), # freebsd-deps.sh. cp-bsd.sh installs only yaria-app (the raw binary). for f in yaria-app yaria-app.bin yaria-app-real freebsd-deps.sh; do if [ -e "$INSTALL_DIR/$f" ]; then rm -f "$INSTALL_DIR/$f" && ok "Removed ${INSTALL_DIR}/${f}" fi done if [ ! -e "$INSTALL_DIR/yaria-app" ] && [ ! -e "$INSTALL_DIR/yaria-app.bin" ]; then info "No Yaria binary found in ${INSTALL_DIR}" fi # Legacy/system locations for legacy in /usr/local/bin/yaria-app /opt/yaria; do if [ -e "$legacy" ]; then if [ -w "$legacy" ] || [ "$(id -u)" -eq 0 ]; then rm -rf "$legacy" 2>/dev/null && ok "Removed ${legacy}" else warn "Cannot remove ${legacy} (run: sudo rm -rf ${legacy})" fi fi done # --- Remove desktop entry --- if [ -f "$DESKTOP_DIR/yaria.desktop" ]; then rm -f "$DESKTOP_DIR/yaria.desktop" && ok "Removed desktop entry" fi if [ -f "/usr/local/share/applications/yaria.desktop" ] && [ -w "/usr/local/share/applications/yaria.desktop" ]; then rm -f "/usr/local/share/applications/yaria.desktop" && ok "Removed system desktop entry" fi # --- Remove icons --- REMOVED_ICONS=0 for size in 16 32 48 64 128 256 512; do ICON="${ICON_DIR}/${size}x${size}/apps/yaria.png" if [ -f "$ICON" ]; then rm -f "$ICON" REMOVED_ICONS=$((REMOVED_ICONS + 1)) fi done if [ "$REMOVED_ICONS" -gt 0 ]; then ok "Removed ${REMOVED_ICONS} icon files" fi # FreeBSD has no gtk-update-icon-cache; XDG hicolor lookup needs no refresh. # --- User data --- printf '\n' printf ' %b\n' "${YELLOW}Do you also want to remove user data?${NC}" printf '\n' printf ' This includes:\n' printf ' - Download history, media database, thumbnails\n' printf ' - License file, cookies cache\n' printf ' - Settings and configuration\n' printf '\n' printf ' Directories:\n' printf ' %s\n' "$USER_DATA_DIR" printf ' %s\n' "$USER_CONFIG_DIR" printf ' %s\n' "$MANTOREX_CONFIG_DIR" printf '\n' REMOVE_DATA=0 REPLY="" if [ -t 0 ]; then printf ' Remove user data? [y/N]: ' read -r REPLY case "$REPLY" in [Yy]|[Yy][Ee][Ss]) REMOVE_DATA=1 ;; esac else info "Running non-interactively. User data preserved." info "To remove manually: rm -rf ~/.yaria ~/.config/yaria ~/.config/mantorex" fi if [ "$REMOVE_DATA" -eq 1 ]; then rm -rf "$USER_DATA_DIR" 2>/dev/null || true rm -rf "$USER_CONFIG_DIR" 2>/dev/null || true rm -rf "$MANTOREX_CONFIG_DIR" 2>/dev/null || true ok "Removed user data" else info "User data preserved" fi # --- System packages (opt-in) --- printf '\n' if [ "$PKG_REMOVE" = "1" ]; then info "Removing Yaria's system packages (this may affect other software)..." if [ "$(id -u)" -eq 0 ]; then # shellcheck disable=SC2086 pkg delete -y $YARIA_PKGS 2>/dev/null && ok "Packages removed" || warn "pkg delete failed" elif command -v sudo >/dev/null 2>&1; then # shellcheck disable=SC2086 sudo -n pkg delete -y $YARIA_PKGS 2>/dev/null && ok "Packages removed" \ || warn "Could not remove packages (sudo may need a password)" else warn "sudo not found. Remove manually: sudo pkg delete $YARIA_PKGS" fi else info "System packages left in place (they may be used by other software)." info "To remove them too: sudo pkg delete $YARIA_PKGS" fi # --- Done --- printf '\n' printf ' %b\n' "${GREEN}Yaria has been uninstalled.${NC}" printf '\n' printf ' Reinstall with:\n' printf ' %b\n' "${CYAN}sh <(curl -fsSL https://yaria.live/install-freebsd.sh)${NC}" printf '\n'