Cpanel Hooks and custom configurations

Modifying the source code of cpanel control panel is prohibited by End User License Agreement (EULA)

So how would you implement some custom fucnctionality?

Cpanel provides something called hooks! for this purpose .Hooks are basically files that are checked and if present executed after someĀ  internal cpanel process like account creation,termination etc

I would provide the example of a hook to help you understand how to accomplish some extra tasks if required in a cpanel powered server

This isĀ  a small program and it just prints out the names of the domain being created to a file:

Create the file /scripts/postwwwacct with the following contents

================

#!/usr/bin/perl
my %OPTS = @ARGV;
open (MYFILE, ‘>> /opt/test’);
print MYFILE “$OPTS{’domain’}\n”;
close (MYFILE);

==================

Now whenever you create an account in whm the domain name gets appended in the file /opt/test .This can be further extended by adding more perl/php script or calling scripts from your favourite language from the postwwwacct file

The official Cpanel Hooks Documentation is here : http://www.cpanel.net/support/docs/hooks.htm

Posted under cpanel, hosting

This post was written by Anoop Alias on November 12, 2008

Tags: ,

Good WHM-cpanel troubleshooting guide

The following guide (property of Cpanel.net ) is a good starting point in troubleshooting cpanel /whm problems

Please note that this document belongs to Cpanel.net and may contain proprietary informationr

Download a copy from here

http://gnusys.net/downloads/Troubleshooting.pdf

Posted under cpanel, hosting

This post was written by Anoop Alias on August 26, 2008

Tags: ,

SSH Service failed and you can’t start it using Cpanel..

Consider the scenario :- SSH service in your server ( CPanel ) has falied and its not allowing you to login from backend. But you can login to WHM with any issues. Trying to restart SSH using WHM > Restart Services also is giving a “Failed” result .

or

You have changed the SSH port for server hardening , but forgot to add the new port to the firewall rules. And after you logout from the current shell you cant login using both ports: -

Please paste the following to your browser

http://your_server_ip:2086/scripts2/doautofixer?autofix=safesshrestart

This will reset the current SSH configuration to default configuration and safely restart SSH. As you all know this only works on a Cpanel Server!

Posted under cpanel

This post was written by manu suresh on August 6, 2008

Tags:

cpanel script to extract reseller users and domain names

This bash script is very useful if you are planning to do cpanel account migrations purely from the commandline and automate the process of the migration . This scripts extracts the names of all reseller users in the server to the file

/opt/reseller_list

and correspondingly for all users in this list extract the cpanel usernames to the file /opt/reseller_users_<resellername>

and all domains under the reseller to

/opt/reseller_domains_<resellername>

Once done with your use you can clean out the files created by the script using the single command

rm -f /opt/reseller*

As always this script is not fool proof but was perfected after several tries of a very large account migration process.You are welcome to send modifications and ideas to enhance this script

*This script can be run on successfully only on Cpanel servers and is tested upto Cpanel version 11

wget http://gnusys.net/downloads/cpanelresellerdetails.bash

bash cpanelresellerdetails.bash

Posted under cpanel, hosting

This post was written by Anoop Alias on May 25, 2008

Tags: ,