Add `backtunnel-open-term`, `backtunnel-share-tui`, and `backtunnel-access-tui` scripts for terminal-based interaction. Update Dolphin service menus to enable TUI workflows, with improved terminal detection logic. Enhance installation and uninstallation scripts to handle new files. Update README with terminal workflow details and logging information.
70 lines
2.5 KiB
Bash
70 lines
2.5 KiB
Bash
#!/usr/bin/env bash
|
|
# BackTunnel uninstaller (with optional PURGE=1 to remove shared defaults)
|
|
set -euo pipefail
|
|
|
|
PREFIX=${PREFIX:-/usr}
|
|
DESTDIR=${DESTDIR:-}
|
|
PURGE=${PURGE:-0} # set PURGE=1 to remove /usr/share/backtunnel and /etc/backtunnel
|
|
|
|
BINDIR="$DESTDIR$PREFIX/bin"
|
|
MANDIR="$DESTDIR$PREFIX/share/man/man1"
|
|
KIO_SM="$DESTDIR$PREFIX/share/kio/servicemenus"
|
|
KSVC5="$DESTDIR$PREFIX/share/kservices5/ServiceMenus"
|
|
APPDIR="$DESTDIR$PREFIX/share/applications"
|
|
BCOMP="$DESTDIR$PREFIX/share/bash-completion/completions"
|
|
SHARE_DIR="$DESTDIR$PREFIX/share/backtunnel"
|
|
ETC_DIR="$DESTDIR/etc/backtunnel"
|
|
|
|
say() { printf '[BackTunnel] %s\n' "$*"; }
|
|
|
|
say "Uninstalling from PREFIX=${PREFIX} DESTDIR=${DESTDIR} (PURGE=${PURGE})"
|
|
|
|
# --- Remove binaries ---
|
|
rm -f "$BINDIR/backtunnel-share" \
|
|
"$BINDIR/backtunnel-access" \
|
|
"$BINDIR/backtunnel-share-gui" \
|
|
"$BINDIR/backtunnel-access-gui" \
|
|
"$BINDIR/backtunnel-open-term" \
|
|
"$BINDIR/backtunnel-share-tui" \
|
|
"$BINDIR/backtunnel-access-tui"
|
|
|
|
# --- Man page ---
|
|
rm -f "$MANDIR/backtunnel.1"
|
|
|
|
# --- Bash completions ---
|
|
rm -f "$BCOMP/backtunnel-share" \
|
|
"$BCOMP/backtunnel-access"
|
|
|
|
# --- Dolphin service menus (Plasma 6 + legacy) ---
|
|
rm -f "$KIO_SM/backtunnel_share.desktop" \
|
|
"$KIO_SM/backtunnel_access.desktop" \
|
|
"$KSVC5/backtunnel_share.desktop" \
|
|
"$KSVC5/backtunnel_access.desktop"
|
|
|
|
# --- Optional desktop launcher ---
|
|
rm -f "$APPDIR/backtunnel.desktop" || true
|
|
|
|
# --- Shared defaults (only if PURGE=1) ---
|
|
if [[ "$PURGE" = "1" ]]; then
|
|
say "Purging shared defaults under $SHARE_DIR and $ETC_DIR"
|
|
rm -f "$SHARE_DIR/profiles.ini" 2>/dev/null || true
|
|
rm -f "$ETC_DIR/profiles.ini" 2>/dev/null || true
|
|
# Remove directories if empty (and prune empty parents)
|
|
rmdir -p --ignore-fail-on-non-empty "$SHARE_DIR" 2>/dev/null || true
|
|
rmdir -p --ignore-fail-on-non-empty "$ETC_DIR" 2>/dev/null || true
|
|
else
|
|
# Optionally clean up empty share dir if package manager removed files already
|
|
rmdir -p --ignore-fail-on-non-empty "$SHARE_DIR" 2>/dev/null || true
|
|
say "Keeping shared defaults: $SHARE_DIR/ and $ETC_DIR/ (set PURGE=1 to remove)"
|
|
fi
|
|
|
|
# --- Refresh desktop/KDE cache (best-effort) ---
|
|
command -v update-desktop-database >/dev/null 2>&1 && update-desktop-database -q || true
|
|
if command -v kbuildsycoca6 >/dev/null 2>&1; then
|
|
kbuildsycoca6 --noincremental >/dev/null 2>&1 || true
|
|
elif command -v kbuildsycoca5 >/dev/null 2>&1; then
|
|
kbuildsycoca5 --noincremental >/dev/null 2>&1 || true
|
|
fi
|
|
|
|
say "Uninstall complete."
|