Add comprehensive inline metadata documentation to all BackTunnel scripts
This commit is contained in:
@@ -1,8 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# Copyright (c) 2025 LUXIM d.o.o., Slovenia
|
||||
# Author: Matjaž Mozetič
|
||||
#
|
||||
# Name: backtunnel-share-tui
|
||||
# Summary: Minimal TUI to start a time-bounded BackTunnel share with optional invite/QR.
|
||||
# Description:
|
||||
# Interactive, terminal-based helper that prompts for remote, duration, ports, and invite options,
|
||||
# then invokes backtunnel-share to create a reverse-SSH tunnel for the selected folder.
|
||||
# Can optionally include a ready-to-copy invite command and QR code for convenience.
|
||||
#
|
||||
# Usage:
|
||||
# backtunnel-share-tui <folder>
|
||||
#
|
||||
# Examples:
|
||||
# backtunnel-share-tui ~/projects
|
||||
#
|
||||
# Dependencies:
|
||||
# - bash
|
||||
# - backtunnel-share (invoked via exec at the end)
|
||||
#
|
||||
# Exit codes:
|
||||
# 0 success (exec replaces this process on success)
|
||||
# 1 invalid usage
|
||||
#
|
||||
# Notes:
|
||||
# - This tool only collects inputs; the actual sharing is done by backtunnel-share.
|
||||
|
||||
set -euo pipefail
|
||||
FOLDER="${1:-}"
|
||||
[[ -n "$FOLDER" ]] || { echo "Usage: backtunnel-share-tui <folder>"; exit 1; }
|
||||
|
||||
# ---- Interactive prompts (with sensible defaults) ----
|
||||
read -r -p "Remote (user@host or user:host) [user@vps.example.com]: " REMOTE
|
||||
REMOTE="${REMOTE:-user@vps.example.com}"
|
||||
|
||||
@@ -15,6 +44,7 @@ TPORT="${TPORT:-2222}"
|
||||
read -r -p "Local sshd port to expose [22]: " LPORT
|
||||
LPORT="${LPORT:-22}"
|
||||
|
||||
# Invite toggles
|
||||
read -r -p "Print invite line for chat? (y/N): " yn
|
||||
INV=; [[ "${yn,,}" == "y" ]] && INV="-i"
|
||||
|
||||
@@ -27,6 +57,8 @@ fi
|
||||
read -r -p "Invite: suggested mount point [/mnt/remote-rssh]: " MP
|
||||
MP="${MP:-/mnt/remote-rssh}"
|
||||
|
||||
# ---- Run the command ----
|
||||
echo
|
||||
echo "Running: backtunnel-share '$FOLDER' with '$REMOTE' for '$DUR' -p '$TPORT' -l '$LPORT' ${INV:+-i} ${QR:+--qr} --invite-mount '$MP'"
|
||||
# Replace this process with backtunnel-share (no return after exec)
|
||||
exec backtunnel-share "$FOLDER" with "$REMOTE" for "$DUR" -p "$TPORT" -l "$LPORT" ${INV:+-i} ${QR:+--qr} --invite-mount "$MP"
|
||||
|
||||
Reference in New Issue
Block a user