Files
Nomarchy/features/scripts/utils/nomarchy-upload-log
Bernardo Magri 1e6becd42d
All checks were successful
Check / eval-and-lint (push) Successful in 7m5s
fix(scripts): improve offline resilience and restore missing update scripts
2026-06-01 20:07:08 +01:00

32 lines
791 B
Bash
Executable File

#!/usr/bin/env bash
# Nomarchy Log Upload Script
# Uploads stdin or a file to a pastebin service.
set -e
if [[ -t 0 ]] && [[ -z $1 ]]; then
echo "Usage: some-command | nomarchy-upload-log"
echo " nomarchy-upload-log <file>"
exit 1
fi
# Use ix.io as the default pastebin
if [[ -n $1 ]]; then
# --connect-timeout 5: fail fast if ix.io is unreachable
url=$(curl -s --connect-timeout 5 -F "f:1=@$1" ix.io || echo "OFFLINE")
else
url=$(curl -s --connect-timeout 5 -F "f:1=@-" ix.io || echo "OFFLINE")
fi
if [[ "$url" == "OFFLINE" ]]; then
echo "Error: Could not upload log. Check your internet connection."
exit 1
fi
echo "Log uploaded to: $url"
if command -v wl-copy &>/dev/null; then
echo "$url" | wl-copy
echo "Link copied to clipboard."
fi