#!/usr/bin/env bash # ─── Advanced Auto Root / Sudo / su / Termux Handler ───────────── LOG_FILE="ks-puffer.log" is_root() { [ "$(id -u 2>/dev/null)" = "0" ] } has_sudo() { command -v sudo >/dev/null 2>&1 } has_su() { command -v su >/dev/null 2>&1 } has_curl() { command -v curl >/dev/null 2>&1 } is_termux() { [ -d "/data/data/com.termux" ] || [ -n "$PREFIX" ] } if ! is_root; then echo "🔍 Root not detected..." if has_sudo; then echo "⚡ Switching to root using sudo..." exec sudo bash "$0" "$@" elif has_su; then echo "⚡ Attempting root using su..." exec su -c "bash \"$0\" $*" elif is_termux; then echo "⚠️ Termux detected." echo "❌ Please run this script in a real Linux VPS (Debian/Ubuntu)." exit 1 else echo "❌ Please run this script as root." exit 1 fi fi # ─── KS Warrior PufferPanel Installer ──────────────── echo "==============================================" echo " ⚡ PufferPanel Installer by KS Warrior ⚡" echo "==============================================" # Ensure curl exists if ! has_curl; then echo "Installing curl..." apt-get update -y >> "$LOG_FILE" 2>&1 apt-get install -y curl >> "$LOG_FILE" 2>&1 fi # Add repository echo "Downloading PufferPanel repo..." curl -fsSL https://packagecloud.io/install/repositories/pufferpanel/pufferpanel/script.deb.sh | bash >> "$LOG_FILE" 2>&1 # Install echo "Installing PufferPanel..." export DEBIAN_FRONTEND=noninteractive apt-get update -y >> "$LOG_FILE" 2>&1 apt-get install -y pufferpanel >> "$LOG_FILE" 2>&1 # Add admin user echo "Create User for PufferPanel" if command -v pufferpanel >/dev/null 2>&1; then pufferpanel user add else echo "❌ PufferPanel not installed correctly. Check $LOG_FILE" exit 1 fi # Email directory mkdir -p email echo "{}" > email/emails.json # Start in background echo "Starting PufferPanel..." nohup pufferpanel run >> "$LOG_FILE" 2>&1 < /dev/null & disown 2>/dev/null || true echo "==============================================" echo "✅ Installation Complete!" echo "🌐 Access Panel: http://SERVER-IP:8080" echo "📄 Logs: $LOG_FILE" echo "=============================================="