#!/bin/bash
# 🔧 MikroTik RouterOS 6.49.19 - CORRECT Commands for hAP lite
# =============================================================

echo "🎯 CORRECT Commands for RouterOS 6.49.19 (hAP lite)"
echo "===================================================="
echo ""
echo "⚠️  Your RouterOS version uses different command structure!"
echo ""

echo "✅ STEP 1: Check Available Hotspot Commands"
echo "============================================"
echo "First, let's see what hotspot commands are available:"
echo ""
echo "/ip hotspot ?"
echo ""
echo "This will show you all available sub-commands."
echo ""

echo "✅ STEP 2: Try These Alternative Commands"
echo "========================================="
echo "RouterOS 6.49.19 might use 'user' instead of 'user-profile':"
echo ""
echo "# Check if 'user' command exists"
echo "/ip hotspot user ?"
echo ""
echo "# If above works, try:"
echo "/ip hotspot user print"
echo ""

echo "✅ STEP 3: Server Profile Configuration"
echo "======================================="
echo "Try configuring the server profile instead:"
echo ""
echo "# Check server profiles"
echo "/ip hotspot server-profile ?"
echo ""
echo "# Print current profiles"
echo "/ip hotspot server-profile print"
echo ""

echo "✅ STEP 4: Web Interface Method (RECOMMENDED)"
echo "============================================="
echo "Since CLI syntax varies by RouterOS version, use web interface:"
echo ""
echo "1. Open browser: http://192.168.0.173"
echo "2. Login with admin credentials"
echo "3. Go to: IP → Hotspot"
echo "4. Click on 'Server Profiles' tab"
echo "5. Double-click 'default' profile"
echo "6. Configure these settings:"
echo ""
echo "   General Tab:"
echo "   - Login By: Check ONLY 'cookie'"
echo "   - Uncheck: chap, https, trial"
echo ""
echo "   Authentication Tab:"
echo "   - Use Radius: No"
echo "   - HTTP Cookie Authentication URL:"
echo "     https://api.kitonga.klikcell.com/api/mikrotik/auth/"
echo "   - HTTP Cookie Logout URL:"
echo "     https://api.kitonga.klikcell.com/api/mikrotik/logout/"
echo ""
echo "7. Click OK to save"
echo ""

echo "✅ STEP 5: Diagnostic Commands"
echo "=============================="
echo "Run these to understand your hotspot setup:"
echo ""
echo "# Check hotspot status"
echo "/ip hotspot print"
echo ""
echo "# Check what's available under /ip hotspot"
echo "/ip hotspot ?"
echo ""
echo "# Check system info"
echo "/system routerboard print"
echo ""

echo "🔍 TROUBLESHOOTING FOR YOUR ROUTER"
echo "=================================="
echo ""
echo "Your router (hAP lite, RouterOS 6.49.19) might have:"
echo "• Different command syntax"
echo "• Limited hotspot features in older versions"
echo "• Different menu structure"
echo ""
echo "Solutions:"
echo "1. Use web interface (most reliable)"
echo "2. Update RouterOS if possible"
echo "3. Check exact command syntax with '?'"
echo ""

echo "📋 VERIFICATION STEPS"
echo "====================="
echo "After configuration (via web interface):"
echo ""
echo "1. Check hotspot server profile:"
echo "/ip hotspot server-profile print detail"
echo ""
echo "2. Test with real device connection"
echo "3. Monitor Django logs for authentication calls"
echo ""

echo "🎯 NEXT STEPS"
echo "============="
echo "1. Use web interface method above"
echo "2. If successful, test with device"
echo "3. Check Django admin for access logs"
echo "4. Report back with results!"
echo ""

echo "💡 TIP: Web interface is often more reliable than CLI"
echo "for hotspot configuration on older RouterOS versions."
