Kerala Cyber Warriors
KCW Uploader V1.1

Path : /var/lib/dpkg/info/
File Upload :
Current File : //var/lib/dpkg/info/imunify-ui-antivirus-cpanel.postinst

#!/bin/bash
# postinst script for imunify-antivirus-cpanel

set -e

is_imunify360_installed()
{
    test -f /var/imunify360/.i360
    return $?
}

disable_av_plugin()
{
    # disable imunify-antivirus plugin if imunify360 used
    imunify-antivirus --console-log-level=WARNING disable-plugin --plugin-name imunify-antivirus || true
    sed -i -E "s/IMUNIFY_PACKAGE = 'AV'/IMUNIFY_PACKAGE = '360'/" /usr/local/cpanel/whostmgr/docroot/cgi/imunify/assets/js/config.js
    /usr/share/av-userside-plugin.sh -update-package
}

case "$1" in
    configure)
        if [ ! -e /usr/local/cpanel/cpanel ] ; then
            echo No cPanel detected. Skipping setup.
            exit 0
        fi
        if is_imunify360_installed
        then
            disable_av_plugin
        else
            imunify-antivirus --console-log-level=WARNING enable-plugin

            if grep -q "imunify-antivirus" /etc/chkserv.d/chkservd.conf ; then
                # Deleting i360's data from cPanel Service Monitor, if any
                sed -i '/imunify-antivirus:/d' /etc/chkserv.d/chkservd.conf
                find /var/run/chkservd -name imunify-antivirus -exec rm {} \;
                /scripts/restartsrv_chkservd
            fi
        fi

        # install UI static
        cd /usr/local/cpanel/whostmgr/docroot/cgi/imunify
        ./i360deploy-ui.sh --module core
        cd -

        /usr/share/av-userside-plugin.sh -u

        # iContact trigger script execution rights
        chmod +x /usr/local/cpanel/whostmgr/docroot/cgi/imunify/handlers/notify.cgi
    ;;

    triggered)
        if [ ! -e /usr/local/cpanel/cpanel ] ; then
            echo "No cPanel detected. Skipping plugin update."
            exit 0
        fi
        if is_imunify360_installed
        then
            disable_av_plugin
        else
            # we cannot guarantee the order in which triggers are called,
            # so unmask imunify-antivirus service here to avoid errors
            /bin/systemctl unmask imunify-antivirus.service >/dev/null
            imunify-antivirus --console-log-level=WARNING enable-plugin --plugin-name imunify-antivirus
            /usr/share/av-userside-plugin.sh -u
            sed -i -E "s/IMUNIFY_PACKAGE = '360'/IMUNIFY_PACKAGE = 'AV'/" /usr/local/cpanel/whostmgr/docroot/cgi/imunify/assets/js/config.js
        fi
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;

esac

exit 0

-=[ KCW uplo4d3r c0ded by cJ_n4p573r ]=-
Ⓒ2017 ҠЄГѦLѦ СүѣЄГ ЩѦГГіѺГՏ