Complete Rocky Linux 9 - daloRADIUS + FreeRADIUS + 5000 Users


✅ Complete Rocky Linux 9 - daloRADIUS + FreeRADIUS + 5000 Users

Ek Command Mein Complete Setup


📥 Step 1: Copy and Run This ONE Command

bash
curl -fsSL https://pastebin.com/raw/XXXXX | bash

Ya agar internet slow hai to manual script:

bash
cat > /root/full_setup.sh << 'EOF'
#!/bin/bash

# ============================================
# COMPLETE daloRADIUS + FreeRADIUS SETUP
# For Rocky Linux 9
# 5000 MAC Users Ready
# ============================================

set -e
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'

echo -e "${GREEN}"
echo "=========================================="
echo "  daloRADIUS + FreeRADIUS Complete Setup"
echo "         Rocky Linux 9"
echo "=========================================="
echo -e "${NC}"

# Get IP address
SERVER_IP=$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d/ -f1 | head -1)

# ============================================
# PART 1: System Updates & Basic Packages
# ============================================
echo -e "${YELLOW}[1/12] Updating System...${NC}"
dnf update -y

echo -e "${YELLOW}[2/12] Installing Basic Packages...${NC}"
dnf install -y epel-release
dnf install -y httpd mariadb-server mariadb php php-mysqlnd php-gd \
    php-mbstring php-xml wget unzip tar freeradius freeradius-mysql \
    freeradius-utils php-pear net-tools

# ============================================
# PART 2: Start Services
# ============================================
echo -e "${YELLOW}[3/12] Starting Services...${NC}"
systemctl enable --now httpd mariadb

# ============================================
# PART 3: MySQL Setup
# ============================================
echo -e "${YELLOW}[4/12] Configuring MySQL...${NC}"
mysqladmin -u root password 'Radius@123'

mysql -u root -pRadius@123 << 'MYSQL'
CREATE DATABASE radius;
CREATE USER 'radius'@'localhost' IDENTIFIED BY 'Radius@123';
GRANT ALL PRIVILEGES ON radius.* TO 'radius'@'localhost';
FLUSH PRIVILEGES;
MYSQL

# ============================================
# PART 4: FreeRADIUS Schema
# ============================================
echo -e "${YELLOW}[5/12] Loading FreeRADIUS Schema...${NC}"
mysql -u root -pRadius@123 radius < /etc/raddb/mods-config/sql/main/mysql/schema.sql

# ============================================
# PART 5: PEAR DB Installation
# ============================================
echo -e "${YELLOW}[6/12] Installing PEAR DB...${NC}"
pear install DB

# ============================================
# PART 6: daloRADIUS Installation
# ============================================
echo -e "${YELLOW}[7/12] Installing daloRADIUS...${NC}"
cd /var/www/html
wget -q https://github.com/lirantal/daloradius/archive/refs/heads/master.zip
unzip -q master.zip
mv daloradius-master daloradius

# Load daloRADIUS schema
mysql -u root -pRadius@123 radius < /var/www/html/daloradius/contrib/db/mariadb-daloradius.sql

# ============================================
# PART 7: daloRADIUS Configuration
# ============================================
echo -e "${YELLOW}[8/12] Configuring daloRADIUS...${NC}"
cp /var/www/html/daloradius/app/common/includes/daloradius.conf.php.sample \
   /var/www/html/daloradius/app/common/includes/daloradius.conf.php

sed -i "s/\$configValues\['CONFIG_DB_USER'\] = '.*';/\$configValues\['CONFIG_DB_USER'\] = 'radius';/" \
    /var/www/html/daloradius/app/common/includes/daloradius.conf.php

sed -i "s/\$configValues\['CONFIG_DB_PASS'\] = '.*';/\$configValues\['CONFIG_DB_PASS'\] = 'Radius@123';/" \
    /var/www/html/daloradius/app/common/includes/daloradius.conf.php

sed -i "s/\$configValues\['CONFIG_DB_NAME'\] = '.*';/\$configValues\['CONFIG_DB_NAME'\] = 'radius';/" \
    /var/www/html/daloradius/app/common/includes/daloradius.conf.php

# Create library directory and copy config
mkdir -p /var/www/html/daloradius/library
cp /var/www/html/daloradius/app/common/includes/daloradius.conf.php \
   /var/www/html/daloradius/library/

# ============================================
# PART 8: PHP Configuration
# ============================================
echo -e "${YELLOW}[9/12] Configuring PHP...${NC}"
sed -i 's/short_open_tag = Off/short_open_tag = On/' /etc/php.ini
sed -i 's/memory_limit = 128M/memory_limit = 256M/' /etc/php.ini
sed -i 's/max_execution_time = 30/max_execution_time = 300/' /etc/php.ini

# ============================================
# PART 9: Permissions & SELinux
# ============================================
echo -e "${YELLOW}[10/12] Setting Permissions...${NC}"
chown -R apache:apache /var/www/html/daloradius
chmod -R 755 /var/www/html/daloradius

# SELinux
setenforce 0
setsebool -P httpd_can_network_connect_db 1

# ============================================
# PART 10: Firewall
# ============================================
echo -e "${YELLOW}[11/12] Configuring Firewall...${NC}"
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-port=1812/udp
firewall-cmd --permanent --add-port=1813/udp
firewall-cmd --reload

# ============================================
# PART 11: Generate 5000 Users
# ============================================
echo -e "${YELLOW}[12/12] Generating 5000 MAC Users...${NC}"

cat > /tmp/gen_users.py << 'PYTHON'
#!/usr/bin/env python3
import mysql.connector
import random

db = mysql.connector.connect(
    host="localhost",
    user="radius",
    password="Radius@123",
    database="radius"
)
cursor = db.cursor()

def random_mac():
    return ''.join(f'{random.randint(0,255):02x}' for _ in range(6))

print("Generating 5000 users...")

for i in range(5000):
    mac = random_mac()
    password = f"g{random.randint(100,999)}"
    
    cursor.execute("INSERT INTO radcheck (username, attribute, op, value) VALUES (%s, 'Cleartext-Password', ':=', %s)", (mac, password))
    cursor.execute("INSERT INTO radusergroup (username, groupname, priority) VALUES (%s, 'hotspot-users', 1)", (mac,))
    
    if i % 500 == 0:
        db.commit()
        print(f"Progress: {i}/5000")

db.commit()
print(f"✅ Done! 5000 users added successfully!")
PYTHON

python3 /tmp/gen_users.py

# ============================================
# PART 12: Restart Services
# ============================================
echo -e "${YELLOW}Restarting Services...${NC}"
systemctl restart httpd php-fpm
systemctl enable radiusd

# ============================================
# FINAL OUTPUT
# ============================================
echo ""
echo -e "${GREEN}"
echo "=========================================="
echo "        ✅ SETUP COMPLETE! ✅"
echo "=========================================="
echo -e "${NC}"
echo "📍 Access URL:"
echo "   http://$SERVER_IP/daloradius/app/operators/login.php"
echo ""
echo "🔑 Login Credentials:"
echo "   Username: administrator"
echo "   Password: radius"
echo ""
echo "📊 Users Created: 5000 MAC users"
echo "   Format: username=MAC address, password=gXXX"
echo ""
echo "🔧 Services Status:"
systemctl is-active httpd && echo "   ✅ Apache: Running" || echo "   ❌ Apache: Stopped"
systemctl is-active mariadb && echo "   ✅ MySQL: Running" || echo "   ❌ MySQL: Stopped"
systemctl is-active radiusd && echo "   ✅ FreeRADIUS: Running" || echo "   ❌ FreeRADIUS: Stopped"
echo ""
echo "=========================================="
EOF

chmod +x /root/full_setup.sh
/root/full_setup.sh

🚀 For New VM - Just Copy & Paste This:

bash
curl -fsSL https://raw.githubusercontent.com/lirantal/daloradius/master/contrib/scripts/install.sh | bash

Ya agar manual script chahiye to upar wala copy karo.


📝 After Setup - What You Get:

ItemDetail
Web Interfacehttp://SERVER_IP/daloradius/app/operators/login.php
Usernameadministrator
Passwordradius
Users5000 MAC users (username=MAC, password=gXXX)
Databaseradius (user: radius, pass: Radius@123)

🔧 Backup & Restore Commands:

bash
# Backup
mysqldump -u root -pRadius@123 radius > backup.sql
tar -czf daloradius_backup.tar.gz /var/www/html/daloradius/

# Restore
mysql -u root -pRadius@123 radius < backup.sql
tar -xzf daloradius_backup.tar.gz -C /

✅ One Line Summary:

Naye Rocky Linux 9 VM pe bas ye command run karo:

bash
curl -fsSL https://pastebin.com/raw/XXXXX | bash

(Agar pastebin link chahiye to batao, ya upar wala manual script copy karo)

Comments

Popular posts from this blog

Windows 11 rdp problem resolved

Microsoft Activation Scripts (MAS)

Windows 11 ke common RDP issues fix karta hai