Mini Shell

Direktori : /usr/share/lve-stats/scriptlets/
Upload File :
Current File : //usr/share/lve-stats/scriptlets/rpm_preun.sh

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

# RPM:
# $1 == 1 -- upgrade
# $1 == 0 -- uninstall

# DEB:
# $1 == remove/upgrade

# "lve-stats PRE UNINSTALL STARTED"

__python=$2
rhel=$3
python_sitelib=$4

if [[ "${rhel}" -ge 8 ]]; then
    /usr/bin/systemctl stop lvestats-burstwatcher.service lvestats-burstwatcher-config.service
    /usr/bin/systemctl disable lvestats-burstwatcher.service lvestats-burstwatcher-config.service > /dev/null
fi

if [[ "${rhel}" -gt 6 ]]; then
    /usr/bin/systemctl stop lvestats.service
    /usr/bin/systemctl disable lvestats.service > /dev/null
fi

"${__python}" "${python_sitelib}"/lvestats/utils/dbmigrator-back/dbgovernor_config.py || true

if [[ -f /var/run/db-governor.pid ]]; then
    service db_governor restart
fi

# uninstall ?
if [[ $1 == 0 || $1 == "remove" ]] ; then
    rm -f /etc/cron.daily/lvestats.cron
    rm -rf /var/lve/tmp

    if [ -f /var/lock/subsys/lvestats2-server ]; then
        /sbin/service lvestats stop
    fi

    if [[ "${rhel}" -lt 7 ]]; then
       /sbin/chkconfig --del lvestats
    fi

    # remove migrations scripts backup
    rm -Rf "${python_sitelib}"/lvestats/utils/dbmigrator-back/
else
# upgrade/downgrade of the package. stop new "lvestats2" server (/etc/init.d/lvestats can be replaced with script from "old" package)
    if [[ -f /var/run/lvestats.pid ]]; then
        kill `cat /var/run/lvestats.pid` > /dev/null 2>&1
        rm -f /var/lock/subsys/lvestats2-server > /dev/null 2>&1
    fi
fi

# "lve-stats PRE UNINSTALL FINISHED"
exit 0

Zerion Mini Shell 1.0