Class: Panelbeater::Whm::Commands
- Inherits:
-
Object
- Object
- Panelbeater::Whm::Commands
- Defined in:
- lib/panelbeater/whm/commands.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#port ⇒ Object
Returns the value of attribute port.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#accountsummary(user) ⇒ Object
Get a users account summary.
-
#addpkg(options = {}, mappings = nil) ⇒ Object
Add a new package.
-
#applist ⇒ Object
Returns a list of available commands.
-
#changepackage(user, package) ⇒ Object
Change a users package.
-
#cpanel(user, options = {}) ⇒ Object
Call cpanel API1 and API2 commands.
-
#createacct(options = {}, mappings = nil) ⇒ Object
Create a new account.
-
#editpkg(name, options = {}, mappings = nil) ⇒ Object
Edits an existing package.
- #fetchsslinfo ⇒ Object
- #generatessl ⇒ Object
-
#gethostname ⇒ Object
Get the hostname of the server.
-
#getlanglist ⇒ Object
List of available languages.
-
#initialize(options = {}) ⇒ Commands
constructor
A new instance of Commands.
-
#killpkg(package) ⇒ Object
Deletes a package from the server.
-
#listaccts(term = nil, options = {}) ⇒ Object
Searches for an account.
-
#listacls ⇒ Object
Reseller functionality not needed yet.
- #listcrts ⇒ Object
-
#listpkgs ⇒ Object
List packages on server.
-
#listresellers ⇒ Object
Reseller functionality not needed yet.
-
#listsuspended ⇒ Object
List suspended accounts.
-
#loadavg ⇒ Object
Get the server load average.
-
#passwd(user, password) ⇒ Object
Change and accounts password.
-
#reboot ⇒ Object
Reboot the server, don’t know if this works or if it takes any arguments.
-
#removeacct(user, options = {}) ⇒ Object
Remore and account from the server.
-
#resellerstats ⇒ Object
Reseller functionality not needed yet.
-
#restartservice(service) ⇒ Object
Restart a service on the server.
-
#saveacllist ⇒ Object
Reseller functionality not needed yet.
-
#setacls ⇒ Object
Reseller functionality not needed yet.
-
#setupreseller ⇒ Object
Reseller functionality not needed yet.
-
#showbw ⇒ Object
Get bandwidth usage for all users, don’t know if this takes additional parameters.
-
#suspendacct(user, reason) ⇒ Object
Suspend an account.
-
#terminatereseller ⇒ Object
Reseller functionality not needed yet.
-
#unsetupreseller ⇒ Object
Reseller functionality not needed yet.
-
#unsuspendacct(user) ⇒ Object
Unsuspend an account.
-
#version ⇒ Object
Get the of WHM.
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(={}) @log = Logger.new(STDOUT) @log.level = Logger::INFO set_server() end |
Instance Attribute Details
#api_key ⇒ Object
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_url ⇒ Object
Returns the value of attribute base_url.
8 9 10 |
# File 'lib/panelbeater/whm/commands.rb', line 8 def base_url @base_url end |
#port ⇒ Object
Returns the value of attribute port.
11 12 13 |
# File 'lib/panelbeater/whm/commands.rb', line 11 def port @port end |
#user ⇒ Object
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(={}, mappings=nil) = { :featurelist => 'default', :ip => 0, :cgi => 1, :frontpage => 0, :cpmod => 'x3', :hasshell => 0 } = .merge!() do_request 'addpkg', , mappings end |
#applist ⇒ Object
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, ={}) = { :apiversion => 2 } = .merge!().merge!(:user => user) do_request 'cpanel', 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(={}, mappings=nil) = { :featurelist => 'default', :ip => 'n', :cgi => 'y', :frontpage => 'n', :cpmod => 'x3', :hasshell => 'n', :maxlst => 0, :reseller => 0 } = .merge!() do_request 'createacct', , 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, ={}, mappings=nil) = { :featurelist => 'default', :ip => 'n', :cgi => 'y', :frontpage => 'n', :cpmod => 'x3', :hasshell => 'n', :maxlists => '0' } = .merge!().merge!(:name => name) do_request 'editpkg', , mappings end |
#fetchsslinfo ⇒ Object
191 192 193 |
# File 'lib/panelbeater/whm/commands.rb', line 191 def fetchsslinfo end |
#generatessl ⇒ Object
195 196 197 |
# File 'lib/panelbeater/whm/commands.rb', line 195 def generatessl end |
#gethostname ⇒ Object
Get the hostname of the server
200 201 202 |
# File 'lib/panelbeater/whm/commands.rb', line 200 def gethostname do_request 'gethostname' end |
#getlanglist ⇒ Object
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 = nil, 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 226 227 228 229 230 231 |
# File 'lib/panelbeater/whm/commands.rb', line 221 def listaccts(term = nil, ={}) if term.nil? # Lists all Accounts do_request 'listaccts' else # Lists accounts accorning to the search term = {:searchtype => 'user'} = .merge!().merge!(:search => term) do_request 'listaccts', end end |
#listacls ⇒ Object
Reseller functionality not needed yet
234 235 236 |
# File 'lib/panelbeater/whm/commands.rb', line 234 def listacls end |
#listcrts ⇒ Object
238 239 240 |
# File 'lib/panelbeater/whm/commands.rb', line 238 def listcrts end |
#listpkgs ⇒ Object
List packages on server
243 244 245 |
# File 'lib/panelbeater/whm/commands.rb', line 243 def listpkgs do_request 'listpkgs' end |
#listresellers ⇒ Object
Reseller functionality not needed yet
248 249 250 |
# File 'lib/panelbeater/whm/commands.rb', line 248 def listresellers end |
#listsuspended ⇒ Object
List suspended accounts
253 254 255 |
# File 'lib/panelbeater/whm/commands.rb', line 253 def listsuspended do_request 'listsuspended' end |
#loadavg ⇒ Object
Get the server load average
258 259 260 |
# File 'lib/panelbeater/whm/commands.rb', line 258 def loadavg do_request 'loadavg' end |
#passwd(user, password) ⇒ Object
Change and accounts password
263 264 265 |
# File 'lib/panelbeater/whm/commands.rb', line 263 def passwd(user, password) do_request 'passwd', {:user => user, :pass => password} end |
#reboot ⇒ Object
Reboot the server, don’t know if this works or if it takes any arguments
268 269 270 |
# File 'lib/panelbeater/whm/commands.rb', line 268 def reboot do_request 'reboot' end |
#removeacct(user, options = {}) ⇒ Object
Remore and account from the server
273 274 275 276 277 |
# File 'lib/panelbeater/whm/commands.rb', line 273 def removeacct(user, ={}) = {:keepdns => false} = .merge!().merge!(:user => user) do_request 'removeacct', end |
#resellerstats ⇒ Object
Reseller functionality not needed yet
280 281 282 |
# File 'lib/panelbeater/whm/commands.rb', line 280 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)
289 290 291 |
# File 'lib/panelbeater/whm/commands.rb', line 289 def restartservice(service) do_request 'restartservice', :service => service end |
#saveacllist ⇒ Object
Reseller functionality not needed yet
294 295 296 |
# File 'lib/panelbeater/whm/commands.rb', line 294 def saveacllist end |
#setacls ⇒ Object
Reseller functionality not needed yet
299 300 301 |
# File 'lib/panelbeater/whm/commands.rb', line 299 def setacls end |
#setupreseller ⇒ Object
Reseller functionality not needed yet
304 305 306 |
# File 'lib/panelbeater/whm/commands.rb', line 304 def setupreseller end |
#showbw ⇒ Object
Get bandwidth usage for all users, don’t know if this takes additional parameters
309 310 311 |
# File 'lib/panelbeater/whm/commands.rb', line 309 def showbw do_request 'showbw' end |
#suspendacct(user, reason) ⇒ Object
Suspend an account
314 315 316 |
# File 'lib/panelbeater/whm/commands.rb', line 314 def suspendacct(user, reason) do_request 'suspendacct', {:user => user, :reason => reason} end |
#terminatereseller ⇒ Object
Reseller functionality not needed yet
319 320 321 |
# File 'lib/panelbeater/whm/commands.rb', line 319 def terminatereseller end |
#unsetupreseller ⇒ Object
Reseller functionality not needed yet
324 325 326 |
# File 'lib/panelbeater/whm/commands.rb', line 324 def unsetupreseller end |
#unsuspendacct(user) ⇒ Object
Unsuspend an account
329 330 331 |
# File 'lib/panelbeater/whm/commands.rb', line 329 def unsuspendacct(user) do_request 'unsuspendacct', :user => user end |
#version ⇒ Object
Get the of WHM
334 335 336 |
# File 'lib/panelbeater/whm/commands.rb', line 334 def version do_request 'version' end |