/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/check_prov.py (4714B)
#!/usr/lib/rads/venv/bin/python3 # Check some things to make sure the vps provisioning went well # 6/19/2017 Nathan import sys import os import socket import dns.resolver # pylint: disable=no-name-in-module from netifaces import interfaces, ifaddresses, AF_INET import rads LOG_FILE = '/root/prov_log' def ip4_addresses(): """List ipv4 addresses setup on this system""" ip_list = [] for interface in interfaces(): if AF_INET in ifaddresses(interface): for link in ifaddresses(interface)[AF_INET]: ip_list.append(link['addr']) return ip_list def get_mainip(): """This should only be run on brand new vps. so there will be 2 IP's. The main IP and a local address""" main_ip = None with open('/etc/wwwacct.conf', encoding='utf-8') as f: for line in f.readlines(): if not line.strip(): continue if line.split()[0] == 'ADDR': main_ip = line.split()[1] return main_ip def check_dns(): """Check that forward and reverse DNS is setup properly""" sys.tracebacklimit = 0 vps_hostname = socket.getfqdn() vps_ips = ip4_addresses() # Forward DNS try: hostname_ip = socket.gethostbyname(vps_hostname) print(vps_hostname + " resolves to " + hostname_ip) except Exception as e: print("A record for hostname not found") print(e) return False # Get the main IP of the server main_ip = None for ip in vps_ips: if ip == hostname_ip: main_ip = ip else: pass if main_ip == hostname_ip: print(main_ip + " resolves to " + vps_hostname) return True print("Reverse DNS either doesn't match or is not present") return False def check_mailip(): """Ripped this straight from google. it does the trick""" my_ip = get_mainip() # Spamhaus zen bls = [ "zen.spamhaus.org", "spam.abuse.ch", "cbl.abuseat.org", "virbl.dnsbl.bit.nl", "dnsbl.inps.de", "ix.dnsbl.manitu.net", "dnsbl.sorbs.net", "bl.spamcop.net", "xbl.spamhaus.org", "pbl.spamhaus.org", "db.wpbl.info", ] listings = [] for bl in bls: try: my_resolver = dns.resolver.Resolver() query = '.'.join(reversed(str(my_ip).split("."))) + "." + bl answers = my_resolver.resolve(query, "A") answer_txt = my_resolver.resolve(query, "TXT") listings.append( 'IP: %s IS listed in %s (%s: %s)' % (my_ip, bl, answers[0], answer_txt[0]) ) except dns.resolver.NXDOMAIN: # print 'IP: %s is NOT listed in %s' %(myIP, bl) pass if len(listings) > 0: return False return True def check_user_setup(): """Check if the reseller user was setup during provisioning""" user_list = [] for _, _, files in os.walk("/var/cpanel/users"): for file in files: user_list.append(file) try: user_list.remove('system') except Exception: pass if len(user_list) < 1: print("Reseller user not setup properly") return False print(user_list[0] + " setup as reseller user") return True def create_task(subject: str, body: str): try: rads.make_ticket(dest='sadmin@imhadmin.net', subject=subject, body=body) except rads.TicketError as exc: print(f"Failed to create ticket - {exc}", file=sys.stderr) else: print("T2S notified") DNS_SETUP_ERROR = ( "One or more of the DNS setup checks failed. Please check that both " "forward and reverse DNS is setup properly for this VPS container" ) MAIL_IP_ERROR = ( "The container was setup with a blacklisted or otherwise bad mail IP. " "Please review the mail ip of the server and rotate/delist as needed" ) USER_SETUP_ERROR = ( "The reseller user was not found on this server after provisioning. Please " "check why, and setup user if needed" ) def main(): subject = socket.getfqdn() + " provisioning check failure" if not check_dns(): print("DNS checks failed") create_task(subject, DNS_SETUP_ERROR) else: print("DNS checks passed") if not check_mailip(): print("Mail IP checks failed") create_task(subject, MAIL_IP_ERROR) else: print("Mail IP checks passed") if not check_user_setup(): print('User setup checks failed') create_task(subject, USER_SETUP_ERROR) else: print('User setup checks passsed') if __name__ == "__main__": main()