Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 72 additions & 1 deletion Readme.markdown
Original file line number Diff line number Diff line change
@@ -1 +1,72 @@
#cPanel gem
WHM
WebHost Manager (WHM) is a web-based tool used by server administrators and resellers to manage hosting accounts on a web server.
WHM listens on ports 2086 and 2087 by default.

cPanel
cPanel is a Unix based web hosting control panel that provides a graphical interface and automation tools designed to simplify the process of hosting a web site. cPanel utilizes a 3 tier structure that provides functionality for administrators, resellers, and end-user website owners to control the various aspects of website and server administration through a standard web browser.
cPanel is commonly accessed on port 2082, with an SSL-secured server operating on port 2083.

Use cpanel and Whm API's in Rails
Panelbeater gem is used for communicating with the cPanel and WHM API's.
Ruby library for the WHM & cPanel API.

Install
require 'panelbeater'
In the model where you want to use.


Usage
Create a server object and connect to WHM using your host and hash:

server = Panelbeater::Whm::Commands.new(
:url => url,
:api_key => secure_hash,
:port => port,
:user => username
)

Now,you can access the modules of WHM by calling server.<module>


Account Example
1. Creating a new account
It requires only a username, domain

result = server.createacct(
:username => 'newuser',
:domain => 'newuser.com'
)

Output

createaact => {result => { :status => boolean, :statusmsg => "" }}

status (boolean) — Status of the operation.

1 — success.
0 — failure.

statusmsg (string) — Status or error message.



Reference : - http://docs.cpanel.net/twiki/bin/view/SoftwareDevelopmentKit/CreateAccount

2. Delete account
It requires only user

result = server.removeacct(:user => 'newuser')

Output

removeacct => {result => { :status => boolean, :statusmsg => "" }}

status (boolean) — Status of the operation.

1 — success.
0 — failure.

statusmsg (string) — Message about the status of the operation.


Reference :- http://docs.cpanel.net/twiki/bin/view/SoftwareDevelopmentKit/TerminateAccount
2 changes: 1 addition & 1 deletion lib/panelbeater/whm/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def changepackage(user, package)

def cpanel(user, options={})
default_options = { :apiversion => 2 }
all_options = default_options.merge!(options).merge!(:user => user)
all_options = default_options.merge!(options).merge!(:cpanel_jsonapi_user => user)
do_request 'cpanel', all_options
end

Expand Down