#!/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 " 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