Class: CpanelApi::Whm::Commands

Inherits:
Object
  • Object
show all
Includes:
Cpanel, Model, Remote
Defined in:
lib/panelbeater/whm/commands.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Remote

#connect, #do_request, #map_options_to_url, #set_server

Methods included from Model

#filter_options, #key_mappings

Constructor Details

#initialize(options = {}) ⇒ Commands

Returns a new instance of Commands.



13
14
15
16
17
# File 'lib/panelbeater/whm/commands.rb', line 13

def initialize(options={})
  @log = Logger.new(STDOUT)
  @log.level = Logger::INFO
  set_server(options)
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



10
11
12
# File 'lib/panelbeater/whm/commands.rb', line 10

def api_key
  @api_key
end

#base_urlObject

Returns the value of attribute base_url.



8
9
10
# File 'lib/panelbeater/whm/commands.rb', line 8

def base_url
  @base_url
end

#portObject

Returns the value of attribute port.



11
12
13
# File 'lib/panelbeater/whm/commands.rb', line 11

def port
  @port
end

#userObject

Returns the value of attribute user.



9
10
11
# File 'lib/panelbeater/whm/commands.rb', line 9

def user
  @user
end

Instance Method Details

#accountsummary(user) ⇒ Object

Get a users account summary



22
23
24
# File 'lib/panelbeater/whm/commands.rb', line 22

def accountsummary(user)
  do_request 'accountsummary', {:user => user}
end

#addpkg(options = {}, mappings = nil) ⇒ Object

Add a new package

required params: name quota maxftp maxsql maxpop maxlists maxsub maxpark maxaddon bwlimit



41
42
43
44
45
46
47
48
49
50
# File 'lib/panelbeater/whm/commands.rb', line 41

def addpkg(options={}, mappings=nil)
  default_options = { :featurelist => 'default',
                      :ip => 0,
                      :cgi => 1,
                      :frontpage => 0,
                      :cpmod => 'x3',
                      :hasshell => 0 }
  all_options = default_options.merge!(options)
  do_request 'addpkg', all_options, mappings
end

#applistObject

Returns a list of available commands



53
54
55
# File 'lib/panelbeater/whm/commands.rb', line 53

def applist
  do_request 'applist'
end

#changepackage(user, package) ⇒ Object

Change a users package



58
59
60
# File 'lib/panelbeater/whm/commands.rb', line 58

def changepackage(user, package)
  do_request 'changepackage', {:user => user, :pkg => package}
end

#cpanel(user, options = {}) ⇒ Object

Call cpanel API1 and API2 commands

user (string) The name of the user that owns the cPanel account to be affected. xmlin (XML) XML container for the function. Format <cpanelaction><module><func><args></args></func></module></cpanelaction> module (string) Name of the module to access. (See www.cpanel.net/plugins/api2/index.html for module and function names) apiversion (integer) Version of the API to access. (1 = API1, no input defaults to API2) func (string) Name of the function to access. (See www.cpanel.net/plugins/api2/index.html for module and function names) args (XML or string) List of arguments or argument container. See examples for API1 and API2 passing arguments.



77
78
79
80
81
# File 'lib/panelbeater/whm/commands.rb', line 77

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

#createacct(options = {}, mappings = nil) ⇒ Object

Create a new account

username (string) User name of the account. Ex: user domain (string) Domain name. Ex: domain.tld plan (string) Package to use for account creation. Ex: reseller_gold quota (integer) Disk space quota in MB. (0-999999, 0 is unlimited) password (string) Password to access cPanel. Ex: p@ss!w0rd$123 ip (string) Whether or not the domain has a dedicated IP address. (y = Yes, n = No) cgi (string) Whether or not the domain has cgi access. (y = Yes, n = No) frontpage (string) Whether or not the domain has FrontPage extensions installed. (y = Yes, n = No) hasshell (string) Whether or not the domain has shell / ssh access. (y = Yes, n = No) contactemail (string) Contact email address for the account. Ex: [email protected] cpmod (string) cPanel theme name. Ex: x3 maxftp (string) Maximum number of FTP accounts the user can create. (0-999999 | unlimited, null | 0 is unlimited) maxsql (string) Maximum number of SQL databases the user can create. (0-999999 | unlimited, null | 0 is unlimited) maxpop (string) Maximum number of email accounts the user can create. (0-999999 | unlimited, null | 0 is unlimited) maxlst (string) Maximum number of mailing lists the user can create. (0-999999 | unlimited, null | 0 is unlimited) maxsub (string) Maximum number of subdomains the user can create. (0-999999 | unlimited, null | 0 is unlimited) maxpark (string) Maximum number of parked domains the user can create. (0-999999 | unlimited, null | 0 is unlimited) maxaddon (string) Maximum number of addon domains the user can create. (0-999999 | unlimited, null | 0 is unlimited) bwlimit (string) Bandiwdth limit in MB. (0-999999, 0 is unlimited) customip (string) Specific IP address for the site. useregns (boolean) Use the registered nameservers for the domain instead of the ones configured on the server. (1 = Yes, 0 = No) hasuseregns (boolean) Set to 1 if you are using the above option. reseller (boolean) Give reseller privileges to the account. (1 = Yes, 0 = No)



132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/panelbeater/whm/commands.rb', line 132

def createacct(options={}, mappings=nil)
  default_options = { :featurelist => 'default',
                      :ip => 'n',
                      :cgi => 'y',
                      :frontpage => 'n',
                      :cpmod => 'x3',
                      :hasshell => 'n',
                      :maxlst => 0,
                      :reseller => 0 }
  all_options = default_options.merge!(options)
  do_request 'createacct', all_options, mappings
end

#editpkg(name, options = {}, mappings = nil) ⇒ Object

Edits an existing package

name (string) Name of the package. featurelist (string) Name of the feature list to be used for the package. quota (integer) Disk space quota for the package (in MB). (max is unlimited) ip (boolean) Whether or not the account has a dedicated IP. Yes=1, No=0. cgi (boolean) Whether or not the account has cgi access. Yes=1, No=0. frontpage (boolean) Whether or not the account can install FrontPage extensions. Yes=1, No=0. cpmod (string) What to change the default package them to. Format: cpmod=themename maxftp (integer) The maximum amount of FTP accounts a user assigned to the package can create. (max is 999) maxsql (integer) The maximum amount of SQL databases a user assigned to the package can create. (max is 999) maxpop (integer) The maximum amount of email accounts a user assigned to the package can create. (max is 999) maxlists (integer) The maximum amount of email lists a user assigned to the package can create. (max is 999) maxsub (integer) The maximum amount of subdomains a user assigned to the package can create. (max is 999) maxpark (integer) The maximum amount of parked domains a user assigned to the package can create. (max is 999) maxaddon (integer) The maximum amount of addon domains a user assigned to the package can create. (max is 999) hasshell (boolean) Whether or not the account has shell access. Yes=1, No=0. bwlimit (integer)



179
180
181
182
183
184
185
186
187
188
189
# File 'lib/panelbeater/whm/commands.rb', line 179

def editpkg(name, options={}, mappings=nil)
  default_options = { :featurelist => 'default',
                      :ip => 'n',
                      :cgi => 'y',
                      :frontpage => 'n',
                      :cpmod => 'x3',
                      :hasshell => 'n',
                      :maxlists => '0' }
  all_options = default_options.merge!(options).merge!(:name => name)
  do_request 'editpkg', all_options, mappings
end

#fetchsslinfoObject



191
192
193
# File 'lib/panelbeater/whm/commands.rb', line 191

def fetchsslinfo
    
end

#generatesslObject



195
196
197
# File 'lib/panelbeater/whm/commands.rb', line 195

def generatessl
    
end

#gethostnameObject

Get the hostname of the server



200
201
202
# File 'lib/panelbeater/whm/commands.rb', line 200

def gethostname
  do_request 'gethostname'
end

#getlanglistObject

List of available languages



205
206
207
# File 'lib/panelbeater/whm/commands.rb', line 205

def getlanglist
  do_request 'getlanglist'
end

#killpkg(package) ⇒ Object

Deletes a package from the server



210
211
212
# File 'lib/panelbeater/whm/commands.rb', line 210

def killpkg(package)
  do_request 'killpkg', {:pkg => package}
end

#listaccts(term, options = {}) ⇒ Object

Searches for an account

searchtype Type of account search. (domain | owner | user | ip | package ) search Search criteria. (Perl Regular Expression)



221
222
223
224
225
# File 'lib/panelbeater/whm/commands.rb', line 221

def listaccts(term, options={})
  default_options = {:searchtype => 'user'}
  all_options = default_options.merge!(options).merge!(:search => term)
  do_request 'listaccts', all_options
end

#listaclsObject

Reseller functionality not needed yet



228
229
230
# File 'lib/panelbeater/whm/commands.rb', line 228

def listacls
    
end

#listcrtsObject



232
233
234
# File 'lib/panelbeater/whm/commands.rb', line 232

def listcrts
    
end

#listpkgsObject

List packages on server



237
238
239
# File 'lib/panelbeater/whm/commands.rb', line 237

def listpkgs
  do_request 'listpkgs'
end

#listresellersObject

Reseller functionality not needed yet



242
243
244
# File 'lib/panelbeater/whm/commands.rb', line 242

def listresellers
    
end

#listsuspendedObject

List suspended accounts



247
248
249
# File 'lib/panelbeater/whm/commands.rb', line 247

def listsuspended
  do_request 'listsuspended'
end

#loadavgObject

Get the server load average



252
253
254
# File 'lib/panelbeater/whm/commands.rb', line 252

def loadavg
  do_request 'loadavg'
end

#passwd(user, password) ⇒ Object

Change and accounts password



257
258
259
# File 'lib/panelbeater/whm/commands.rb', line 257

def passwd(user, password)
  do_request 'passwd', {:user => user, :pass => password}
end

#rebootObject

Reboot the server, don’t know if this works or if it takes any arguments



262
263
264
# File 'lib/panelbeater/whm/commands.rb', line 262

def reboot
  do_request 'reboot'
end

#removeacct(user, options = {}) ⇒ Object

Remore and account from the server



267
268
269
270
271
# File 'lib/panelbeater/whm/commands.rb', line 267

def removeacct(user, options={})
  default_options = {:keepdns => false}
  all_options = default_options.merge!(options).merge!(:user => user)
  do_request 'removeacct', all_options
end

#resellerstatsObject

Reseller functionality not needed yet



274
275
276
# File 'lib/panelbeater/whm/commands.rb', line 274

def resellerstats
    
end

#restartservice(service) ⇒ Object

Restart a service on the server

service Service to restart (bind | interchange | ftp | httpd | imap | cppop | exim | mysql | postgres | ssh | tomcat)



283
284
285
# File 'lib/panelbeater/whm/commands.rb', line 283

def restartservice(service)
  do_request 'restartservice', :service => service
end

#saveacllistObject

Reseller functionality not needed yet



288
289
290
# File 'lib/panelbeater/whm/commands.rb', line 288

def saveacllist
    
end

#setaclsObject

Reseller functionality not needed yet



293
294
295
# File 'lib/panelbeater/whm/commands.rb', line 293

def setacls
    
end

#setupresellerObject

Reseller functionality not needed yet



298
299
300
# File 'lib/panelbeater/whm/commands.rb', line 298

def setupreseller
    
end

#showbwObject

Get bandwidth usage for all users, don’t know if this takes additional parameters



303
304
305
# File 'lib/panelbeater/whm/commands.rb', line 303

def showbw
  do_request 'showbw'
end

#suspendacct(user, reason) ⇒ Object

Suspend an account



308
309
310
# File 'lib/panelbeater/whm/commands.rb', line 308

def suspendacct(user, reason)
  do_request 'suspendacct', {:user => user, :reason => reason}
end

#terminateresellerObject

Reseller functionality not needed yet



313
314
315
# File 'lib/panelbeater/whm/commands.rb', line 313

def terminatereseller
    
end

#unsetupresellerObject

Reseller functionality not needed yet



318
319
320
# File 'lib/panelbeater/whm/commands.rb', line 318

def unsetupreseller
    
end

#unsuspendacct(user) ⇒ Object

Unsuspend an account



323
324
325
# File 'lib/panelbeater/whm/commands.rb', line 323

def unsuspendacct(user)
  do_request 'unsuspendacct', :user => user
end

#versionObject

Get the of WHM



328
329
330
# File 'lib/panelbeater/whm/commands.rb', line 328

def version
  do_request 'version'
end