bug with hook “addaddondomain”

kroko

Member
May 30, 2005
6
0
151
hello,

This thread was opened for a problem with cpanel, but i will give my sollution for a 3rd party plugin too.

I have a server with nginxcp
Today my nginx crashed after one of my customers tried to add his main domain as addon domain because the hook was still launched even the cpanel throwed him the error:

Code:
You cannot park your main domain!
I can say i have this problem after my cpanel was upgraded to 11.40 (4 times in one month on this server).
Also i had problems with apache alternate port but it was solved.


the problem in nginx script was with the missing ip variable from hook (I don't know why was triggered in the first place!)

Code:
Restarting nginx daemon: nginxnginx: [emerg] no host in ":80" of the "listen" directive in /etc/nginx/vhosts/xx.xx.ro:3
already running.
To avoid this issue in the future I added a check in addaddondomain script, part of nginxcp, (located in:/usr/local/cpanel/hooks/addondomain):

Code:
if yip == "": 
    sys.exit()
complete file source:
Code:
#!/usr/bin/env python
# Nginx Admin Installer
# Website: www.nginxcp.com
#
# Copyright (C) NGINXCP.COM.
#
import subprocess
import sys
import os
import yaml
from xml.dom import minidom
sys.path.append('/scripts')
import createvhosts
doc = minidom.parse(sys.stdin)

resulttaglist = doc.getElementsByTagName('result')
resultlist =[]

if resulttaglist[1].childNodes[0].toxml() == 0:
        sys.exit
else:
        subdomaintaglist = doc.getElementsByTagName('subdomain')
        subdomain = subdomaintaglist[0].childNodes[0].toxml()
        maindomaintaglist = doc.getElementsByTagName('DOMAIN')
        maindomain = maindomaintaglist[0].childNodes[0].toxml()
        domain =  subdomain + '.' + maindomain
        usertaglist = doc.getElementsByTagName('USER')
        user = usertaglist[0].childNodes[0].toxml()
        docroot, yip, alias = createvhosts.getvars(domain)
        serverip = createvhosts.getmainip()
if yip == "": 
    sys.exit() 
if yip == serverip:
        createvhosts.writeconfshared(user, domain, docroot, yip, alias)
else:
        createvhosts.writeconfded(user, domain, docroot, yip, alias)
proc = subprocess.Popen("/etc/init.d/nginx restart > /dev/null 2>&1", shell=True)
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,202
363
Hello :)

Please ensure you open any potential bugs with cPanel itself as a bug report via:

Submit A Bug Report

You can post the ticket number here so we can update this thread with the outcome.

Thank you.