#!/bin/bash
set -e

# === CONFIGURATION ===
APP_URL="https://forge.xavier.cc/xavier/Peeper/raw/branch/main/Peeper"
APP_PATH="/usr/local/bin/peepinfo"
LOG_FILE="/var/log/peepinfo.log"

# === INSTALL APP ===
echo "➡️  Downloading peepinfo from $APP_URL"
curl -fsSL "$APP_URL" -o "$APP_PATH"
chmod +x "$APP_PATH"

# === EXECUTE NOW ===
echo "🚀 Running peepinfo..."
"$APP_PATH" >> "$LOG_FILE" 2>&1 || echo "⚠️ peepinfo execution failed"

echo "✅ peepinfo installed and executed successfully."