Let user choose MariaDB 11.8 or 12.1; default 11.8

- install.py: use preFlightsChecks.mariadb_version in mariadb_repo_setup
- venvsetup.sh: prompt for MariaDB 11.8/12.1 in interactive install, pass --mariadb-version to install.py
- cyberpanel_upgrade.sh: add MARIADB_VER (default 11.8), --mariadb-version arg, interactive prompt, write /etc/cyberpanel/mariadb_version, use in MariaDB.repo
- plogical/upgrade.py: read mariadb_version from /etc/cyberpanel/mariadb_version in fix_almalinux9_mariadb(), default 11.8
This commit is contained in:
master3395
2026-02-03 21:17:25 +01:00
parent b037e37bde
commit fbe97a4e79
4 changed files with 68 additions and 9 deletions

View File

@@ -325,6 +325,8 @@ done
Git_User_Override=""
# Skip full system package update (yum/dnf update -y) to speed up upgrade; use when system is already updated
Skip_System_Update=""
# MariaDB version for repo setup: 11.8 (LTS, default) or 12.1
MARIADB_VER="11.8"
Check_Argument() {
# Parse --branch / -b (extract first word after -b or --branch)
@@ -347,6 +349,14 @@ if [[ "$*" = *"--no-system-update"* ]]; then
Skip_System_Update="yes"
echo -e "\nUsing --no-system-update: skipping full system package update.\n"
fi
# Parse --mariadb-version 11.8|12.1 (default 11.8)
if [[ "$*" = *"--mariadb-version "* ]]; then
MARIADB_VER=$(echo "$*" | sed -n 's/.*--mariadb-version \([^ ]*\).*/\1/p' | head -1)
MARIADB_VER="${MARIADB_VER:-11.8}"
fi
if [[ "$MARIADB_VER" != "11.8" ]] && [[ "$MARIADB_VER" != "12.1" ]]; then
MARIADB_VER="11.8"
fi
}
Pre_Upgrade_Setup_Git_URL() {
@@ -461,11 +471,11 @@ if [[ "$Server_OS" = "CentOS" ]] || [[ "$Server_OS" = "AlmaLinux9" ]] ; then
fi
cat << EOF > /etc/yum.repos.d/MariaDB.repo
# MariaDB 11.8 LTS repository list - updated 2026-02
# MariaDB $MARIADB_VER repository list - updated 2026-02
# https://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = https://mirror.mariadb.org/yum/11.8/$MARIADB_REPO
baseurl = https://mirror.mariadb.org/yum/$MARIADB_VER/$MARIADB_REPO
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF
@@ -1661,6 +1671,26 @@ if [[ "$*" != *"--branch "* ]] && [[ "$*" != *"-b "* ]] ; then
Pre_Upgrade_Branch_Input
fi
# Prompt for MariaDB version if not set via --mariadb-version (default 11.8)
if [[ "$*" != *"--mariadb-version "* ]]; then
echo -e "\nMariaDB version: use \e[31m11.8\e[39m LTS (default) or \e[31m12.1\e[39m."
echo -e "Press Enter for 11.8 LTS, or type \e[31m12.1\e[39m and Enter for 12.1 (5 sec timeout): "
read -r -t 5 Tmp_MariaDB_Ver || true
if [[ "$Tmp_MariaDB_Ver" = "12.1" ]]; then
MARIADB_VER="12.1"
echo -e "MariaDB 12.1 selected.\n"
else
MARIADB_VER="11.8"
echo -e "MariaDB 11.8 LTS (default).\n"
fi
fi
# Write chosen MariaDB version for upgrade.py (e.g. fix_almalinux9_mariadb)
mkdir -p /etc/cyberpanel
echo "$MARIADB_VER" > /etc/cyberpanel/mariadb_version
chmod 644 /etc/cyberpanel/mariadb_version
echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] MariaDB version set to: $MARIADB_VER" | tee -a /var/log/cyberpanel_upgrade_debug.log
Pre_Upgrade_Setup_Repository
Pre_Upgrade_Setup_Git_URL

View File

@@ -1902,8 +1902,9 @@ module cyberpanel_ols {
except (ValueError, TypeError):
pass
# Set up MariaDB 11.8 LTS repository only if not already installed
command = 'curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash -s -- --mariadb-server-version=11.8'
# Set up MariaDB repository only if not already installed (version from --mariadb-version, default 11.8)
mariadb_ver = getattr(preFlightsChecks, 'mariadb_version', '11.8')
command = f'curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash -s -- --mariadb-server-version={mariadb_ver}'
self.call(command, self.distro, command, command, 1, 1, os.EX_OSERR, True)
command = 'dnf install mariadb-server mariadb-devel mariadb-client-utils -y'
@@ -6470,8 +6471,14 @@ def main():
parser.add_argument('--mysqluser', help='MySQL user if remote is chosen.')
parser.add_argument('--mysqlpassword', help='MySQL password if remote is chosen.')
parser.add_argument('--mysqlport', help='MySQL port if remote is chosen.')
parser.add_argument('--mariadb-version', default='11.8', help='MariaDB version: 11.8 (LTS, default) or 12.1')
args = parser.parse_args()
# Normalize and validate MariaDB version choice (default 11.8)
mariadb_ver = (getattr(args, 'mariadb_version', None) or '11.8').strip()
if mariadb_ver not in ('11.8', '12.1'):
mariadb_ver = '11.8'
preFlightsChecks.mariadb_version = mariadb_ver
logging.InstallLog.ServerIP = args.publicip
logging.InstallLog.writeToFile("Starting CyberPanel installation..,10")

View File

@@ -19,6 +19,7 @@ KEY_SIZE=""
ADMIN_PASS="1234567"
MEMCACHED="ON"
REDIS="ON"
MARIADB_VER="11.8"
TOTAL_RAM=$(free -m | awk '/Mem\:/ { print $2 }')
# Robust pip install function to handle broken pipe errors
@@ -873,6 +874,17 @@ if [[ $TMP_YN =~ ^(no|n|N) ]] ; then
else
REDIS="ON"
fi
echo -e "\nWhich MariaDB version do you want to install? \e[31m11.8\e[39m (LTS, default) or \e[31m12.1\e[39m?"
printf "%s" "Choose [1] for 11.8 LTS (recommended), [2] for 12.1, or press Enter for default [1]: "
read TMP_YN
if [[ $TMP_YN =~ ^(2|12\.1) ]] ; then
MARIADB_VER="12.1"
echo -e "\nMariaDB 12.1 will be installed.\n"
else
MARIADB_VER="11.8"
echo -e "\nMariaDB 11.8 LTS will be installed (default).\n"
fi
}
main_install() {
@@ -909,9 +921,9 @@ fi
if [[ $debug == "1" ]] ; then
if [[ $DEV == "ON" ]] ; then
/usr/local/CyberPanel/bin/python install.py $SERVER_IP $SERIAL_NO $LICENSE_KEY
/usr/local/CyberPanel/bin/python install.py $SERVER_IP $SERIAL_NO $LICENSE_KEY --mariadb-version "${MARIADB_VER:-11.8}"
else
/usr/local/CyberPanel/bin/python2 install.py $SERVER_IP $SERIAL_NO $LICENSE_KEY
/usr/local/CyberPanel/bin/python2 install.py $SERVER_IP $SERIAL_NO $LICENSE_KEY --mariadb-version "${MARIADB_VER:-11.8}"
fi
if grep "CyberPanel installation successfully completed" /var/log/installLogs.txt > /dev/null; then

View File

@@ -4376,9 +4376,19 @@ echo $oConfig->Save() ? 'Done' : 'Error';
command = "dnf clean all"
subprocess.run(command, shell=True, capture_output=True)
# Install MariaDB 11.8 LTS from official repository
Upgrade.stdOut("Setting up official MariaDB 11.8 LTS repository...", 1)
command = "curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash -s -- --mariadb-server-version='11.8'"
# Install MariaDB from official repository (version from /etc/cyberpanel/mariadb_version or default 11.8)
mariadb_ver = "11.8"
try:
mariadb_version_file = "/etc/cyberpanel/mariadb_version"
if os.path.isfile(mariadb_version_file):
with open(mariadb_version_file, "r") as f:
raw = f.read().strip()
if raw in ("11.8", "12.1"):
mariadb_ver = raw
except Exception:
pass
Upgrade.stdOut("Setting up official MariaDB %s repository..." % mariadb_ver, 1)
command = "curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash -s -- --mariadb-server-version='%s'" % mariadb_ver
result = subprocess.run(command, shell=True, capture_output=True, text=True)
if result.returncode != 0:
Upgrade.stdOut(f"Warning: MariaDB repo setup failed: {result.stderr}", 0)