====== Managing ispCP Daemon with CLI ====== ===== The domain.php script ===== Having the ability to create domains or services from the command line is a must for a control panel. After some effort I have created a tool to help with that. Basically the idea behind it is so you can use it altogether with rsync to migrate from other control panels (such as plesk) in a fully automated way. The objective is to code the minimum possible and use all the ispcp methods, so most of the stuff done in the scripts is to insert the new registers on the database, trying always to be conservative about deleting stuff. This Command line a is a work in progress, is full of TODO within the code, but will help the people meanwhile someone does something better. And it's being used on a production environment at the moment. At the moment, it's not part of the project, so don't take it as an official tool because it isn't ===== Where to get it ===== You can get the last version at this thread: http://www.isp-control.net/forum/thread-4255-post-35948.html Also that's the place where problems, suggestions and all that stuff should be posted ===== How to use it ===== Once you dowload it, after extracting the files, the first thing you have to do is to copy the config.php.dist to config.php and change the variables to fit your environment (all of them should be self explanatory, you can ask on the forum otherwise). There are two different scripts you can use to manage your server: **domain.php**: This script allows you to create all the stuff you need to be able to migrate a domain, such as the mailboxes, the mail aliases, the ftp accounts, and much more, also it allow you to delete domains and domains_alias. **domain_dns.php**: This script helps you to administrate the dns for your domains. With it you can create any kind of dns type allowed by the control panel. You can do the following: Create a new domain and the administrator for it php domain.php --action create_domain --created_by 'admin' --domain 'example.com' --password 'adminpass' --hosting_plan 'FullPlan'" Change the ownership of the htdocs direcory to be the right one (also for the htsdocs) php domain.php --action fix_htdocs_owner --domain 'example.com'" Also, not less important: * create_ftp * create_mail * create_mail_alias * create_dom_alias * create_db * create_db_user * create_subdomain * regenerate_domain * create_default_mail * disable_mail * enable_mail * create_htaccess_user #Creates a htaccess user to be used to protect a folder or view stats * join_htaccess_group #Joins the htaccess user to the stats group to see statistics * set_mail_limit With the domain_dns.php you can do the following: * create_dns The current release has the ability to delete domains too. This is DANGEROUS, I am running it without problems in a system with 1.0.5, but double check before using it, because the changes are permanent, and there's no way to recover the deleted domains. In case you want to try it, launch the domain.php with the option: * delete_domain * delete_alias ===== Example ===== #Domain creation php domain.php --action create_domain --created_by 'reseller' --domain 'example.com' --password 'adminpass' --hosting_plan 'FullPlan'" #Ftp creation php domain.php --action 'create_ftp' --created_by 'reseller' --domain 'example.com' --user 'admin' --password 'adminpass'; #Creating the default mailboxes (postmaster, webmaster and abuse) php domain.php --action 'create_default_mail' --domain 'example.com'; #In case you want to customize the dns entries for some customers, you should edit the db_e.tpl # file removing what you want to customize and create the entries for EVERY domain. #You only have to create the www entry in case you allow your customers to customize them. php domain_dns.php --action 'create_dns' --domain 'example.com' --dns_type 'CNAME' --dns_sub 'www' --dns_txt 'example.com.'; #You only have to create the mx entries if you let your customers to customize them # in that case you should alter the dns templates) php domain_dns.php --action 'create_dns' --domain 'example.com' --dns_type 'MX' --dns_sub 'example.com.' --dns_txt 'mx1.example.com.' --dns_prio '10'; php domain_dns.php --action 'create_dns' --domain 'example.com' --dns_type 'MX' --dns_sub 'example.com.' --dns_txt 'mx2.example.com.' --dns_prio '20'; TODO, add detail to add the htusers/htgroup for awstats ===== Test scripts ===== In the tar file, you will also find a bash script called verify_cli.sh, that will print the commands to create a complete domain.