From 94c56c0015574a30fe7a9ca0602105553dc498fa Mon Sep 17 00:00:00 2001 From: usmannasir Date: Sat, 20 Sep 2025 20:21:18 +0500 Subject: [PATCH] bug fix: of evn creation --- cyberpanel.sh | 18 +++++++++--------- install/install.py | 9 +++++++-- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/cyberpanel.sh b/cyberpanel.sh index 333720642..648ce5238 100644 --- a/cyberpanel.sh +++ b/cyberpanel.sh @@ -1427,7 +1427,7 @@ mkdir -p /usr/local/CyberPanel if [[ "$Server_OS" = "Ubuntu" ]] && ([[ "$Server_OS_Version" = "22" ]] || [[ "$Server_OS_Version" = "24" ]]) ; then echo -e "Ubuntu 22.04/24.04 detected, using python3 -m venv..." - if python3 -m venv /usr/local/CyberPanel 2>&1; then + if python3 -m venv /usr/local/CyberPanel-venv 2>&1; then echo -e "Virtual environment created successfully" else echo -e "python3 -m venv failed, trying virtualenv..." @@ -1438,24 +1438,24 @@ if [[ "$Server_OS" = "Ubuntu" ]] && ([[ "$Server_OS_Version" = "22" ]] || [[ "$S # For Ubuntu 22.04, install virtualenv via apt Retry_Command "DEBIAN_FRONTEND=noninteractive apt-get install -y python3-virtualenv" fi - virtualenv -p /usr/bin/python3 /usr/local/CyberPanel + virtualenv -p /usr/bin/python3 /usr/local/CyberPanel-venv fi else - virtualenv -p /usr/bin/python3 /usr/local/CyberPanel + virtualenv -p /usr/bin/python3 /usr/local/CyberPanel-venv fi # Verify virtual environment was created -if [[ ! -f /usr/local/CyberPanel/bin/activate ]]; then +if [[ ! -f /usr/local/CyberPanel-venv/bin/activate ]]; then echo -e "ERROR: Virtual environment creation failed!" exit 1 fi if [ "$Server_OS" = "Ubuntu" ]; then # shellcheck disable=SC1091 - . /usr/local/CyberPanel/bin/activate + . /usr/local/CyberPanel-venv/bin/activate else # shellcheck disable=SC1091 - source /usr/local/CyberPanel/bin/activate + source /usr/local/CyberPanel-venv/bin/activate fi Debug_Log2 "Installing requirments..,3" @@ -1855,7 +1855,7 @@ if [[ "$Debug" = "On" ]] ; then Debug_Log "Final_Flags" "${Final_Flags[@]}" fi -/usr/local/CyberPanel/bin/python install.py "${Final_Flags[@]}" +/usr/local/CyberPanel-venv/bin/python install.py "${Final_Flags[@]}" if grep "CyberPanel installation successfully completed" /var/log/installLogs.txt >/dev/null; then @@ -2294,10 +2294,10 @@ curl --silent -o /etc/profile.d/cyberpanel.sh https://cyberpanel.sh/?banner 2>/d chmod 700 /etc/profile.d/cyberpanel.sh echo "$Admin_Pass" > /etc/cyberpanel/adminPass chmod 600 /etc/cyberpanel/adminPass -/usr/local/CyberPanel/bin/python /usr/local/CyberCP/plogical/adminPass.py --password "$Admin_Pass" +/usr/local/CyberPanel-venv/bin/python /usr/local/CyberCP/plogical/adminPass.py --password "$Admin_Pass" mkdir -p /etc/opendkim -echo '/usr/local/CyberPanel/bin/python /usr/local/CyberCP/plogical/adminPass.py --password "$@"' > /usr/bin/adminPass +echo '/usr/local/CyberPanel-venv/bin/python /usr/local/CyberCP/plogical/adminPass.py --password "$@"' > /usr/bin/adminPass echo "systemctl restart lscpd" >> /usr/bin/adminPass echo "echo \$@ > /etc/cyberpanel/adminPass" >> /usr/bin/adminPass chmod 700 /usr/bin/adminPass diff --git a/install/install.py b/install/install.py index b16c9504a..8e8b2ee0b 100644 --- a/install/install.py +++ b/install/install.py @@ -598,6 +598,10 @@ class preFlightsChecks: command = "git clone https://github.com/usmannasir/cyberpanel" preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + # Remove existing CyberCP directory if it exists (could be remnant from failed install) + if os.path.exists('CyberCP'): + shutil.rmtree('CyberCP') + shutil.move('cyberpanel', 'CyberCP') ## @@ -641,6 +645,7 @@ password="%s" logging.InstallLog.writeToFile("Environment configuration generated successfully!") if self.remotemysql == 'ON': + path = self.cyberPanelPath + "/CyberCP/settings.py" command = "sed -i 's|localhost|%s|g' %s" % (self.mysqlhost, path) preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) @@ -2896,11 +2901,11 @@ def main(): sys.exit(1) # Create fresh migrations for all apps - command = "/usr/local/CyberPanel/bin/python manage.py makemigrations" + command = "/usr/local/CyberPanel-venv/bin/python manage.py makemigrations" preFlightsChecks.call(command, distro, command, command, 1, 1, os.EX_OSERR) # Apply all migrations - command = "/usr/local/CyberPanel/bin/python manage.py migrate" + command = "/usr/local/CyberPanel-venv/bin/python manage.py migrate" preFlightsChecks.call(command, distro, command, command, 1, 1, os.EX_OSERR) checks.setupPHPAndComposer()