Hi hopefully someone can help. I'm writing a script to remove an addon domain but so far it's not getting rid of it...
Currently I've just tried to use the safer cpanel scripts and a few commands to achieve this but I'm hoping some can fill in the gaps as to what I'm missing so that when I navigate back into that account after running the script the domain is no longer there under the Addon Domains section. Any help appreciated, here is what I have so far:
Currently I've just tried to use the safer cpanel scripts and a few commands to achieve this but I'm hoping some can fill in the gaps as to what I'm missing so that when I navigate back into that account after running the script the domain is no longer there under the Addon Domains section. Any help appreciated, here is what I have so far:
Code:
set -x # Turns tracing on so we can see what is happening
ex +g/$addonDOMAIN/d' -cwq /var/cpanel/users/$cpanelACC # Remove all lines containing addon domain in users file
ex +g/$addonDOMAIN/d' -cwq /var/cpanel/userdata/$cpanelACC/main # Remove all lines containing addon domain in userdata file
/usr/local/cpanel/scripts/killdns $addonDOMAIN # Remove Addon Domain from BIND
/usr/local/cpanel/scripts/killvhost $addonDOMAIN # Remove Addon Domain http entries
/usr/local/cpanel/scripts/rebuildhttpdconf # Rebuild Apache Configuration
set +x # Turns tracing off again
APACHE_CONFIG=$(/usr/local/apache/bin/apachectl configtest 2>&1) # Check condition of Apache with a test
if [[ $APACHE_CONFIG =~ "Syntax OK" ]]; then
echo "Apache config is ok. Restarting Apache."
RESTART_APACHE=$(/usr/local/cpanel/scripts/restartsrv httpd)
if [[ $RESTART_APACHE =~ "Apache successfully restarted" ]]; then
echo "Apache restarted successfully"
else
echo "Apache restart failed: $RESTART_APACHE"
fi
else
echo "Apache config problem. Will not restart apache: $APACHE_CONFIG"
fi