Skip to content

Commit a56060d

Browse files
authored
Merge pull request #1686 from master3395/v2.5.5-dev
Version Management: always show v2.5.5-dev as up to date; upgrade fixes
2 parents 01a6a06 + 1ff6621 commit a56060d

File tree

3 files changed

+66
-8
lines changed

3 files changed

+66
-8
lines changed

baseTemplate/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
re_path(r'^getAdminStatus$', views.getAdminStatus, name='getSystemInformation'),
88
re_path(r'^getLoadAverage$', views.getLoadAverage, name='getLoadAverage'),
99
re_path(r'^versionManagment$', views.versionManagment, name='versionManagment'),
10+
re_path(r'^versionManagement$', views.versionManagment, name='versionManagement'),
1011
re_path(r'^design$', views.design, name='design'),
1112
re_path(r'^getthemedata$', views.getthemedata, name='getthemedata'),
1213
re_path(r'^upgrade$', views.upgrade, name='upgrade'),

baseTemplate/views.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,19 +291,30 @@ def versionManagment(request):
291291
currentVersion = VERSION
292292
currentBuild = str(BUILD)
293293

294-
getVersion = requests.get('https://cyberpanel.net/version.txt')
295-
latest = getVersion.json()
296-
latestVersion = latest['version']
297-
latestBuild = latest['build']
298-
branch_ref = 'v%s.%s' % (latestVersion, latestBuild)
299-
300294
notechk = True
301295
Currentcomt = ''
302296
latestcomit = ''
297+
latestVersion = '0'
298+
latestBuild = '0'
303299

304-
if _version_compare(currentVersion, latestVersion) > 0:
300+
try:
301+
getVersion = requests.get('https://cyberpanel.net/version.txt', timeout=10)
302+
getVersion.raise_for_status()
303+
latest = getVersion.json()
304+
latestVersion = str(latest.get('version', '0'))
305+
latestBuild = str(latest.get('build', '0'))
306+
except (requests.RequestException, ValueError, KeyError) as e:
307+
logging.CyberCPLogFileWriter.writeToFile('[versionManagment] cyberpanel.net/version.txt failed: %s' % str(e))
308+
if currentVersion == '2.5.5' and currentBuild == 'dev':
309+
notechk = False
310+
311+
branch_ref = 'v%s.%s' % (latestVersion, latestBuild)
312+
313+
if notechk and (currentVersion == '2.5.5' and currentBuild == 'dev'):
305314
notechk = False
306-
else:
315+
elif notechk and _version_compare(currentVersion, latestVersion) > 0:
316+
notechk = False
317+
elif notechk:
307318
remote_cmd = 'git -C /usr/local/CyberCP remote get-url origin 2>/dev/null || true'
308319
remote_out = ProcessUtilities.outputExecutioner(remote_cmd)
309320
is_usmannasir = 'usmannasir/cyberpanel' in (remote_out or '')

cyberpanel_upgrade.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,26 @@ Pre_Upgrade_Setup_Repository() {
428428
echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Pre_Upgrade_Setup_Repository started for OS: $Server_OS" | tee -a /var/log/cyberpanel_upgrade_debug.log
429429

430430
if [[ "$Server_OS" = "CentOS" ]] || [[ "$Server_OS" = "AlmaLinux9" ]] ; then
431+
# Reduce dnf/yum timeouts and mirror issues (e.g. ftp.lip6.fr connection timeout)
432+
for dnf_conf in /etc/dnf/dnf.conf /etc/yum.conf; do
433+
if [[ -f "$dnf_conf" ]]; then
434+
grep -q '^timeout=' "$dnf_conf" 2>/dev/null || echo 'timeout=120' >> "$dnf_conf"
435+
grep -q '^minrate=' "$dnf_conf" 2>/dev/null || echo 'minrate=1000' >> "$dnf_conf"
436+
grep -q '^retries=' "$dnf_conf" 2>/dev/null || echo 'retries=5' >> "$dnf_conf"
437+
break
438+
fi
439+
done
440+
# For AlmaLinux 9: switch to repo.almalinux.org baseurl to avoid slow mirrors (e.g. ftp.lip6.fr timeout)
441+
if [[ "$Server_OS" = "AlmaLinux9" ]] && [[ -d /etc/yum.repos.d ]]; then
442+
for repo in /etc/yum.repos.d/almalinux*.repo /etc/yum.repos.d/AlmaLinux*.repo; do
443+
[[ ! -f "$repo" ]] && continue
444+
if grep -q '^mirrorlist=' "$repo" 2>/dev/null; then
445+
echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Switching AlmaLinux repos to repo.almalinux.org to avoid mirror timeouts" | tee -a /var/log/cyberpanel_upgrade_debug.log
446+
sed -i 's|^mirrorlist=|#mirrorlist=|g' "$repo"
447+
sed -i 's|^#baseurl=\(.*repo\.almalinux\.org.*\)|baseurl=\1|' "$repo"
448+
fi
449+
done
450+
fi
431451
echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Setting up repositories for $Server_OS..." | tee -a /var/log/cyberpanel_upgrade_debug.log
432452
rm -f /etc/yum.repos.d/CyberPanel.repo
433453
rm -f /etc/yum.repos.d/litespeed.repo
@@ -979,6 +999,18 @@ if [[ -z "$CP_PYTHON" ]]; then
979999
exit 1
9801000
fi
9811001
echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Using Python: $CP_PYTHON" | tee -a /var/log/cyberpanel_upgrade_debug.log
1002+
1003+
# Ensure ols_binaries_config exists (required by upgrade.py; may be missing when upgrading from older versions)
1004+
mkdir -p /usr/local/CyberCP/install
1005+
if [[ ! -f /usr/local/CyberCP/install/ols_binaries_config.py ]]; then
1006+
echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Downloading ols_binaries_config.py (required for upgrade)..." | tee -a /var/log/cyberpanel_upgrade_debug.log
1007+
wget -q -O /usr/local/CyberCP/install/ols_binaries_config.py "${Git_Content_URL}/${Branch_Name}/install/ols_binaries_config.py" 2>/dev/null || \
1008+
curl -sL -o /usr/local/CyberCP/install/ols_binaries_config.py "${Git_Content_URL}/${Branch_Name}/install/ols_binaries_config.py" 2>/dev/null || true
1009+
fi
1010+
if [[ ! -f /usr/local/CyberCP/install/ols_binaries_config.py ]]; then
1011+
echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] WARNING: ols_binaries_config.py not found; upgrade.py may fail with ModuleNotFoundError" | tee -a /var/log/cyberpanel_upgrade_debug.log
1012+
fi
1013+
9821014
echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Running: $CP_PYTHON upgrade.py $Branch_Name" | tee -a /var/log/cyberpanel_upgrade_debug.log
9831015

9841016
# Run upgrade.py and capture output
@@ -1633,6 +1665,20 @@ if [[ $Panel_Port = "" ]] ; then
16331665
Panel_Port="8090"
16341666
fi
16351667

1668+
# Resolve server IP for remote access URL (avoid empty Remote: https://:2087)
1669+
if [[ -z "$SERVER_IP" ]]; then
1670+
SERVER_IP=$(hostname -I 2>/dev/null | awk '{print $1}')
1671+
fi
1672+
if [[ -z "$SERVER_IP" ]]; then
1673+
SERVER_IP=$(ip -4 route get 1 2>/dev/null | awk '/src/ {print $7; exit}')
1674+
fi
1675+
if [[ -z "$SERVER_IP" ]]; then
1676+
SERVER_IP=$(curl -s --max-time 3 ifconfig.me 2>/dev/null || curl -s --max-time 3 icanhazip.com 2>/dev/null)
1677+
fi
1678+
if [[ -z "$SERVER_IP" ]]; then
1679+
SERVER_IP="YOUR_SERVER_IP"
1680+
fi
1681+
16361682
# Test if CyberPanel is accessible
16371683
echo -e "\n🔍 Testing CyberPanel accessibility..."
16381684

0 commit comments

Comments
 (0)