#!/usr/bin/env bash # Pyxsoft 3 installation script # Installation & upgrade from Pyxsoft 2.x for cPanel OS_VERSION=$(grep -E -o '[0-9]' /etc/redhat-release | head -n1); V3_AUTH_FILE="/opt/pyxsoft/auth.ini" # Old location where license key was stored PYXSOFT_INI_FILE="/opt/pyxsoft/pyxsoft.ini" # Verificar que se ejecuta como root if [[ "$(whoami)" != 'root' ]]; then echo "Sorry, you need to run this as root" exit 1 fi # Verificar cPanel if [ ! -d "/var/cpanel" ]; then echo "cPanel not detected in this server." exit 1 fi # Verificar que pyxsoft 1.x no este instalado if [[ -d /usr/share/ilabs_antimalware ]]; then echo "Pyxsoft 1.x installed on this server." echo "Please remove before install. Use:" echo "curl https://www.pyxsoft.com/removev1 | bash" exit fi # Verificar la version de Centos mayor o igual a 7 if [ "$OS_VERSION" -le "6" ]; then echo "Pyxsoft 4 must be installed in RHEL 7 or superior" echo "For RHEL $OS_VERSION please install Pyxsoft 2 using:" echo "curl https://www.pyxsoft.com/install2-cpanel | bash" exit 1 fi read -p "Do you want to continue with the installation? [y/n]?" RES &2 exit 1 fi # Uninstall previous specific OS repo file if [[ -f /etc/yum.repos.d/pyxsoft_v3.repo ]]; then rm -f /etc/yum.repos.d/pyxsoft_v3.repo yum -y clean all fi # Remove Pyxsoft v3 repositorty if exists if [[ -f /etc/yum.repos.d/pyxsoft_v3_rpm_any.repo ]]; then rm -f /etc/yum.repos.d/pyxsoft_v3_rpm_any.repo yum -y clean all fi # Stop old services if systemctl is-active --quiet pxscand; then echo "Stopping old pxscand service..." systemctl stop pxscand systemctl disable pxscand fi if systemctl is-active --quiet pyxsoft; then echo "Stopping old pyxsoft service..." systemctl stop pyxsoft systemctl disable pyxsoft fi # Remove old files if /opt/pyxsoft/pyxsoftui exists if [[ -f /opt/pyxsoft/pyxsoftui ]]; then # Copy license code to /etc/pyxsoft.lic if exists if [ -f "$V3_AUTH_FILE" ]; then LICENSE_CODE=$(awk -F '=' '/^LicenseCode/ { gsub(/^[ \t]+|[ \t]+$/, "", $2); print $2 }' "$V3_AUTH_FILE") if [ -n "$LICENSE_CODE" ]; then echo "Migrating license code to new pyxsoft version" echo "LicenseCode = $LICENSE_CODE" > "/etc/pyxsoft.lic" else echo "License code not found" fi fi echo "Removing old pyxsoft installation..." yum -y remove pyxsoft-cpanel pxscand pyxsoftui # Remove old files rm -fR /opt/pyxsoft rm -fR /opt/pxscand # Remove unit files rm -f /etc/systemd/system/pyxsoft.service rm -f /etc/systemd/system/pxscand.service # Remove logs rm -fR /var/log/pyxsoft systemctl daemon-reload fi # Install Pyxsoft v4 repository if [[ ! -f /etc/yum.repos.d/pyxsoft.repo ]]; then echo "Installing Pyxsoft v4 repository..." curl -s https://repo.pyxsoft.com/public-tools/setup-repo.sh | REPO_NAME="pyxsoft" OS="any" bash exit_code=$? if [[ $exit_code -gt 0 ]]; then echo "Error installing repository" exit 1 fi yum clean all fi # Install Pyxsoft echo "Installing Pyxsoft v4..." yum -y install pyxsoft-cpanel exit_code=$? if [[ $exit_code -gt 0 ]]; then echo "Error installing Pyxsoft" exit 1 fi # Start services if not running echo "Preparing services..." systemctl daemon-reload if ! systemctl is-active --quiet pxshield; then echo "Starting pxshield service..." systemctl start pxshield fi if ! systemctl is-active --quiet pyxsoft; then echo "Starting pyxsoft service..." systemctl start pyxsoft fi # Activate curl https://api.pyxsoft.com/activate.php systemctl restart pxshield echo "Congratulations!! Pyxsoft v4 was successfully installed in this server."