/opt/dedrads
NameSizeModeActions
account_review/-0555rm
check_software_mods/-0555rm
cms_tools/-0555rm
etc/-0555rm
extras/-0555rm
mailparse/-0555rm
mysql/-0555rm
nlp_scripts/-0555rm
oldrads/-0555rm
perl/-0555rm
provision/-0555rm
python/-0555rm
suspended/-0555rm
__pycache__/-0555rm
account-review7990555editdlrm
allfw62590555editdlrm
alp.py165530555editdlrm
autossl_sync62670555editdlrm
check_apache92050555editdlrm
check_bandwidth45460555editdlrm
check_boxtrapper16840555editdlrm
check_cpu122120555editdlrm
check_crons18270555editdlrm
check_dcpumon19730555editdlrm
check_dns18270555editdlrm
check_domlogs610555editdlrm
check_exim37310555editdlrm
check_hacks226040555editdlrm
check_imap52490555editdlrm
check_io66350555editdlrm
check_max_children163410555editdlrm
check_mem16600555editdlrm
check_misc15100555editdlrm
check_pacct52010555editdlrm
check_php43440555editdlrm
check_pop322950555editdlrm
check_prov.py47140555editdlrm
check_server6960555editdlrm
check_size4900555editdlrm
check_software98490555editdlrm
check_spamd24260555editdlrm
check_traffic19330555editdlrm
check_user18870555editdlrm
clean_exim.py63900555editdlrm
clusterfix53430555editdlrm
cmspass.py39700555editdlrm
cms_check.py98250555editdlrm
cms_counter.py367340555editdlrm
cms_creds7130555editdlrm
cms_dumpdb44850555editdlrm
cms_pw14160555editdlrm
cpanel-api70400555editdlrm
cpanel_postgres_manager.py290040555editdlrm
cpmerge46310555editdlrm
cpumon21950555editdlrm
dcpumon.pl12390555editdlrm
dedcheck181270555editdlrm
dns-sync143860555editdlrm
docroot.py44250555editdlrm
du-tree74500555editdlrm
envinfo.py66330555editdlrm
exclude_rbl.py52490555editdlrm
extract-vhost26910555editdlrm
filescan35660555editdlrm
find_warez14600555editdlrm
first_setup.py191200555editdlrm
fixwpcron.py48220555editdlrm
fix_dns_cluster3530555editdlrm
goaccess12177200555editdlrm
hostsfilemods44670555editdlrm
imap_io23230555editdlrm
innodb_converter.py93430555editdlrm
killall9115300555editdlrm
killdns9410555editdlrm
lastcommcache.sh13740555editdlrm
legal_lock_down.sh74500555editdlrm
lil-cpanel520020555editdlrm
listacct45750555editdlrm
mailscan45440555editdlrm
mail_sources.py74070555editdlrm
megaclisas-status386640555editdlrm
migrate2central.sh144180555editdlrm
modify-account406310555editdlrm
modsec_disable.py114610555editdlrm
monarxctl89120555editdlrm
msp.pl277140555editdlrm
mysql_dstat4740555editdlrm
mysql_selector.py731020555editdlrm
nlp45820555editdlrm
procscrape18630555editdlrm
quarantine110830555editdlrm
radsfunctions.sh8630555editdlrm
recent-cp161480555editdlrm
remote_dump183470555editdlrm
reset_cpanel32050555editdlrm
server-load21920555editdlrm
show-conns201050555editdlrm
show-conns-adv.py546670555editdlrm
sparta.py3824980555editdlrm
sqltop271290555editdlrm
telcheck24110555editdlrm
temprootreset1860555editdlrm
unsuspend_user13070555editdlrm
unsusprunner.sh18400555editdlrm
updatednsadmin5260555editdlrm
update_spf149720555editdlrm
upgrade-check92160555editdlrm
vhost_data.py62210555editdlrm
wp-xray.sh858160555editdlrm
Edit: /opt/dedrads/fixwpcron.py (4822B)
#!/usr/lib/rads/venv/bin/python3 """wp-cron was a hacky Wordpress feature added to compensate for Windows's lack of scheduling system. Certain plugins can trigger very poor behavior that causes it to be run every time anything happens on the site. The end result is dozens of thousands of redundant hits to wp-cron.php. This script disables the wp-cron feature, and sets up a cronjob to run once every three hours""" import sys import os import getpass import random import argparse import crontab from rads import is_cpuser def parse_args(): """Parse commandline args""" parser = argparse.ArgumentParser(description=__doc__) group = parser.add_mutually_exclusive_group(required=True) # fmt: off group.add_argument( '--path', '-p', metavar='PATH', type=os.path.realpath, help='path to wordpress installation. If using this argument, we assume' ' the customer has not modified the site to have wp-config.php in an ' 'alternate directory. Both wp-config.php and wp-cron.php should be ' 'present in the supplied directory', ) all_help = """Set this up for every WordPress installation that the user owns. Installations modified to have wp-config.php in an alternate folder for security are supported; wp-config.php and wp-cron.php files will be located separately """ current_user = getpass.getuser() if current_user == 'root': group.add_argument('--user', '-u', help=all_help) else: group.add_argument('--all', '-a', action='store_true', help=all_help) # fmt: on args = parser.parse_args() if args.path: if not os.path.isdir(args.path): sys.exit(f'{args.path} does not exist') try: assert args.path.split('/')[1] == 'home' args.user = args.path.split('/')[2] except (AssertionError, IndexError): sys.exit("Incorrect path. Should be in a user's homedir") if not hasattr(args, 'all'): args.all = False if args.all: args.user = current_user if not is_cpuser(args.user): sys.exit(f'{args.user} is not a cPanel user') return args def turn_off(filename): """Sticks the DISABLE_WP_CRON line in wp-config""" with open(filename, encoding='utf-8') as handle: linelist = handle.readlines() for index, line in enumerate(linelist): if 'DB_USER' in line: if linelist[index + 1] == "define('DISABLE_WP_CRON', 'true');\n": print('File already modified:', filename) return if linelist[index + 1] == '\n': linelist[index + 1] = "define('DISABLE_WP_CRON', 'true');\n" else: print( 'Non-standard wp-config file at {}. Add this manually ' 'under DB_USER:'.format(filename), "define('DISABLE_WP_CRON', 'true');", sep='\n', ) return break with open(filename, 'w', encoding='utf-8') as handle: handle.writelines(linelist) def setup_cron(user, path, not_root): """Setup php -q wp-cron.php system cron""" if not_root: ctab = crontab.CronTab() else: ctab = crontab.CronTab(user=user) cmd = f'cd {path}; php -q wp-cron.php' if len([x for x in ctab.find_command(cmd) if x.is_enabled()]) > 0: print('Cron already enabled:', cmd) return job = ctab.new(command=cmd) job.hour.every(3) job.minute.on(random.randint(0, 59)) ctab.write() def find_files(user): """Find wp-config.php files and dirs containing wp-cron.php""" crondirs = [] # directories containing wp-cron.php configs = [] # wp-config.php files for root, _, filenames in os.walk(os.path.join('/home', user)): if 'wp-config.php' in filenames: configs.append(os.path.join(root, 'wp-config.php')) if 'wp-cron.php' in filenames: crondirs.append(root) return configs, crondirs def main(): """Main program logic""" args = parse_args() if args.path: configs = [os.path.join(args.path, 'wp-config.php')] crondirs = [args.path] else: configs, crondirs = find_files(args.user) if len(configs) > 0: print("wp-config.php file(s):") print(*configs, sep='\n') print() if len(crondirs) > 0: print('dir(s) to setup system crons for wp-cron.php:') print(*crondirs, sep='\n') print() for path in configs: try: turn_off(path) except OSError: print('Error reading/writing to', path) for path in crondirs: setup_cron(args.user, path, args.all) print('done.') if __name__ == '__main__': main()