mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-12-20 15:29:43 +01:00
Fix password handling in CyberPanel installer
- Capture actual generated password from CyberPanel installation output - Save generated password to /root/.cyberpanel_password for persistence - Use captured password for OpenLiteSpeed admin configuration - Update status summary to show actual password instead of hardcoded value - Fix service check to use lscpd (actual CyberPanel service) instead of non-existent 'cyberpanel' service - Add lscpd service status check in installation summary This ensures the password shown in the summary matches the actual CyberPanel admin password.
This commit is contained in:
100
cyberpanel.sh
100
cyberpanel.sh
@@ -244,8 +244,20 @@ fix_post_install_issues() {
|
|||||||
mysql -e "GRANT ALL PRIVILEGES ON cyberpanel.* TO 'cyberpanel'@'localhost';" 2>/dev/null || true
|
mysql -e "GRANT ALL PRIVILEGES ON cyberpanel.* TO 'cyberpanel'@'localhost';" 2>/dev/null || true
|
||||||
mysql -e "FLUSH PRIVILEGES;" 2>/dev/null || true
|
mysql -e "FLUSH PRIVILEGES;" 2>/dev/null || true
|
||||||
|
|
||||||
# Set unified password for both CyberPanel and OpenLiteSpeed
|
# Get or set unified password for both CyberPanel and OpenLiteSpeed
|
||||||
local unified_password="1234567"
|
local unified_password=""
|
||||||
|
if [ -f "/root/.cyberpanel_password" ]; then
|
||||||
|
unified_password=$(cat /root/.cyberpanel_password 2>/dev/null)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If no password was captured from installation, use default
|
||||||
|
if [ -z "$unified_password" ]; then
|
||||||
|
unified_password="1234567"
|
||||||
|
# Save password to file for later retrieval
|
||||||
|
echo "$unified_password" > /root/.cyberpanel_password 2>/dev/null || true
|
||||||
|
chmod 600 /root/.cyberpanel_password 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
echo " Setting unified password for CyberPanel and OpenLiteSpeed..."
|
echo " Setting unified password for CyberPanel and OpenLiteSpeed..."
|
||||||
echo " Password: $unified_password"
|
echo " Password: $unified_password"
|
||||||
|
|
||||||
@@ -683,7 +695,7 @@ install_cyberpanel_direct() {
|
|||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Run installer and show live output
|
# Run installer and show live output, capturing the password
|
||||||
if [ "$DEBUG_MODE" = true ]; then
|
if [ "$DEBUG_MODE" = true ]; then
|
||||||
./cyberpanel_installer.sh --debug 2>&1 | tee /var/log/CyberPanel/install_output.log
|
./cyberpanel_installer.sh --debug 2>&1 | tee /var/log/CyberPanel/install_output.log
|
||||||
else
|
else
|
||||||
@@ -692,6 +704,14 @@ install_cyberpanel_direct() {
|
|||||||
|
|
||||||
local install_exit_code=${PIPESTATUS[0]}
|
local install_exit_code=${PIPESTATUS[0]}
|
||||||
|
|
||||||
|
# Extract the generated password from the installation output
|
||||||
|
local generated_password=$(grep "Panel password:" /var/log/CyberPanel/install_output.log | awk '{print $NF}')
|
||||||
|
if [ -n "$generated_password" ]; then
|
||||||
|
echo "Captured CyberPanel password: $generated_password"
|
||||||
|
echo "$generated_password" > /root/.cyberpanel_password
|
||||||
|
chmod 600 /root/.cyberpanel_password
|
||||||
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "==============================================================================================================="
|
echo "==============================================================================================================="
|
||||||
echo " INSTALLATION COMPLETED"
|
echo " INSTALLATION COMPLETED"
|
||||||
@@ -774,18 +794,25 @@ install_cyberpanel_direct() {
|
|||||||
apply_fixes() {
|
apply_fixes() {
|
||||||
print_status "Applying installation fixes..."
|
print_status "Applying installation fixes..."
|
||||||
|
|
||||||
|
# Get the actual password that was generated during installation
|
||||||
|
local admin_password=""
|
||||||
|
if [ -f "/root/.cyberpanel_password" ]; then
|
||||||
|
admin_password=$(cat /root/.cyberpanel_password 2>/dev/null)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If no password was captured, generate a new one
|
||||||
|
if [ -z "$admin_password" ]; then
|
||||||
|
admin_password=$(openssl rand -base64 12)
|
||||||
|
echo "$admin_password" > /root/.cyberpanel_password
|
||||||
|
chmod 600 /root/.cyberpanel_password
|
||||||
|
print_status "Generated new admin password: $admin_password"
|
||||||
|
else
|
||||||
|
print_status "Using CyberPanel generated password: $admin_password"
|
||||||
|
fi
|
||||||
|
|
||||||
# Fix database issues
|
# Fix database issues
|
||||||
systemctl start mariadb 2>/dev/null || true
|
systemctl start mariadb 2>/dev/null || true
|
||||||
systemctl enable mariadb 2>/dev/null || true
|
systemctl enable mariadb 2>/dev/null || true
|
||||||
mysqladmin -u root password '1234567' 2>/dev/null || true
|
|
||||||
|
|
||||||
# Create cyberpanel database user
|
|
||||||
mysql -u root -p1234567 -e "
|
|
||||||
CREATE DATABASE IF NOT EXISTS cyberpanel;
|
|
||||||
CREATE USER IF NOT EXISTS 'cyberpanel'@'localhost' IDENTIFIED BY 'cyberpanel';
|
|
||||||
GRANT ALL PRIVILEGES ON cyberpanel.* TO 'cyberpanel'@'localhost';
|
|
||||||
FLUSH PRIVILEGES;
|
|
||||||
" 2>/dev/null || true
|
|
||||||
|
|
||||||
# Fix LiteSpeed service
|
# Fix LiteSpeed service
|
||||||
cat > /etc/systemd/system/lsws.service << 'EOF'
|
cat > /etc/systemd/system/lsws.service << 'EOF'
|
||||||
@@ -812,39 +839,19 @@ EOF
|
|||||||
systemctl start lsws
|
systemctl start lsws
|
||||||
|
|
||||||
# Set OpenLiteSpeed admin password to match CyberPanel
|
# Set OpenLiteSpeed admin password to match CyberPanel
|
||||||
local unified_password="1234567"
|
|
||||||
echo "Setting OpenLiteSpeed admin password..."
|
echo "Setting OpenLiteSpeed admin password..."
|
||||||
if [ -f "/usr/local/lsws/admin/misc/admpass.sh" ]; then
|
if [ -f "/usr/local/lsws/admin/misc/admpass.sh" ]; then
|
||||||
/usr/local/lsws/admin/misc/admpass.sh -u admin -p "$unified_password" 2>/dev/null || {
|
/usr/local/lsws/admin/misc/admpass.sh -u admin -p "$admin_password" 2>/dev/null || {
|
||||||
echo "OpenLiteSpeed password set via alternative method..."
|
echo "OpenLiteSpeed password set via alternative method..."
|
||||||
# Alternative method: directly create htpasswd entry
|
# Alternative method: directly create htpasswd entry
|
||||||
echo "admin:$(openssl passwd -apr1 '$unified_password')" > /usr/local/lsws/admin/htpasswd 2>/dev/null || true
|
echo "admin:$(openssl passwd -apr1 '$admin_password')" > /usr/local/lsws/admin/htpasswd 2>/dev/null || true
|
||||||
}
|
}
|
||||||
echo "✓ OpenLiteSpeed admin password set to: $unified_password"
|
echo "✓ OpenLiteSpeed admin password set to: $admin_password"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Fix CyberPanel service
|
# Ensure CyberPanel (lscpd) service is running
|
||||||
cat > /etc/systemd/system/cyberpanel.service << 'EOF'
|
systemctl enable lscpd 2>/dev/null || true
|
||||||
[Unit]
|
systemctl start lscpd 2>/dev/null || true
|
||||||
Description=CyberPanel Web Interface
|
|
||||||
After=network.target mariadb.service
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=simple
|
|
||||||
User=root
|
|
||||||
Group=root
|
|
||||||
WorkingDirectory=/usr/local/CyberCP
|
|
||||||
ExecStart=/usr/local/CyberPanel-venv/bin/python manage.py runserver 0.0.0.0:8000
|
|
||||||
Restart=always
|
|
||||||
RestartSec=5
|
|
||||||
Environment=DJANGO_SETTINGS_MODULE=CyberCP.settings
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
EOF
|
|
||||||
|
|
||||||
systemctl daemon-reload
|
|
||||||
systemctl enable cyberpanel
|
|
||||||
|
|
||||||
print_status "SUCCESS: All fixes applied successfully"
|
print_status "SUCCESS: All fixes applied successfully"
|
||||||
}
|
}
|
||||||
@@ -873,12 +880,13 @@ show_status_summary() {
|
|||||||
echo "ERROR: LiteSpeed Web Server - NOT RUNNING"
|
echo "ERROR: LiteSpeed Web Server - NOT RUNNING"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if systemctl is-active --quiet cyberpanel; then
|
if systemctl is-active --quiet lscpd; then
|
||||||
echo "SUCCESS: CyberPanel Application - RUNNING"
|
echo "SUCCESS: CyberPanel Application - RUNNING"
|
||||||
else
|
else
|
||||||
echo "ERROR: CyberPanel Application - NOT RUNNING"
|
echo "ERROR: CyberPanel Application - NOT RUNNING"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "NETWORK PORTS STATUS:"
|
echo "NETWORK PORTS STATUS:"
|
||||||
echo "--------------------------------------------------------------------------------"
|
echo "--------------------------------------------------------------------------------"
|
||||||
@@ -896,6 +904,14 @@ show_status_summary() {
|
|||||||
echo "ERROR: Port 80 (HTTP) - NOT LISTENING"
|
echo "ERROR: Port 80 (HTTP) - NOT LISTENING"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Get the actual password that was set
|
||||||
|
local admin_password="1234567" # Default password
|
||||||
|
|
||||||
|
# Check if password was set in /root/.cyberpanel_password (if it exists)
|
||||||
|
if [ -f "/root/.cyberpanel_password" ]; then
|
||||||
|
admin_password=$(cat /root/.cyberpanel_password 2>/dev/null) || admin_password="1234567"
|
||||||
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "SUMMARY:"
|
echo "SUMMARY:"
|
||||||
echo "--------------------------------------------------------------------------------"
|
echo "--------------------------------------------------------------------------------"
|
||||||
@@ -903,11 +919,11 @@ show_status_summary() {
|
|||||||
echo ""
|
echo ""
|
||||||
echo "Access CyberPanel at: http://your-server-ip:8090"
|
echo "Access CyberPanel at: http://your-server-ip:8090"
|
||||||
echo "Default username: admin"
|
echo "Default username: admin"
|
||||||
echo "Default password: 1234567"
|
echo "Default password: $admin_password"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Access OpenLiteSpeed at: http://your-server-ip:7080"
|
echo "Access OpenLiteSpeed at: http://your-server-ip:7080"
|
||||||
echo "Default username: admin"
|
echo "Default username: admin"
|
||||||
echo "Default password: 1234567 (same as CyberPanel)"
|
echo "Default password: $admin_password (same as CyberPanel)"
|
||||||
echo ""
|
echo ""
|
||||||
echo "IMPORTANT: Change the default password immediately!"
|
echo "IMPORTANT: Change the default password immediately!"
|
||||||
echo ""
|
echo ""
|
||||||
@@ -1448,7 +1464,7 @@ show_system_status() {
|
|||||||
echo " ERROR: LiteSpeed - Not Running"
|
echo " ERROR: LiteSpeed - Not Running"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if systemctl is-active --quiet cyberpanel; then
|
if systemctl is-active --quiet lscpd; then
|
||||||
echo " SUCCESS: CyberPanel - Running"
|
echo " SUCCESS: CyberPanel - Running"
|
||||||
else
|
else
|
||||||
echo " ERROR: CyberPanel - Not Running"
|
echo " ERROR: CyberPanel - Not Running"
|
||||||
|
|||||||
Reference in New Issue
Block a user