forked from usmannasir/cyberpanel
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfix_cyberpanel_install.sh
More file actions
128 lines (102 loc) · 3.95 KB
/
fix_cyberpanel_install.sh
File metadata and controls
128 lines (102 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
# CyberPanel Post-Upgrade Fix Script
# This script completes the installation when the upgrade exits early due to TypeError
set -e # Exit on error
echo "==================================="
echo "CyberPanel Installation Fix Script"
echo "==================================="
echo ""
# Check if running as root
if [[ $(id -u) != 0 ]]; then
echo "This script must be run as root!"
exit 1
fi
# Function to print colored output
print_status() {
echo -e "\033[1;32m[$(date +"%Y-%m-%d %H:%M:%S")]\033[0m $1"
}
print_error() {
echo -e "\033[1;31m[$(date +"%Y-%m-%d %H:%M:%S")] ERROR:\033[0m $1"
}
# Check if virtual environment exists
if [[ ! -f /usr/local/CyberCP/bin/activate ]]; then
print_error "CyberPanel virtual environment not found!"
print_status "Creating virtual environment..."
# Try python3 -m venv first
if python3 -m venv --system-site-packages /usr/local/CyberCP 2>/dev/null; then
print_status "Virtual environment created successfully with python3 -m venv"
else
# Fallback to virtualenv
virtualenv -p /usr/bin/python3 --system-site-packages /usr/local/CyberCP
fi
fi
# Activate virtual environment
print_status "Activating CyberPanel virtual environment..."
source /usr/local/CyberCP/bin/activate
# Check if Django is already installed
if python -c "import django" 2>/dev/null; then
print_status "Django is already installed. Checking version..."
python -c "import django; print(f'Django version: {django.__version__}')"
else
print_status "Installing Python requirements..."
# Download requirements file
print_status "Downloading requirements.txt..."
if [[ -f /tmp/requirements.txt ]]; then
rm -f /tmp/requirements.txt
fi
# Detect OS version and download appropriate requirements
if grep -q "22.04" /etc/os-release || grep -q "VERSION_ID=\"9" /etc/os-release; then
wget -q -O /tmp/requirements.txt https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.4.4-dev/requirments.txt
else
wget -q -O /tmp/requirements.txt https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.4.4-dev/requirments-old.txt
fi
# Upgrade pip first
print_status "Upgrading pip, setuptools, and wheel..."
pip install --upgrade pip setuptools wheel packaging
# Install requirements
print_status "Installing CyberPanel requirements (this may take a few minutes)..."
pip install --default-timeout=3600 --ignore-installed -r /tmp/requirements.txt
fi
# Install WSGI-LSAPI if not present
if [[ ! -f /usr/local/CyberCP/bin/lswsgi ]]; then
print_status "Installing WSGI-LSAPI..."
cd /tmp
rm -rf wsgi-lsapi-2.1*
wget -q https://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-2.1.tgz
tar xf wsgi-lsapi-2.1.tgz
cd wsgi-lsapi-2.1
/usr/local/CyberCP/bin/python ./configure.py
make
cp lswsgi /usr/local/CyberCP/bin/
print_status "WSGI-LSAPI installed successfully"
fi
# Fix permissions
print_status "Fixing permissions..."
chown -R cyberpanel:cyberpanel /usr/local/CyberCP/lib 2>/dev/null || true
chown -R cyberpanel:cyberpanel /usr/local/CyberCP/lib64 2>/dev/null || true
# Test Django installation
print_status "Testing Django installation..."
cd /usr/local/CyberCP
if python manage.py check 2>&1 | grep -q "System check identified no issues"; then
print_status "Django is working correctly!"
else
print_error "Django check failed. Checking for specific issues..."
python manage.py check
fi
# Restart LSCPD
print_status "Restarting LSCPD service..."
systemctl restart lscpd
# Check service status
if systemctl is-active --quiet lscpd; then
print_status "LSCPD service is running"
else
print_error "LSCPD service failed to start"
systemctl status lscpd
fi
echo ""
print_status "CyberPanel fix completed!"
echo ""
echo "You can now access CyberPanel at: https://$(hostname -I | awk '{print $1}'):8090"
echo ""
# Deactivate virtual environment
deactivate 2>/dev/null || true