Tag Archives: cPanel

remove duplicated DNS zones from cPanel cluster servers

#!/bin/bash

# Find and remove duplicated DNS zones from cPanel cluster servers

cp -r /var/named /var/named_$(date +%F)
cp /etc/named.conf /etc/named.conf_$(date +%F)

> /tmp/all_zones
> /tmp/good
> /tmp/bad

find /var/named -maxdepth 1 -name '*.db' -exec basename {} .db \; > /tmp/all_zones

for z in $(cat /tmp/zonos.txt); do
grep -qE "DNS[0-9]*=$z" /var/cpanel/users/* && echo $z >> /tmp/good
done

grep -vwf /tmp/good /tmp/all_zones > /tmp/bad

wc -l /tmp/good /tmp/bad
wc -l /tmp/all_zones

for z in $(cat /tmp/bad); do
rm -f /var/named/$z.db
done

rm -f /var/named/cache/*
mv -f /etc/named.conf /tmp/
/scripts/rebuilddnsconfig

service named restart
sleep 5
service named status

DBD::mysql::db do failed: Illegal mix of collations

Full error message:

DBD::mysql::db do failed: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation ‘=’
The system failed to lock the file “/home/username/etc/domain.tld/_privs.json” because of an error: Permission denied at /usr/local/cpanel/Cpanel/Transaction/File/Base.pm line 88.

Fix.
chown username.username /home/username/etc/domain.tld/

cPanel disable SSL 3

If you are afraid of POODLE Attack, you should disable SSL v3. You can use this ansible playbook:


– hosts: test
remote_user: root

tasks:
– lineinfile: dest=/usr/local/apache/conf/includes/pre_main_global.conf line=”#Turn off SSL v3 support\nSSLProtocol All -SSLv2 -SSLv3\nSSLHonorCipherOrder On\n” insertafter=BOF
– name: rebuild httpd confs
command: /scripts/rebuildhttpdconf
notify:
– restart httpd
– name: ensure apache is running
service: name=httpd state=started

handlers:
– name: restart httpd
service: name=httpd state=restarted