| Linux server27.hostingraja.org 2.6.32-954.3.5.lve1.4.93.el6.x86_64 #1 SMP Wed Oct 4 17:04:29 UTC 2023 x86_64 Path : /opt/imunify360/venv/lib64/python3.11/site-packages/im360/simple_rpc/ |
| Current File : //opt/imunify360/venv/lib64/python3.11/site-packages/im360/simple_rpc/uninstall_cleanup.py |
import logging
import os
from defence360agent.contracts.config import AcronisBackup
from defence360agent.rpc_tools.lookup import RootEndpoints, bind
from defence360agent.utils import Scope
from im360.plugins.protector.lfd import LFD
from im360.subsys import csf
from im360.utils.net import OUT, TCP
logger = logging.getLogger(__name__)
class UninstallCleanupEndpoints(RootEndpoints):
SCOPE = Scope.IM360
@bind("remove-csf-ports")
async def remove_csf_ports(self):
if not os.path.isfile(csf.CSF_CONFIG):
logging.info("Nothing to do, there is no csf config file")
return
try:
ports = AcronisBackup.PORTS
ranges = AcronisBackup.RANGE
csf.remove_ports(TCP, OUT, *ports, ranges=ranges)
await csf.restart_all()
logging.info("Successfully removed Acronis ports from csf config")
except Exception:
logger.exception("Failed to remove Arconis ports from csf config")
@bind("remove-block-report-script")
async def restore_block_report_script(self):
await LFD().shutdown()
@bind("restore-configs")
async def pre_uninstall(self):
await self.remove_csf_ports()
await self.restore_block_report_script()