Files
BackTunnel/scripts/backtunnel-share-gui

46 lines
1.4 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env bash
# Copyright (c) 2025. LUXIM d.o.o., Slovenia - Matjaž Mozetič.
# GUI wrapper for BackTunnel "Share" action (Dolphin service menu)
# Prompts for parameters via kdialog and launches backtunnel-share in Konsole.
set -euo pipefail
# --- Selection from Dolphin ---
FOLDER="${1:-}"
if [[ -z "$FOLDER" ]]; then
kdialog --error "No folder selected." || true
exit 1
fi
# --- Defaults ---
REMOTE_DEFAULT="user@vps.example.com"
DURATION_DEFAULT="2h"
TPORT_DEFAULT="2222"
LPORT_DEFAULT="22"
INVITE_MOUNT_DEFAULT="/mnt/remote-rssh"
# --- Prompts ---
REMOTE="$(kdialog --inputbox "Remote (user@host or user:host):" "$REMOTE_DEFAULT")" || exit 1
DUR="$(kdialog --combobox "Share duration" 30m 2h 6h 1d 2d --editable "$DURATION_DEFAULT")" || exit 1
TPORT="$(kdialog --inputbox "Tunnel port on remote:" "$TPORT_DEFAULT")" || exit 1
LPORT="$(kdialog --inputbox "Local SSH port to expose:" "$LPORT_DEFAULT")" || exit 1
INV="" # explicit if-then; avoids SC2015 ("A && B || C is not if-then-else")
if kdialog --yesno "Print invite line for chat?"; then
INV="-i"
fi
QR=""
if kdialog --yesno "Show QR code for the invite?"; then
QR="--qr"
fi
MP="$(kdialog --inputbox "Suggested mount point in invite:" "$INVITE_MOUNT_DEFAULT")" || exit 1
# --- Run share in Konsole (keeps session open) ---
exec konsole --noclose -e backtunnel-share \
"$FOLDER" with "$REMOTE" for "$DUR" \
-p "$TPORT" -l "$LPORT" $INV $QR --invite-mount "$MP"