Files
BackTunnel/scripts/backtunnel-share-tui

33 lines
1.0 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env bash
set -euo pipefail
FOLDER="${1:-}"
[[ -n "$FOLDER" ]] || { echo "Usage: backtunnel-share-tui <folder>"; exit 1; }
read -r -p "Remote (user@host or user:host) [user@vps.example.com]: " REMOTE
REMOTE="${REMOTE:-user@vps.example.com}"
read -r -p "Share duration (30m/2h/1d) [2h]: " DUR
DUR="${DUR:-2h}"
read -r -p "Tunnel port on remote [2222]: " TPORT
TPORT="${TPORT:-2222}"
read -r -p "Local sshd port to expose [22]: " LPORT
LPORT="${LPORT:-22}"
read -r -p "Print invite line for chat? (y/N): " yn
INV=; [[ "${yn,,}" == "y" ]] && INV="-i"
QR=
if [[ -n "$INV" ]]; then
read -r -p "Show QR code for the invite? (y/N): " yq
[[ "${yq,,}" == "y" ]] && QR="--qr"
fi
read -r -p "Invite: suggested mount point [/mnt/remote-rssh]: " MP
MP="${MP:-/mnt/remote-rssh}"
echo
echo "Running: backtunnel-share '$FOLDER' with '$REMOTE' for '$DUR' -p '$TPORT' -l '$LPORT' ${INV:+-i} ${QR:+--qr} --invite-mount '$MP'"
exec backtunnel-share "$FOLDER" with "$REMOTE" for "$DUR" -p "$TPORT" -l "$LPORT" ${INV:+-i} ${QR:+--qr} --invite-mount "$MP"