cPanel - Domain already exists error while adding a subdomain or addon domain

Domain already exists error while adding a subdomain or addon domain



A very common error  when adding an addon or parked domain via cpanel. Unfortunately, the error they see is usually very generic and doesn’t provide any information such as “can not create domain”. This is usually due to the domain name existing *somewhere* and checking these locations/steps out should help you find the domain that is lurking somewhere and causing the issues.

Reason 1: There is an existing zone file on the server.

1) You can use the following command to check whether zone exists or not,


# dig @server_ip domain.com

If there is a zone file exists, this will show the A record of the domain.com.

2) If there is a zone file that exists, log into the server that the zone file is pointing to and make sure the domain doesn’t exist:

# /scripts/whoowns domain.com

If it does, you would need to remove this prior to adding their new addon domain. If it does not, continue on

3) Remove the zone file from master by running the following command:

# ./killdns domain.com

 This will then get rid of the pesky zone file that is getting in the way of their addon creation

Reason 2: There are old traces of the domain on the server

1) Log into the server where the customer is seeing problems adding the domain and confirm that the domain does not exist on the server.

# /scripts/whoowns domain.com

2) Check Cpanel files for traces of the problem domain name

# grep domain.com /var/cpanel/users/*

# grep -R domain.com /var/cpanel/userdata/*

3) Edit any files that are found and remove the traces of the domain name the customer is trying to add. You also may need to remove the entire file for the domain in the /var/cpanel/userdata/USERNAME/ directory.

 4) Rebuild the user domains database

# /scripts/updateuserdomains

5) Rebuild the Apache configuration and make sure apache is running with all traces of the bad domain removed.

# /scripts/rebuildhttpdconf ; service httpd restart

This should have all traces that were left behind from when this domain name was removed in the past and then will no longer cause a conflict when the customer tries to add the domain again.

cPanel - Bash script To Change password of all mail accounts

 Bash script To Change password of all mail accounts

The bash script given below will change the password of all the mail accounts in a cpanel server. The new password with mail account user name will be saved in to '/root/mailaccounts.txt'.




#!/bin/bash -   

#title          :changeallmailpass.sh

#description    :To Change password of all mail accounts in a cPanel Server

#author         :Arun Ghosh

#date           :20130812

#version        :1.0   

#usage          :./changeallmailpass.sh

#notes          :      

#bash_version   :4.2.25(1)-release

#============================================================================

genpasswd() {

        tr -dc A-Za-z0-9_ < /dev/urandom | head -c 12 | xargs

}

cat /dev/null > /root/mailaccounts.txt

CP_ACCOUNTS=`ls -1A /var/cpanel/users/`

for CP_USER in `echo -n $CP_ACCOUNTS`

do

    USER_DOMAIN=`grep -i ^dns /var/cpanel/users/$CP_USER |cut -d= -f2`

    for DOMAIN in `echo -n "$USER_DOMAIN"`

    do

        SHADOW_FILE="/home/$CP_USER/etc/$DOMAIN/shadow"

        if [ -f $SHADOW_FILE ] && [ -s $SHADOW_FILE ]

        then

            cat /dev/null > "/home/$CP_USER/etc/$DOMAIN/shadow.tmp"

            for shadow in `cat $SHADOW_FILE`

            do

                NEW_PASS=$(genpasswd)

                MD5_PASS=$(openssl passwd -1 $NEW_PASS)

                user=$(echo $shadow | cut -d":" -f1)

                rest=$(echo $shadow | cut -d":" -f3-)

                echo -e "$NEW_PASS\t$user@$DOMAIN" >> "/root/mailaccounts.txt"

                echo "$user:$MD5_PASS:$rest" >> "/home/$CP_USER/etc/$DOMAIN/shadow.tmp"

               

            done

            mv "/home/$CP_USER/etc/$DOMAIN/shadow" "/home/$CP_USER/etc/$DOMAIN/shadow.$(date +%s)"

            mv "/home/$CP_USER/etc/$DOMAIN/shadow.tmp" "/home/$CP_USER/etc/$DOMAIN/shadow"

            chmod 640 "/home/$CP_USER/etc/$DOMAIN/shadow"

            chown $CP_USER:$CP_USER "/home/$CP_USER/etc/$DOMAIN/shadow"        

        fi

    done

done



cPanel - Bash script To change password of a single mail account in cPanel via terminal


Bash script To change password of a mail account in cPanel via command line

The bash script given below will help you to change the password of a single mail account in a cpanel server via command line.

Let the script name is 'changemailpass.sh'. You can change the password of a mail account by using the following format.

# ./changemailpass.sh <mail_account> <newpassword>



#!/bin/bash -  
#title          :changemailpass.sh
#description    :To change password of a single mail account in cPanel via terminal
#author         :Arun Ghosh
#date           :20130811
#version        :1.0   
#usage          :./changemailpass.sh
#notes          :      
#bash_version   :4.2.25(1)-release
#============================================================================

MAIL_USER=$1
NEW_PASS=$2

MAIL_FLAG=false
DOMAIN=$(echo $MAIL_USER | cut -d"@" -f2)
MAIL=$(echo $MAIL_USER | cut -d"@" -f1)

EXIST=`grep ^$DOMAIN /etc/userdomains`

if [ "$EXIST" ]
then

CP_USER=`grep ^$DOMAIN /etc/userdomains | cut -d":" -f2 | tr -d ' '`
SHADOW_FILE="/home/$CP_USER/etc/$DOMAIN/shadow"

cat /dev/null > "/home/$CP_USER/etc/$DOMAIN/shadow.tmp"
for shadow in `cat /home/$CP_USER/etc/$DOMAIN/shadow`
do

pass=$(openssl passwd -1 $NEW_PASS)
user=$(echo $shadow | cut -d":" -f1)
rest=$(echo $shadow | cut -d":" -f3-)

if [ "$user" == "$MAIL" ]
then
MAIL_FLAG=true
echo "$user":$pass:$rest >> /home/$CP_USER/etc/$DOMAIN/shadow.tmp
else
echo $shadow >>/home/$CP_USER/etc/$DOMAIN/shadow.tmp
fi

done

if [ $MAIL_FLAG = false ]
then
echo "$1 not exists..!!";
elif [ $MAIL_FLAG = true ]
then

echo "$1 password changed to: $2"
fi
mv "/home/$CP_USER/etc/$DOMAIN/shadow" "/home/$CP_USER/etc/$DOMAIN/shadow.$(date +%s)"
mv "/home/$CP_USER/etc/$DOMAIN/shadow.tmp" "/home/$CP_USER/etc/$DOMAIN/shadow"
chmod 640 "/home/$CP_USER/etc/$DOMAIN/shadow"
chown $CP_USER:$CP_USER "/home/$CP_USER/etc/$DOMAIN/shadow"
else
echo "Domain not in the server"
fi




cPanel - Bash script to List All Mail Accounts


 Bash script to List All Mail Accounts in cPanel Server


The bash script given below will list all the mail accounts in a cpanel server and the list is saved in '/root/mailaccounts.txt'. Depending upon the total accounts, it will take time to finish script.



#!/bin/bash -  
#title          :listallmailaccounts.sh
#description    :To List All Mail Accounts in cPanel via Terminal
#author         :Arun Ghosh
#date           :20130811
#version        :1.0   
#usage          :./listallmailaccounts.sh
#notes          :      
#bash_version   :4.2.25(1)-release
#============================================================================

cat /dev/null > /root/mailaccounts.txt

CP_ACCOUNTS=`ls -1A /var/cpanel/users/`

for user in `echo -n $CP_ACCOUNTS`
do/root/mailaccounts.txt
    domain=`grep -i ^dns /var/cpanel/users/$user |cut -d= -f2`
    for dom in `echo -n "$domain"`
    do
        PASSWD_FILE="/home/$user/etc/$dom/passwd"
        if [ -f $PASSWD_FILE ] && [ -s $PASSWD_FILE ]
        then
            for mail in `cat $PASSWD_FILE| cut -d":" -f1`
            do
                echo "$mail@$dom" >> mailaccounts.txt
            done
        fi
    done
done




Forcefully recalculate/update message counts and disk quota - MDaemon




Situation:

I have removed some mails from the MDaemon server from the backend,ie, browsed through the mail box and deleted some mails maunally without using MDeamon's application. In this case, the new mail box count and quota will not reflect in the wordclient and MDaemon's backend application. You can follow the steps shown below to update the message counts and disk quota manually.

Solution:


1. The results of user quota checks are maintained in the 'MDaemon\App\quotacounts.dat' file.

Create a file named 'ClearQuotaCounts.sem'.
If you wish to clear the cached quota value for a user, add the user’s email address to this SEM file and then place it in the MDaemon\App directory.
If you wish to clear all cached counts, just place a single  * character in it. and then place 'ClearQuotaCounts.sem' file in the MDaemon\App directory.

2. Then open MDaemon and go into the Queues >> Queue and Statistics Manager



3. Once you click the 'User Page', the page will start to update with new quota and message counts. The file 'quotacounts.dat' will updated with new values once the 'User Page' is fully loaded.





Reference:
http://mdaemon.dutaint.com/9.0/RouteSlips.html

require_once(Cache/Lite.php) : failed to open stream - Joomla


Joomla Error:


Warning: require_once(Cache/Lite.php) [function.require-once]: failed to open stream: No such file or directory in /home/test/public_html/libraries/joomla/cache/storage/cachelite.php on line 75

Fatal error: require_once() [function.require]: Failed opening required 'Cache/Lite.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/test/public_html/libraries/joomla/cache/storage/cachelite.php on line 75


Fix:


Install cachelite using the following command.


[root@server ~]# pear install Cache_Lite-1.7.15

Install 'MailParse' extension - cPanel




The following installation will work with php-5.3.x

root@server [~]# cd /usr/local/src
root@server [/usr/local/src]# wget http://pecl.php.net/get/mailparse-2.1.5.tgz
root@server [/usr/local/src]# tar xvzf mailparse-2.1.5.tgz
root@server [/usr/local/src]# cd mailparse-2.1.5
root@server [/usr/local/src/mailparse-2.1.5]# phpize
root@server [/usr/local/src/mailparse-2.1.5]# ./configure
root@server [/usr/local/src/mailparse-2.1.5]# make
root@server [/usr/local/src/mailparse-2.1.5]# make install
Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-non-zts-20090626/


Once the installation is completed, you can find 'mailparse.so' file in a directory like /usr/local/lib/php/extensions/no-debug-non-zts-20090626/.

Open the php.ini file and add this extesnion. Here in my case i added an entry like the following.


root@server [~]# vi /usr/local/lib/php.ini
.
.
extension = "/usr/local/lib/php/extensions/no-debug-non-zts-20090626/mailparse.so"
.
.


Restart Apache to make the changes in effect.

root@server [~]# /etc/init.d/httpd restart


Verify wheter the extesnions is loaded or not.

root@server [~]# php -m | grep mailparse
mailparse

That's it...