#!/bin/bash

# Upload install log(s) to 0x0.st

ARCHINSTALL_LOG="/var/log/archinstall/install.log"
OMARCHY_LOG="/var/log/omarchy-install.log"
COMBINED_LOG="/tmp/combined-install.log"

# Combine whatever logs exist (archinstall first, then omarchy)
cat $ARCHINSTALL_LOG $OMARCHY_LOG >"$COMBINED_LOG" 2>/dev/null

if [ ! -s "$COMBINED_LOG" ]; then
  echo "Error: No install logs found"
  exit 1
fi

echo "Uploading installation log to 0x0.st..."
echo ""

URL=$(curl -sF "file=@$COMBINED_LOG" -Fexpires=24 https://0x0.st)

if [ $? -eq 0 ] && [ -n "$URL" ]; then
  echo "✓ Log uploaded successfully!"
  echo "Share this URL with support:"
  echo ""
  echo "  $URL"
  echo ""
  echo "This link will expire in 24 hours."
else
  echo "Error: Failed to upload log file"
  exit 1
fi
