Mini Shell

Direktori : /usr/share/l.v.e-manager/utils/downgrades/
Upload File :
Current File : //usr/share/l.v.e-manager/utils/downgrades/clear-reseller.py

#!/opt/cloudlinux/venv/bin/python3 -bb
# coding:utf-8

# Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2019 All Rights Reserved
#
# Licensed under CLOUD LINUX LICENSE AGREEMENT
# http://cloudlinux.com/docs/LICENSE.TXT
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
import getopt
import os
import shutil
import subprocess
import sys

import cldetectlib as detect

SOURCE_PATH = "/usr/share/l.v.e-manager/"
ROOT_DA_DIR = "/usr/local/directadmin/plugins/"
ROOT_PLESK_DIR = "/usr/local/psa/admin/"


def main():
    detect.getCP()
    try:
        # Notice: This argument added for disable uninstalling plugin
        # when upgrade from lvemanager <= 4.0 versions.
        # Without this argument do nothing (called from %preun spec section in <= 4.0)
        opts, args = getopt.getopt(sys.argv[1:], "u", ["unregister"])
    except getopt.GetoptError as err:
        sys.exit(2)
    for o, a in opts:
        if o in ("-u", "--unregister"):
            unregister()
            sys.exit()


def unregister():
    if detect.CP_NAME == "cPanel":
        if os.path.exists(SOURCE_PATH+'utils/install-cpanel-plugin.sh'):
            subprocess.run(SOURCE_PATH+'utils/install-cpanel-plugin.sh unregister', shell=True, executable='/bin/bash')
    elif detect.CP_NAME == "DirectAdmin":
        if os.path.exists(ROOT_DA_DIR+"lvemanager_spa/reseller"):
            shutil.rmtree(ROOT_DA_DIR+"lvemanager_spa/reseller")
        if os.path.exists(ROOT_DA_DIR+"lvemanager_spa/hooks/reseller_txt.html"):
            os.remove(ROOT_DA_DIR+"lvemanager_spa/hooks/reseller_txt.html")
    elif detect.CP_NAME == "Plesk":
        if os.path.exists(ROOT_PLESK_DIR+"plib/modules/plesk-lvemanager/hooks/CustomButtons.php"):
            os.remove(ROOT_PLESK_DIR+"plib/modules/plesk-lvemanager/hooks/CustomButtons.php")


if __name__ == '__main__':
    main()

Zerion Mini Shell 1.0