HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //var/lib/dpkg/info/wp-toolkit-cpanel.prerm
### Copyright 1999-2025. WebPros International GmbH. All rights reserved.
[ -z "$WP_TOOLKIT_INSTALLER_DEBUG" ] || set -x
[ -z "$WP_TOOLKIT_INSTALLER_STRICT_MODE" ] || set -e

uninstall_whm_plugin()
{
    /usr/local/cpanel/bin/unregister_appconfig /usr/local/cpanel/3rdparty/wp-toolkit/whm-plugin/whm-wp-toolkit.conf
}

# unused, why not removed during upgrade to WPT with new integration schema?
uninstall_privileged_executor()
{
    rm -rf /usr/local/cpanel/bin/admin/WpToolkit
}

uninstall_cpanel_plugin()
{
    CPANEL_FRONTEND_PATH="/usr/local/cpanel/base/frontend"
    CPANEL_PLUGIN_BASE_PATH="/usr/local/cpanel/3rdparty/wp-toolkit/cpanel-plugin"

    find ${CPANEL_FRONTEND_PATH} -mindepth 1 -maxdepth 1 -type d -printf "%f\n" | while IFS=$'\n' read -r theme
    do
      CPANEL_PLUGIN_TARGET_PATH="${CPANEL_FRONTEND_PATH}/$theme/wp-toolkit"
      /usr/local/cpanel/scripts/uninstall_plugin --theme "$theme" ${CPANEL_PLUGIN_BASE_PATH}
      rm -f "${CPANEL_PLUGIN_TARGET_PATH}"
    done
}

unregister_fpm_applications()
{
  /usr/local/cpanel/bin/unregister_appconfig "/usr/local/cpanel/3rdparty/wp-toolkit/cpanel-plugin/cpanel-wp-toolkit.conf"
  /usr/local/cpanel/bin/unregister_appconfig "/usr/local/cpanel/3rdparty/wp-toolkit/whm-plugin/whm-wp-toolkit-api.conf"
}

uninstall_engines()
{
    if [ -x /bin/systemctl ]; then
      /bin/systemctl stop sw-engine.service
      /bin/systemctl disable sw-engine.service
    fi
}

remove_users()
{
  userdel --force wp-toolkit
  rm -f /etc/sudoers.d/48-wp-toolkit
}

remove_services()
{
  for service in background-tasks scheduled-tasks; do
    if [ -x /bin/systemctl ]; then
      /bin/systemctl stop "wp-toolkit-${service}"
      ! /bin/systemctl is-enabled "wp-toolkit-${service}" > /dev/null || /bin/systemctl disable "wp-toolkit-${service}"
    fi
  done
}

prepare_uninstall()
{
   /usr/local/cpanel/3rdparty/wp-toolkit/bin/run-script pre-uninstall.php
}


case "$1" in
    remove)
        prepare_uninstall
        remove_services
        uninstall_cpanel_plugin
        uninstall_whm_plugin
        unregister_fpm_applications
        uninstall_privileged_executor
        uninstall_engines
        remove_users
        ;;
    upgrade|deconfigure|failed-upgrade)
        ;;
    *)
        echo "prerm called with unknown argument \`$1'" >&2
        exit 1
        ;;
esac

exit 0