commit dfdd5231106b1ef7fd25db08fa6a329c22b48abf parent 299acd21e4224f45cdcd07eeedc667c167872255 Author: Sivaldo <gxixtx@xsxixvxaxlxdxoxdxaxvxix.xcxoxm> Date: Sun, 13 Sep 2026 11:20:52 -0300 refactor(scripts): remove script de compartilhamento local share Diffstat:
| D | .local/bin/share | | | 102 | ------------------------------------------------------------------------------- |
1 file changed, 0 insertions(+), 102 deletions(-)
diff --git a/.local/bin/share b/.local/bin/share @@ -1,102 +0,0 @@ -#!/bin/sh - -PORT=8000 - -# Detecta o IP da interface de saída padrão -get_ip() { - # Tenta a rota de saída; fallback para o primeiro IP da máquina - iface=$(ip route get 1.1.1.1 2>/dev/null | awk '{print $5; exit}') - if [ -z "$iface" ]; then - # Fallback para redes sem conectividade externa (isoladas) - hostname -I 2>/dev/null | awk '{print $1; exit}' - return - fi - ip -4 addr show "$iface" 2>/dev/null \ - | awk '/inet / {split($2, a, "/"); print a[1]; exit}' -} - -# Exibe QR Code se qrencode estiver disponível -show_qr() { - if command -v qrencode >/dev/null 2>&1; then - printf '%s' "$1" | qrencode -t ansiutf8 - fi - printf 'URL: %s\n' "$1" -} - -# Inicia o servidor HTTP (download ou upload) -start_server() { - local mode="$1" - - if [ "$mode" = "receive" ]; then - if python3 -m uploadserver --help >/dev/null 2>&1; then - python3 -m uploadserver "$PORT" - else - VENV_DIR="/tmp/share_upload_venv" - if [ ! -d "$VENV_DIR" ]; then - printf 'Criando venv temporário para uploadserver...\n' - python3 -m venv "$VENV_DIR" - "$VENV_DIR/bin/pip" install --quiet uploadserver - fi - printf 'Iniciando servidor de upload...\n' - "$VENV_DIR/bin/python3" -m uploadserver "$PORT" - fi - else - python3 -m http.server "$PORT" - fi -} - -share() { - ip=$(get_ip) || { echo "Erro: IP não detectado." >&2; exit 1; } - [ -z "$ip" ] && { echo "Erro: IP não detectado." >&2; exit 1; } - show_qr "http://$ip:$PORT" - printf 'Servindo pasta atual em: http://%s:%s\n' "$ip" "$PORT" - start_server share -} - -receive() { - ip=$(get_ip) || { echo "Erro: IP não detectado." >&2; exit 1; } - [ -z "$ip" ] && { echo "Erro: IP não detectado." >&2; exit 1; } - show_qr "http://$ip:$PORT/upload" - printf 'Aguardando uploads em: http://%s:%s/upload\n' "$ip" "$PORT" - start_server receive -} - -send() { - [ -z "$1" ] || [ -z "$2" ] && { - echo "Uso: $(basename "$0") send <origem> <destino>" >&2 - exit 1 - } - rsync -avz --progress "$1" "$2" -} - -sharefile() { - [ -z "$1" ] || [ ! -f "$1" ] && { - echo "Erro: arquivo não encontrado." >&2 - exit 1 - } - - filepath=$(realpath "$1") - filename=$(basename "$filepath") - - # Cria diretório temporário com link simbólico para servir apenas o arquivo - tmpdir=$(mktemp -d) || exit 1 - ln -s "$filepath" "$tmpdir/$filename" - - ip=$(get_ip) || { echo "Erro: IP não detectado." >&2; rm -rf "$tmpdir"; exit 1; } - show_qr "http://$ip:$PORT/$filename" - printf 'Servindo arquivo: %s\n' "$filename" - - (cd "$tmpdir" && start_server share) - rm -rf "$tmpdir" -} - -case "${1:-}" in - share) share ;; - receive) receive ;; - send) send "$2" "$3" ;; - file) sharefile "$2" ;; - *) - printf 'Uso: %s {share|receive|send|file} [args...]\n' "$(basename "$0")" - exit 1 - ;; -esac