Files
BackTunnel/scripts/install.sh
sysadminmatmoz fcbd6514cc Add accessor key authorization and enhance completion logic
Introduce `backtunnel-authorize` for managing restricted SFTP-only keys, and update `backtunnel-share` to support temporary accessor key authorization via `--allow-key` and `--allow-known`. Extend bash completion with profile, accessor, and SSH host suggestions. Revamp README sections to include updated workflows, quick starts, and key management details.
2025-09-20 17:17:26 +02:00

101 lines
3.4 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# BackTunnel installer (scripts, man page, completions, Dolphin service menus)
set -euo pipefail
PREFIX=${PREFIX:-/usr}
DESTDIR=${DESTDIR:-}
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' "$@"; }
# --- Create dirs ---
install -d -m 755 "$BINDIR" "$MANDIR" "$KIO_SM" "$KSVC5" "$BCOMP" "$SHARE_DIR" "$APPDIR"
install -d -m 755 "$ETC_DIR"
# --- Install binaries ---
for f in \
scripts/backtunnel-share \
scripts/backtunnel-access \
scripts/backtunnel-share-gui \
scripts/backtunnel-access-gui \
scripts/backtunnel-open-term \
scripts/backtunnel-share-tui \
scripts/backtunnel-access-tui \
scripts/backtunnel-keys \
scripts/backtunnel-authorize \
scripts/backtunnel-auth-setup
do
if [[ -f "$f" ]]; then
install -m 755 "$f" "$BINDIR/$(basename "$f")"
say "Installed $(basename "$f")"
fi
done
# --- Man page ---
if [[ -f man/backtunnel.1 ]]; then
install -m 644 man/backtunnel.1 "$MANDIR/backtunnel.1"
say "Installed man page"
fi
# --- Bash completion (same file serves both commands) ---
if [[ -f completions/backtunnel.bash ]]; then
install -m 644 completions/backtunnel.bash "$BCOMP/backtunnel-share"
install -m 644 completions/backtunnel.bash "$BCOMP/backtunnel-access"
say "Installed bash completions"
fi
# --- Dolphin service menus (Plasma 6 primary, Plasma 5 fallback) ---
if [[ -f servicemenus/backtunnel_share.desktop ]]; then
install -m 644 servicemenus/backtunnel_share.desktop "$KIO_SM/backtunnel_share.desktop"
install -m 644 servicemenus/backtunnel_share.desktop "$KSVC5/backtunnel_share.desktop"
say "Installed Dolphin: Share"
fi
if [[ -f servicemenus/backtunnel_access.desktop ]]; then
install -m 644 servicemenus/backtunnel_access.desktop "$KIO_SM/backtunnel_access.desktop"
install -m 644 servicemenus/backtunnel_access.desktop "$KSVC5/backtunnel_access.desktop"
say "Installed Dolphin: Access"
fi
# --- Optional desktop launcher ---
if [[ -f desktop/backtunnel.desktop ]]; then
install -m 644 desktop/backtunnel.desktop "$APPDIR/backtunnel.desktop"
say "Installed desktop launcher"
fi
# --- Profiles defaults ---
if [[ -f docs/profiles.ini.example ]]; then
install -m 644 docs/profiles.ini.example "$SHARE_DIR/profiles.ini"
# install system default if not present (dont overwrite local admin config)
if [[ ! -f "$ETC_DIR/profiles.ini" ]]; then
install -m 644 docs/profiles.ini.example "$ETC_DIR/profiles.ini"
say "Installed default /etc/backtunnel/profiles.ini"
else
say "Preserved existing /etc/backtunnel/profiles.ini"
fi
fi
# --- Refresh desktop/KDE cache (best-effort; skip during DESTDIR packaging) ---
if [[ -z "${DESTDIR}" ]]; then
if command -v update-desktop-database >/dev/null 2>&1; then
say "Refreshing desktop database..."
update-desktop-database -q || true
fi
if command -v kbuildsycoca6 >/dev/null 2>&1; then
say "Rebuilding KDE sycoca (Plasma 6)..."
kbuildsycoca6 --noincremental >/dev/null 2>&1 || true
elif command -v kbuildsycoca5 >/dev/null 2>&1; then
say "Rebuilding KDE sycoca (Plasma 5)..."
kbuildsycoca5 --noincremental >/dev/null 2>&1 || true
fi
fi
say "Install complete."