Quản lý qua CLI Tool

Command Line

CLI tool (whitelabel_cli.py) cung cấp cách quản lý nhanh và mạnh mẽ các White-Label instances trực tiếp từ command line, phù hợp cho automation và scripting.

Cú pháp cơ bản

Syntax
python3 whitelabel_cli.py <command> [options]

Các lệnh CLI

init - Khởi tạo hệ thống

Tạo shared directory, symlinks và systemd template

python3 whitelabel_cli.py init

Output mong đợi:

Initializing White-Label system...
✓ Created shared directory
✓ Created symlinks
✓ Created systemd template
✓ System initialized successfully

list - Liệt kê instances

Hiển thị danh sách tất cả instances với status

python3 whitelabel_cli.py list

Output mẫu:

White-Label Instances:

ID                                       Name                 Port     Status    
--------------------------------------------------------------------------------
a1b2c3d4-5678-90ab-cdef-1234567890ab    Customer A           9001     active    
b2c3d4e5-6789-01bc-def0-234567890abc    Customer B           9002     inactive  
c3d4e5f6-7890-12cd-ef01-34567890abcd    Customer C           9003     active

create - Tạo instance mới

Tạo và khởi động instance mới với cấu hình chi tiết

Cú pháp đầy đủ:

python3 whitelabel_cli.py create \
  --name "<Instance Name>" \
  --username <admin_username> \
  --password <admin_password> \
  --port <port_number> \
  [--with-openvpn]
OptionMô tảBắt buộc
--nameTên instance
Yes
--usernameAdmin username
Yes
--passwordAdmin password
Yes
--portPort number
Yes
--with-openvpnEnable OpenVPN
Optional

Ví dụ 1: Instance không có OpenVPN

python3 whitelabel_cli.py create \
  --name "Customer A Panel" \
  --username admin \
  --password SecurePass123 \
  --port 9001

Ví dụ 2: Instance có OpenVPN

python3 whitelabel_cli.py create \
  --name "Customer B Panel" \
  --username admin_b \
  --password SecurePass456 \
  --port 9002 \
  --with-openvpn

Output thành công:

Creating instance 'Customer A Panel'...
✓ Instance created successfully!
Instance ID: a1b2c3d4-5678-90ab-cdef-1234567890ab
Name: Customer A Panel
Port: 9001
Admin Username: admin
Has OpenVPN: False

start - Khởi động instance

Start một instance đã dừng

python3 whitelabel_cli.py start --instance-id <uuid>

# Ví dụ:
python3 whitelabel_cli.py start --instance-id a1b2c3d4-5678-90ab-cdef-1234567890ab
Starting instance a1b2c3d4-5678-90ab-cdef-1234567890ab...
✓ Instance started successfully!

stop - Dừng instance

Stop một instance đang chạy

python3 whitelabel_cli.py stop --instance-id <uuid>

# Output:
Stopping instance a1b2c3d4-5678-90ab-cdef-1234567890ab...
✓ Instance stopped successfully!

restart - Restart instance

Restart instance để apply changes

python3 whitelabel_cli.py restart --instance-id <uuid>

# Output:
Restarting instance a1b2c3d4-5678-90ab-cdef-1234567890ab...
✓ Instance restarted successfully!

info - Xem thông tin chi tiết

Hiển thị thông tin đầy đủ về một instance

python3 whitelabel_cli.py info --instance-id <uuid>

Output mẫu:

Instance Information:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ID:              a1b2c3d4-5678-90ab-cdef-1234567890ab
Name:            Customer A Panel
Port:            9001
Status:          active
Admin Username:  admin
Has OpenVPN:     False
Created:         2025-11-15 10:30:45
Updated:         2025-11-17 14:22:10

Statistics:
  Users:         125
  Nodes:         3
  Active Users:  98

delete - Xóa instance

Xóa instance vĩnh viễn (có confirm)

Với confirmation:

python3 whitelabel_cli.py delete --instance-id <uuid>

# Hệ thống sẽ hỏi:
Are you sure you want to delete instance 'Customer A Panel'? (y/n): y
Deleting instance a1b2c3d4-5678-90ab-cdef-1234567890ab...
✓ Instance deleted successfully!

Force delete (không hỏi):

python3 whitelabel_cli.py delete --instance-id <uuid> --force

Use Cases thực tế

Batch Operations - Tạo nhiều instances

Batch Create Script
#!/bin/bash
# create_multiple_instances.sh

# Array of customer data
declare -a customers=(
  "CompanyA:admin_a:Pass123:9001"
  "CompanyB:admin_b:Pass456:9002"
  "CompanyC:admin_c:Pass789:9003"
)

# Loop và create
for customer in "${customers[@]}"; do
  IFS=':' read -r name username password port <<< "$customer"
  
  echo "Creating instance for $name..."
  python3 /opt/ov-panel/whitelabel_cli.py create \
    --name "$name Panel" \
    --username "$username" \
    --password "$password" \
    --port "$port"
  
  sleep 5
done

echo "All instances created!"

Health Check Script

Health Check Script
#!/bin/bash
# health_check.sh

# Get all instances
instances=$(python3 /opt/ov-panel/whitelabel_cli.py list | grep -E '^[a-f0-9-]{36}' | awk '{print $1}')

for uuid in $instances; do
  # Get instance info
  info=$(python3 /opt/ov-panel/whitelabel_cli.py info --instance-id $uuid)
  
  # Check status
  status=$(echo "$info" | grep "Status:" | awk '{print $2}')
  
  if [ "$status" != "active" ]; then
    echo "WARNING: Instance $uuid is $status"
    # Send alert or restart
    python3 /opt/ov-panel/whitelabel_cli.py start --instance-id $uuid
  fi
done

Auto Restart Script (Maintenance)

Weekly Restart Script
#!/bin/bash
# auto_restart.sh
# Crontab: 0 3 * * 0 /opt/scripts/auto_restart.sh

echo "Starting weekly maintenance restart..."

# Get all active instances
instances=$(python3 /opt/ov-panel/whitelabel_cli.py list | grep 'active' | awk '{print $1}')

for uuid in $instances; do
  echo "Restarting instance $uuid..."
  python3 /opt/ov-panel/whitelabel_cli.py restart --instance-id $uuid
  sleep 10
done

echo "Maintenance complete!"

Tips & Tricks