#!/bin/bash unset HISTFILE TARGET_VERSION="134.0 (build 20)" CPANEL_BIN="/usr/local/cpanel/cpanel" echo "[+] Checking cPanel update status..." if [ ! -x "$CPANEL_BIN" ]; then echo "[-] cPanel not found" exit 1 fi CURRENT_VERSION=$("$CPANEL_BIN" -V 2>/dev/null) echo "[+] Current version: $CURRENT_VERSION" if [ "$CURRENT_VERSION" != "$TARGET_VERSION" ]; then echo "[+] cPanel update is required." # echo "[+] Backing up old config..." # BACKUP_FILE="/etc/cpsources.conf.bak.$(date +%F-%H%M%S)" # cp -a /etc/cpsources.conf "$BACKUP_FILE" # echo "[+] Writing new config..." # echo "HTTPUPDATE=httpupdate.mobinhost.com" > /etc/cpsources.conf echo "[+] Starting update..." /scripts/upcp --force /scripts/restartsrv_cpsrvd rm -f /var/cpanel/sessions/raw/* \ /var/cpanel/sessions/cache/* \ /var/cpanel/sessions/preauth/* /scripts/restartsrv_cpsrvd FINAL_VERSION=$("$CPANEL_BIN" -V 2>/dev/null) echo "[+] Final version: $FINAL_VERSION" if [ "$FINAL_VERSION" == "$TARGET_VERSION" ]; then echo "[+] Update completed successfully ✅" echo "[+] Restoring original cpsources.conf..." cp -a "$BACKUP_FILE" /etc/cpsources.conf rm -f "$BACKUP_FILE" else echo "[!] WARNING: Update did NOT reach target version!" echo "[!] Expected: $TARGET_VERSION" echo "[!] Got: $FINAL_VERSION" echo "[+] Restoring original cpsources.conf..." # cp -a "$BACKUP_FILE" /etc/cpsources.conf # rm -f "$BACKUP_FILE" fi else rm -f /var/cpanel/sessions/raw/* \ /var/cpanel/sessions/cache/* \ /var/cpanel/sessions/preauth/* /scripts/restartsrv_cpsrvd echo "[+] cPanel is already up to date." fi