#!/bin/bash
# Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2026 All Rights Reserved
#
# Licensed under CLOUD LINUX LICENSE AGREEMENT
# http://cloudlinux.com/docs/LICENSE.TXT

# RPM PREUN script, no arguments
# Note: Also called from Debian ea-apache24-mod_lsapi.postinst scriptlet

# "ea-apache24-mod_lsapi PREUN STARTED"

rhel=$2

if [[ "$1" -eq 0 || "$1" == "remove" ]]; then
  if [[ $rhel -lt 7 ]]; then
    /sbin/service lsapi-cache stop > /dev/null 2>&1
    /sbin/chkconfig --del lsapi-cache
  else
    systemctl --no-reload disable lsapi-cache.service > /dev/null 2>&1
    systemctl stop lsapi-cache.service > /dev/null 2>&1
  fi
fi

if [[ $1 -eq 0 || "$1" == "remove" ]]; then
  switch_mod_lsapi --uninstall
  if [ -e /usr/share/lve/modlscapi/global.enabled ]; then
        rm -rf /usr/share/lve/modlscapi/global.enabled
  fi

  rm -rf /etc/apache2/conf.modules.d/001_mod_lsapi.conf
fi

# "ea-apache24-mod_lsapi PREUN FINISHED"
