ephekt/cpanel.rb
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
NOTE: Currently this supports only x3 theme for creating databases and database users. Rest of the methods can be used irrespective of the cPanel theme.
c = Cpanel.new(cpanel_username, cpanel_pass,IP/domain_name,port)
eg:
c = Cpanel.new('kilari', 'xxxxxxxx','kilari.co.in')
c = Cpanel.new('kilari', 'xxxxxxxx','74.63.8.201')
By default it will take port 2083(https).
========================================================================================================================
******Database Utility Functons******
========================================================================================================================
First you will need to set the Database type 'mysql/psql'
c.db_type = :mysql or c.db_type = :psql
public instance methods
1)list_dbs -> Returns an array of database's.
2)list_db_users -> Returns an array of database users.
3)list_db_priv(db_name) -> Returns an array of user's added the database name passed.
4)create_db(db_name) -> create a database with the database name passed.
5)create_db_user(db_user,pass) -> Created a database user with the username passed. Random password will be generated if not passed.
6)reset_user_pass(db_user,pass) -> To reset the database user password. Random password will be generated if not passed.
7)assign_user2db(db_name,db_user) -> To assign a user to a database.
8)del_db(db_name) -> To delete a database.
9)del_user(db_user) -> To delete a database user.
Return message for 4-9 methods is a hash of {:status => 'true/false', :message => '',:pass => '',:db => 'DB name', :user => 'DB user'}
'pass','db','user' key pairs are returned when required in the funtions.
Database username's and Database name are prefixed with the cPanel user name(like kilari_dbname), so while passing the DB name or Username you can pass the whole name(like kilari_dbname) or just the excluding the cPanel name(like dbname).
========================================================================================================================
========================================================================================================================
******Domain Utility Functons******
========================================================================================================================
Public instance methods
1)list_domains -> Return an array if addon,parked,main domains.
2)get_doc_root(domain_name) -> Returns the absolute path for the domain's document root.
3)list_park_domains -> Returns and array of the parked domains.
4)list_addon_domains -> Returns and array of addon domains.
5)list_sub_domains -> Returns and array of sub domains.
6)main_domain -> Returns the main domain of the account.
7)is_park_domain?(domain_name)
8)is_addon_domain?(domain_name)
9)is_sub_domain?(domain_name)
10)is_main_domain?(domain_name)
11)park_domain(domain_name) -> Park a domain
12)add_addon_domain(domain_name,doc_root,ftp_user,pass) -> Add a addon domain
13)add_sub_domain(sub_domain_name,main_domain,pass) -> Add a sub domain
14)del_park_domain(domain_name) -> Delete a parked domain
15)del_addon_domain(domain_name) -> Delete a add on domain
16)del_sub_domain(domain_name) -> Delete a sub domain