/opt/imunify360/venv/share/imunify360/scripts
NameSizeModeActions
migrate_csf/-0755rm
__pycache__/-0755rm
check-detached.py11410755editdlrm
create_default_config12630755editdlrm
delay_on_cron_call.py11490755editdlrm
imunify-check-pkg-integrity76500755editdlrm
imunify-core-release4150700editdlrm
imunify-disable-cpu-accounting.sh10240744editdlrm
imunify-doctor.sh269560744editdlrm
imunify-force-update.sh83450744editdlrm
imunify_core_release.py222740644editdlrm
purge-clamav5390755editdlrm
send-notifications154724770editdlrm
setup_cagefs.py45830700editdlrm
track-fpfn-submissions.sh38960755editdlrm
update_components_versions.py42090755editdlrm
Edit: /opt/imunify360/venv/share/imunify360/scripts/delay_on_cron_call.py (1149B)
#!/opt/imunify360/venv/bin/python3 """ Script for internal use in cron update scripts. This script detects when parent call was maid from cron job and apply the random delay in 60 minutes """ import os import psutil import random import time MAX_SLEEP_TIME = 3600 def is_current_process_cron_child(): pid = os.getpid() try: process = psutil.Process(pid) parents = process.parents() # True for cron cronie anacron and etc.. return any(is_cron(proc.name().lower()) for proc in parents) except psutil.NoSuchProcess: print("Unable to determine parent process ID.") return False def is_cron(proc_name: str): return "cron" in proc_name and "imunify" not in proc_name def sleep_in_cron(): try: if is_current_process_cron_child(): sleep_time = random.randint(0, MAX_SLEEP_TIME) print(f"Wait for {sleep_time} seconds before starting updates") time.sleep(sleep_time) else: print("Not in cron, run update immediately") except Exception as e: print("An error occurred while waiting: ", e) sleep_in_cron()