-
-
Notifications
You must be signed in to change notification settings - Fork 713
Expand file tree
/
Copy pathtest_debian13_support.sh
More file actions
430 lines (368 loc) · 12.4 KB
/
test_debian13_support.sh
File metadata and controls
430 lines (368 loc) · 12.4 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
#!/bin/bash
# Debian 13 Support Test Script for CyberPanel
# This script tests the compatibility of CyberPanel with Debian 13
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Test results
TESTS_PASSED=0
TESTS_FAILED=0
TESTS_TOTAL=0
# Function to print colored output
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
((TESTS_PASSED++))
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
((TESTS_FAILED++))
}
print_test_header() {
echo -e "\n${BLUE}=== $1 ===${NC}"
((TESTS_TOTAL++))
}
# Function to run a test
run_test() {
local test_name="$1"
local test_command="$2"
local expected_result="$3"
print_test_header "$test_name"
if eval "$test_command" >/dev/null 2>&1; then
if [[ "$expected_result" == "success" ]]; then
print_success "$test_name passed"
return 0
else
print_error "$test_name failed (unexpected success)"
return 1
fi
else
if [[ "$expected_result" == "failure" ]]; then
print_success "$test_name passed (expected failure)"
return 0
else
print_error "$test_name failed"
return 1
fi
fi
}
# Function to check OS detection
test_os_detection() {
print_test_header "OS Detection Test"
# Check if we're on Debian 13
if [[ -f /etc/os-release ]]; then
source /etc/os-release
if [[ "$ID" == "debian" && "$VERSION_ID" == "13" ]]; then
print_success "Debian 13 detected correctly"
else
print_warning "Not running on Debian 13 (Current: $ID $VERSION_ID)"
print_status "This test is designed for Debian 13, but will continue with current OS"
fi
else
print_error "Cannot detect OS - /etc/os-release not found"
return 1
fi
}
# Function to test CyberPanel OS detection logic
test_cyberpanel_os_detection() {
print_test_header "CyberPanel OS Detection Logic Test"
# Test the OS detection logic from cyberpanel.sh
if grep -q -E "Debian GNU/Linux 11|Debian GNU/Linux 12|Debian GNU/Linux 13" /etc/os-release; then
print_success "CyberPanel OS detection logic recognizes Debian 11/12/13"
else
print_error "CyberPanel OS detection logic does not recognize current Debian version"
return 1
fi
}
# Function to test package manager compatibility
test_package_manager() {
print_test_header "Package Manager Compatibility Test"
# Test apt-get availability
if command -v apt-get >/dev/null 2>&1; then
print_success "apt-get package manager is available"
else
print_error "apt-get package manager not found"
return 1
fi
# Test apt-get update (dry run)
if apt-get update --dry-run >/dev/null 2>&1; then
print_success "apt-get update works correctly"
else
print_warning "apt-get update failed (may be network related)"
fi
}
# Function to test systemd compatibility
test_systemd_compatibility() {
print_test_header "Systemd Compatibility Test"
# Test systemctl availability
if command -v systemctl >/dev/null 2>&1; then
print_success "systemctl is available"
else
print_error "systemctl not found"
return 1
fi
# Test systemd status
if systemctl is-system-running >/dev/null 2>&1; then
print_success "systemd is running"
else
print_warning "systemd status unclear"
fi
}
# Function to test Python compatibility
test_python_compatibility() {
print_test_header "Python Compatibility Test"
# Test Python 3 availability
if command -v python3 >/dev/null 2>&1; then
local python_version=$(python3 --version 2>&1 | cut -d' ' -f2)
print_success "Python 3 is available: $python_version"
# Check if Python version is compatible (3.6+)
local major_version=$(echo "$python_version" | cut -d'.' -f1)
local minor_version=$(echo "$python_version" | cut -d'.' -f2)
if [[ $major_version -ge 3 && $minor_version -ge 6 ]]; then
print_success "Python version is compatible (3.6+)"
else
print_warning "Python version may not be fully compatible (requires 3.6+)"
fi
else
print_error "Python 3 not found"
return 1
fi
# Test pip3 availability
if command -v pip3 >/dev/null 2>&1; then
print_success "pip3 is available"
else
print_warning "pip3 not found (may need to be installed)"
fi
}
# Function to test web server compatibility
test_web_server_compatibility() {
print_test_header "Web Server Compatibility Test"
# Test Apache2 availability
if command -v apache2 >/dev/null 2>&1; then
print_success "Apache2 is available"
else
print_warning "Apache2 not found (will be installed by CyberPanel)"
fi
# Test if Apache2 can be installed
if apt-cache show apache2 >/dev/null 2>&1; then
print_success "Apache2 package is available in repositories"
else
print_error "Apache2 package not found in repositories"
return 1
fi
}
# Function to test required packages availability
test_required_packages() {
print_test_header "Required Packages Availability Test"
local required_packages=(
"curl"
"wget"
"git"
"build-essential"
"python3-dev"
"python3-pip"
"python3-venv"
"software-properties-common"
"apt-transport-https"
"ca-certificates"
"gnupg"
)
local available_count=0
local total_count=${#required_packages[@]}
for package in "${required_packages[@]}"; do
if apt-cache show "$package" >/dev/null 2>&1; then
print_success "$package is available"
((available_count++))
else
print_warning "$package not found in repositories"
fi
done
print_status "Available packages: $available_count/$total_count"
if [[ $available_count -ge $((total_count * 8 / 10)) ]]; then
print_success "Most required packages are available"
else
print_warning "Many required packages are missing"
fi
}
# Function to test LiteSpeed repository compatibility
test_litespeed_repo_compatibility() {
print_test_header "LiteSpeed Repository Compatibility Test"
# Test if we can access LiteSpeed Debian repository
if curl -s --head "http://rpms.litespeedtech.com/debian/" | head -n 1 | grep -q "200 OK"; then
print_success "LiteSpeed Debian repository is accessible"
else
print_warning "LiteSpeed Debian repository may not be accessible"
fi
# Test if we can download the repository setup script
if wget --spider "http://rpms.litespeedtech.com/debian/enable_lst_debian_repo.sh" 2>/dev/null; then
print_success "LiteSpeed repository setup script is available"
else
print_warning "LiteSpeed repository setup script may not be available"
fi
}
# Function to test MariaDB compatibility
test_mariadb_compatibility() {
print_test_header "MariaDB Compatibility Test"
# Test MariaDB repository accessibility
if curl -s --head "https://mariadb.org/mariadb_release_signing_key.pgp" | head -n 1 | grep -q "200 OK"; then
print_success "MariaDB signing key is accessible"
else
print_warning "MariaDB signing key may not be accessible"
fi
# Test if MariaDB packages are available
if apt-cache show mariadb-server >/dev/null 2>&1; then
print_success "MariaDB packages are available in repositories"
else
print_warning "MariaDB packages not found in default repositories"
fi
}
# Function to test network connectivity
test_network_connectivity() {
print_test_header "Network Connectivity Test"
local test_urls=(
"https://github.com"
"https://pypi.org"
"http://rpms.litespeedtech.com"
"https://mariadb.org"
)
local accessible_count=0
local total_count=${#test_urls[@]}
for url in "${test_urls[@]}"; do
if curl -s --head "$url" >/dev/null 2>&1; then
print_success "$url is accessible"
((accessible_count++))
else
print_warning "$url is not accessible"
fi
done
print_status "Accessible URLs: $accessible_count/$total_count"
if [[ $accessible_count -ge $((total_count * 3 / 4)) ]]; then
print_success "Network connectivity is good"
else
print_warning "Network connectivity may be limited"
fi
}
# Function to test system resources
test_system_resources() {
print_test_header "System Resources Test"
# Test available memory
local total_memory=$(free -m | awk 'NR==2{print $2}')
if [[ $total_memory -ge 1024 ]]; then
print_success "Sufficient memory available: ${total_memory}MB"
else
print_warning "Low memory: ${total_memory}MB (recommended: 1GB+)"
fi
# Test available disk space
local available_space=$(df / | awk 'NR==2{print $4}')
local available_gb=$((available_space / 1024 / 1024))
if [[ $available_gb -ge 10 ]]; then
print_success "Sufficient disk space: ${available_gb}GB"
else
print_warning "Low disk space: ${available_gb}GB (recommended: 10GB+)"
fi
# Test CPU cores
local cpu_cores=$(nproc)
if [[ $cpu_cores -ge 2 ]]; then
print_success "Sufficient CPU cores: $cpu_cores"
else
print_warning "Limited CPU cores: $cpu_cores (recommended: 2+)"
fi
}
# Function to run all tests
run_all_tests() {
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE} CyberPanel Debian 13 Compatibility Test${NC}"
echo -e "${BLUE}========================================${NC}\n"
test_os_detection
test_cyberpanel_os_detection
test_package_manager
test_systemd_compatibility
test_python_compatibility
test_web_server_compatibility
test_required_packages
test_litespeed_repo_compatibility
test_mariadb_compatibility
test_network_connectivity
test_system_resources
echo -e "\n${BLUE}========================================${NC}"
echo -e "${BLUE} Test Results Summary${NC}"
echo -e "${BLUE}========================================${NC}"
echo -e "Total Tests: $TESTS_TOTAL"
echo -e "Passed: ${GREEN}$TESTS_PASSED${NC}"
echo -e "Failed: ${RED}$TESTS_FAILED${NC}"
if [[ $TESTS_FAILED -eq 0 ]]; then
echo -e "\n${GREEN}✅ All tests passed! Debian 13 appears to be compatible with CyberPanel.${NC}"
return 0
elif [[ $TESTS_FAILED -le 2 ]]; then
echo -e "\n${YELLOW}⚠️ Most tests passed. Debian 13 should be compatible with minor issues.${NC}"
return 0
else
echo -e "\n${RED}❌ Multiple tests failed. Debian 13 may have compatibility issues.${NC}"
return 1
fi
}
# Function to show usage
show_usage() {
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " -h, --help Show this help message"
echo " -v, --verbose Enable verbose output"
echo " --quick Run only essential tests"
echo ""
echo "This script tests CyberPanel compatibility with Debian 13."
echo "Run as root for best results."
}
# Main execution
main() {
local verbose=false
local quick=false
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
show_usage
exit 0
;;
-v|--verbose)
verbose=true
shift
;;
--quick)
quick=true
shift
;;
*)
echo "Unknown option: $1"
show_usage
exit 1
;;
esac
done
# Check if running as root
if [[ $EUID -ne 0 ]]; then
print_warning "Not running as root. Some tests may fail."
print_status "Consider running: sudo $0"
fi
# Run tests
if [[ "$quick" == "true" ]]; then
print_status "Running quick compatibility test..."
test_os_detection
test_cyberpanel_os_detection
test_package_manager
test_systemd_compatibility
else
run_all_tests
fi
}
# Run main function
main "$@"