mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-02-16 19:46:48 +01:00
Add MariaDB 10.11 option; fix install/upgrade robustness
- install.py: allow --mariadb-version 10.11 (with 11.8, 12.1); use --nobest for 10.11/11.8 on RHEL; accept existing 10.x - cyberpanel.sh: prompt and --mariadb-version accept 10.11; only pass --mariadb-version if install.py supports it; fix MySQLdb check (no __version__) - cyberpanel_upgrade.sh: accept 10.11 in --mariadb-version and prompt; Check_Root allow uid 0 when SUDO set; Branch_Check avoid double v (vv2.5.5-dev); early root check
This commit is contained in:
@@ -583,11 +583,11 @@ install_cyberpanel_direct() {
|
||||
# Ask MariaDB version first (even in no-confirmation/auto mode) if not set via --mariadb-version
|
||||
if [ -z "$MARIADB_VER" ]; then
|
||||
echo ""
|
||||
echo " MariaDB version: 11.8 (LTS, default) or 12.1?"
|
||||
read -r -t 60 -p " Enter 11.8 or 12.1 [11.8]: " MARIADB_VER || true
|
||||
echo " MariaDB version: 10.11, 11.8 (LTS, default) or 12.1?"
|
||||
read -r -t 60 -p " Enter 10.11, 11.8 or 12.1 [11.8]: " MARIADB_VER || true
|
||||
MARIADB_VER="${MARIADB_VER:-11.8}"
|
||||
MARIADB_VER="${MARIADB_VER// /}"
|
||||
if [ "$MARIADB_VER" != "11.8" ] && [ "$MARIADB_VER" != "12.1" ]; then
|
||||
if [ "$MARIADB_VER" != "10.11" ] && [ "$MARIADB_VER" != "11.8" ] && [ "$MARIADB_VER" != "12.1" ]; then
|
||||
MARIADB_VER="11.8"
|
||||
fi
|
||||
echo " Using MariaDB $MARIADB_VER"
|
||||
@@ -1176,9 +1176,10 @@ except Exception as e:
|
||||
fi
|
||||
fi
|
||||
|
||||
# Verify MySQLdb is available
|
||||
# Verify MySQLdb is available (mysqlclient; some builds lack __version__)
|
||||
print_status "Verifying MySQLdb module availability..."
|
||||
if python3 -c "import MySQLdb; print('MySQLdb version:', MySQLdb.__version__)" 2>&1; then
|
||||
if python3 -c "import MySQLdb; getattr(MySQLdb, '__version__', 'ok'); print('MySQLdb OK')" 2>/dev/null || \
|
||||
python3 -c "import MySQLdb; MySQLdb; print('MySQLdb OK')" 2>/dev/null; then
|
||||
print_status "✓ MySQLdb module is available and working"
|
||||
else
|
||||
print_status "⚠️ WARNING: MySQLdb module not available"
|
||||
@@ -1195,12 +1196,14 @@ except Exception as e:
|
||||
|
||||
# Add optional arguments based on user preferences
|
||||
# Default: OpenLiteSpeed, Full installation (postfix, powerdns, ftp), Local MySQL
|
||||
# These match what the user selected in the interactive prompts
|
||||
install_args+=("--postfix" "ON")
|
||||
install_args+=("--powerdns" "ON")
|
||||
install_args+=("--ftp" "ON")
|
||||
install_args+=("--remotemysql" "OFF")
|
||||
install_args+=("--mariadb-version" "${MARIADB_VER:-11.8}")
|
||||
# Only pass --mariadb-version if this install.py supports it (avoids "unrecognized arguments" on older archives)
|
||||
if grep -q "mariadb-version\|mariadb_version" "$installer_py" 2>/dev/null; then
|
||||
install_args+=("--mariadb-version" "${MARIADB_VER:-11.8}")
|
||||
fi
|
||||
|
||||
if [ "$DEBUG_MODE" = true ]; then
|
||||
# Note: install.py doesn't have --debug, but we can set it via environment
|
||||
@@ -2698,14 +2701,17 @@ parse_arguments() {
|
||||
shift
|
||||
;;
|
||||
--mariadb-version)
|
||||
if [ -n "$2" ] && [ "$2" = "11.8" ]; then
|
||||
if [ -n "$2" ] && [ "$2" = "10.11" ]; then
|
||||
MARIADB_VER="10.11"
|
||||
shift 2
|
||||
elif [ -n "$2" ] && [ "$2" = "11.8" ]; then
|
||||
MARIADB_VER="11.8"
|
||||
shift 2
|
||||
elif [ -n "$2" ] && [ "$2" = "12.1" ]; then
|
||||
MARIADB_VER="12.1"
|
||||
shift 2
|
||||
else
|
||||
echo "ERROR: --mariadb-version requires 11.8 or 12.1"
|
||||
echo "ERROR: --mariadb-version requires 10.11, 11.8 or 12.1"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
@@ -2718,7 +2724,7 @@ parse_arguments() {
|
||||
echo "Options:"
|
||||
echo " -b, --branch BRANCH Install from specific branch/commit"
|
||||
echo " -v, --version VER Install specific version (auto-adds v prefix)"
|
||||
echo " --mariadb-version VER MariaDB version: 11.8 or 12.1 (asked first if omitted)"
|
||||
echo " --mariadb-version VER MariaDB version: 10.11, 11.8 or 12.1 (asked first if omitted)"
|
||||
echo " --debug Enable debug mode"
|
||||
echo " --auto Auto mode without prompts (MariaDB still asked first unless --mariadb-version)"
|
||||
echo " -h, --help Show this help message"
|
||||
@@ -2732,6 +2738,7 @@ parse_arguments() {
|
||||
echo " $0 -v 2.4.3 # Install version 2.4.3"
|
||||
echo " $0 -b main # Install from main branch"
|
||||
echo " $0 -b a1b2c3d4 # Install from specific commit"
|
||||
echo " $0 --mariadb-version 10.11 # Use MariaDB 10.11 (same as v2.4.4 style)"
|
||||
echo " $0 --mariadb-version 12.1 # Use MariaDB 12.1 (no prompt)"
|
||||
echo " $0 --auto --mariadb-version 11.8 # Fully non-interactive with MariaDB 11.8"
|
||||
echo ""
|
||||
|
||||
@@ -11,6 +11,16 @@
|
||||
#Please use variable/functions name as MySomething or My_Something, and please try not to use too-short abbreviation :)
|
||||
#Please use On/Off, True/False, Yes/No.
|
||||
|
||||
# Require root immediately so all later steps (logs, /root, /usr/local/CyberCP) succeed
|
||||
if [[ $(id -u) -ne 0 ]] 2>/dev/null; then
|
||||
echo ""
|
||||
echo "This script must be run as root."
|
||||
echo "Run: sudo bash <(curl -sL https://raw.githubusercontent.com/master3395/cyberpanel/stable/cyberpanel_upgrade.sh) -b v2.5.5-dev"
|
||||
echo "Or: sudo su - then run the same command without sudo"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Sudo_Test=$(set)
|
||||
#for SUDO check
|
||||
|
||||
@@ -95,20 +105,21 @@ echo -e "\n${1}" >> /var/log/upgradeLogs.txt
|
||||
|
||||
Check_Root() {
|
||||
echo -e "\nChecking root privileges..."
|
||||
# If we're actually root (uid 0), allow regardless of SUDO in environment (e.g. curl | sudo bash)
|
||||
if [[ $(id -u) -eq 0 ]] 2>/dev/null; then
|
||||
echo -e "\nYou are running as root...\n"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if echo "$Sudo_Test" | grep SUDO >/dev/null; then
|
||||
echo -e "\nYou are using SUDO, please run as root user...\n"
|
||||
echo -e "\nIf you don't have direct access to root user, please run \e[31msudo su -\e[39m command (do NOT miss the \e[31m-\e[39m at end or it will fail) and then run installation command again."
|
||||
exit
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $(id -u) != 0 ]] >/dev/null; then
|
||||
echo -e "\nYou must run as root user to install CyberPanel...\n"
|
||||
echo -e "or run the following command: (do NOT miss the quotes)"
|
||||
echo -e "\e[31msudo su -c \"sh <(curl https://cyberpanel.sh || wget -O - https://cyberpanel.sh)\"\e[39m"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\nYou are running as root...\n"
|
||||
fi
|
||||
echo -e "\nYou must run as root user to install CyberPanel...\n"
|
||||
echo -e "Run: \e[31msudo su -\e[39m then run this script again, or: curl -sL <url> | sudo bash -s -- <args>"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Check_Server_IP() {
|
||||
@@ -234,7 +245,13 @@ if [[ "$1" = *.*.* ]]; then
|
||||
echo -e "\nYou must use version number higher than 2.3.4"
|
||||
exit
|
||||
else
|
||||
Branch_Name="v${1//[[:space:]]/}"
|
||||
raw="${1//[[:space:]]/}"
|
||||
# Do not add "v" if user already passed e.g. v2.5.5-dev (avoids vv2.5.5-dev)
|
||||
if [[ "$raw" = v* ]]; then
|
||||
Branch_Name="$raw"
|
||||
else
|
||||
Branch_Name="v$raw"
|
||||
fi
|
||||
echo -e "\nSet branch name to $Branch_Name...\n"
|
||||
fi
|
||||
else
|
||||
@@ -349,12 +366,12 @@ 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)
|
||||
# Parse --mariadb-version 10.11|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
|
||||
if [[ "$MARIADB_VER" != "10.11" ]] && [[ "$MARIADB_VER" != "11.8" ]] && [[ "$MARIADB_VER" != "12.1" ]]; then
|
||||
MARIADB_VER="11.8"
|
||||
fi
|
||||
}
|
||||
@@ -1671,12 +1688,16 @@ if [[ "$*" != *"--branch "* ]] && [[ "$*" != *"-b "* ]] ; then
|
||||
Pre_Upgrade_Branch_Input
|
||||
fi
|
||||
|
||||
# Prompt for MariaDB version if not set via --mariadb-version (default 11.8). Downgrade supported (e.g. re-run with --mariadb-version 11.8).
|
||||
# Prompt for MariaDB version if not set via --mariadb-version (default 11.8). Options: 10.11, 11.8, 12.1.
|
||||
if [[ "$*" != *"--mariadb-version "* ]]; then
|
||||
echo -e "\nMariaDB version: \e[31m11.8\e[39m LTS (default) or \e[31m12.1\e[39m. You can switch later by re-running with --mariadb-version 11.8 or 12.1."
|
||||
echo -e "Press Enter for 11.8 LTS, or type \e[31m12.1\e[39m and Enter for 12.1 (5 sec timeout): "
|
||||
echo -e "\nMariaDB version: \e[31m10.11\e[39m, \e[31m11.8\e[39m LTS (default) or \e[31m12.1\e[39m. You can switch later by re-running with --mariadb-version 10.11, 11.8 or 12.1."
|
||||
echo -e "Press Enter for 11.8 LTS, or type \e[31m10.11\e[39m or \e[31m12.1\e[39m (5 sec timeout): "
|
||||
read -r -t 5 Tmp_MariaDB_Ver || true
|
||||
if [[ "$Tmp_MariaDB_Ver" = "12.1" ]]; then
|
||||
Tmp_MariaDB_Ver="${Tmp_MariaDB_Ver// /}"
|
||||
if [[ "$Tmp_MariaDB_Ver" = "10.11" ]]; then
|
||||
MARIADB_VER="10.11"
|
||||
echo -e "MariaDB 10.11 selected.\n"
|
||||
elif [[ "$Tmp_MariaDB_Ver" = "12.1" ]]; then
|
||||
MARIADB_VER="12.1"
|
||||
echo -e "MariaDB 12.1 selected.\n"
|
||||
else
|
||||
|
||||
@@ -1889,12 +1889,12 @@ module cyberpanel_ols {
|
||||
|
||||
if is_installed:
|
||||
self.stdOut(f"MariaDB/MySQL is already installed (version: {installed_version}), skipping installation", 1)
|
||||
# Use existing if already on 11.x or 12.x
|
||||
# Use existing if already on 10.x, 11.x or 12.x
|
||||
if major_minor and major_minor != "unknown":
|
||||
try:
|
||||
major_ver = float(major_minor)
|
||||
if major_ver >= 11.0:
|
||||
self.stdOut("Using existing MariaDB installation (11.x/12.x)", 1)
|
||||
if major_ver >= 10.0:
|
||||
self.stdOut("Using existing MariaDB installation (10.x/11.x/12.x)", 1)
|
||||
self.startMariaDB()
|
||||
self.changeMYSQLRootPassword()
|
||||
self.fixMariaDB()
|
||||
@@ -1902,12 +1902,15 @@ module cyberpanel_ols {
|
||||
except (ValueError, TypeError):
|
||||
pass
|
||||
|
||||
# Set up MariaDB repository only if not already installed (version from --mariadb-version, default 11.8)
|
||||
# Set up MariaDB repository only if not already installed (version from --mariadb-version: 10.11, 11.8 or 12.1)
|
||||
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'
|
||||
# Use --nobest for 10.11 and 11.8 on el9 to avoid MariaDB-client dependency resolution issues
|
||||
if mariadb_ver in ('10.11', '11.8'):
|
||||
command = 'dnf install -y --nobest mariadb-server mariadb-devel mariadb-client-utils'
|
||||
else:
|
||||
command = 'dnf install mariadb-server mariadb-devel mariadb-client-utils -y'
|
||||
self.call(command, self.distro, command, command, 1, 1, os.EX_OSERR, True)
|
||||
|
||||
# Verify MariaDB was installed successfully before proceeding
|
||||
@@ -6485,12 +6488,12 @@ 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')
|
||||
parser.add_argument('--mariadb-version', default='11.8', help='MariaDB version: 10.11, 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'):
|
||||
if mariadb_ver not in ('10.11', '11.8', '12.1'):
|
||||
mariadb_ver = '11.8'
|
||||
preFlightsChecks.mariadb_version = mariadb_ver
|
||||
|
||||
|
||||
Reference in New Issue
Block a user