Current time: 04-20-2024, 01:13 AM Hello There, Guest! (LoginRegister)


Thread Closed 
[HOWTO] Using the CLI to manage ispcp via command line (scripts)
Author Message
aseques Offline
Member
*****
Dev Team

Posts: 330
Joined: May 2008
Reputation: 4
Post: #1
[HOWTO] Using the CLI to manage ispcp via command line (scripts)
I wanted to create create a set of tools to be able to create/modify/delete domains from the command line.
This approach will be most practical when doing migrations from other control panels for example, with the list of domains+passwords, you'd be able to replicate the system in a few minutes.
There is some documentation about usage at the dokuwiki here.
For any suggestions, modifications of the code,etc .. post it here or edit the wiki, so it can be useful for us all

Contributing code
If you want to test and improve the most current code, you can connect to:
http://bitbucket.org/aseques/ispcp-cli/src

UPDATE
Fixed the creation of TXT dns entries
See CHANGELOG to view the full list of changes

It's designed to work at least with the current 1.0.7 (there are older working versions too)
You can call it something like:
php domain.php --action create_domain --created_by "reseller" --domain "example.com" --password "password25" --hosting_plan "FullPlan"
To create the hosting for the domain example.com using the template FullPlan and with the admin password password25, note that when creating a domain, the name of the admin and the domain will be the same (due to the script limitations)
or
php domain.php --action create_ftp --created_by "reseller" --domain "example.com" --password "password25" --hosting_plan "FullPlan" --user "username"
To create the ftp account username@example.com for the previous domain.

To check the usual syntax of many of the commands, you can user the verify_cli.sh that will create a sample domain with most of the features..

It has been extensively tested, and it shouldn't break anything.
For anyone interested in using the script, I'm not a programmer so the code probably will hurt your eyes, any advice will be taken into consideration.
I hope it will be of use to you.

UPDATE: New features are included in every new release of this scripts, acording with the new features in ispcp, but the syntax and the core functionality is basically the same.

There is the version working in ispcp 1.0.3.1
.gz  scripts_1_0_3_1.tar.gz (Size: 14.86 KB / Downloads: 24)

There is the version working for ispcp 1.0.4
.gz  scripts_1_0_4.tar.gz (Size: 14.89 KB / Downloads: 40)

The version for ispcp 1.0.5 and 1.0.6
.gz  scripts_1_0_5.tar.gz (Size: 12.99 KB / Downloads: 35)

The version for 1.0.7 and current trunk
.gz  scripts_1_0_7.tar.gz (Size: 14.26 KB / Downloads: 95)

NOTE: For the version working on 1.0.0 systems send me a PM, it's obsoleted and might confuse people.
(This post was last modified: 08-02-2011 02:25 AM by aseques.)
09-13-2008 02:34 AM
Find all posts by this user
suw Offline
Junior Member
*

Posts: 17
Joined: Sep 2008
Reputation: 0
Post: #2
RE: Using the CLI with ispcp (wiki article)
nice to see this already done. I was a little bit bussy in the last week, had no time to edit that wiki page myself.

Thank you
(This post was last modified: 09-15-2008 08:01 AM by suw.)
09-15-2008 07:41 AM
Find all posts by this user
four2theizz0 Offline
Junior Member
*

Posts: 59
Joined: Sep 2008
Reputation: 0
Post: #3
RE: Using the CLI with ispcp (wiki article)
Hi,

This sounds great, but I think I am missing something. I am able to telnet in and connect.
But I am not sure what queries to run. Where can I see these?

Thank you
10-03-2008 11:55 AM
Find all posts by this user
aseques Offline
Member
*****
Dev Team

Posts: 330
Joined: May 2008
Reputation: 4
Post: #4
RE: Using the CLI with ispcp (wiki article)
(10-03-2008 11:55 AM)four2theizz0 Wrote:  Hi,

This sounds great, but I think I am missing something. I am able to telnet in and connect.
But I am not sure what queries to run. Where can I see these?

Thank you

This article in the wiki is just a stub, I wanted to start the documentation, but I still haven't used this feature (I'm sure I'll need it in the future tough).
Basically you should do some insert queries on one of this tables filling the same fields they're using now.

The interesting tables are this ones:
domain, subdomain, , domain_aliasses, mail_users

If you succeed, please post your results or update the docs ..

Cheers
10-03-2008 05:34 PM
Find all posts by this user
suw Offline
Junior Member
*

Posts: 17
Joined: Sep 2008
Reputation: 0
Post: #5
RE: Using the CLI with ispcp (wiki article)
I feel like I have to explain why is this usefull or for who this "direct communication wiht ispcp daemon" can be usefull.

Suppose you have a customer who devel. programs and want that on each registered program to give an e-mail address to customer, the program has pop/imap connection and can send mails and so on everybody's happy. Now. how in the name of sacre cow would you do this?
1. the registration server is somewhere in russia, has an IP you-re and your server are located in germany - for example.
2. the registration server can't connect to mysql ,but it's ip is allowed to access a folder restricted with .htaccess.

how can you do this/
Each registered customer is made manually - If you wish to be called on 1am coz some lammer just bought the program and registered and now he wants to comunicate with others.... it's a solution. But since most of us are programmers or have some minimal skills to write a php script and a .htaccess file, the second solution is to make a script separately from ispcp who can add in ispcp's database -> email table a new email account with status - toadd and after adding this to tell ispcp's daemon to do it's magic.

When I first put myself in this position - i tought that we will use C to communicate with the ispcp daemon and tell to do it's magic, but needed also the exact method how to communicate with it.
After I've read the php function i've realized that, that file can be copied on any projects and use direct communication with ispcp's daemon.

I hope you understand why we did this. Future NEW developers will not loose time that we lost, because our time once lost we considered that we gain some experience and it will be nice to share with others.

cheers and have fun with ispcp.
10-07-2008 01:12 AM
Find all posts by this user
aseques Offline
Member
*****
Dev Team

Posts: 330
Joined: May 2008
Reputation: 4
Post: #6
RE: Using the CLI with ispcp
I am bringing to lilve this topic again, as I am trying to make something useful of this.

I started to look into the databases for the changes that would be necessary to make a domain creation.
Basically I would like to do something like:

add_domain.php --domain example.com --password password --hosting_plan basic

So I can create a domain from the command line (i.e. from my own administration scripts)

Anyone know what's the minimum information I'd need to launch the new domain process?

Thanks
05-08-2009 11:26 PM
Find all posts by this user
pgentoo Offline
Member
*****
Dev Team

Posts: 326
Joined: Mar 2007
Reputation: 0
Post: #7
RE: Using the CLI with ispcp (wiki article)
I would just see what the minimum fields you can give during domain creation in the UI are, and then take those in via the script. For sure, domain, email, password. I believe all that needs to be done is to insert the record into the admin and domain tables, and then call the request manager script. Not 100% on that though, but it should be a good start.

Some problems though... I believe the welcome email is done through the GUI, where this should be moved into the engine at some point (for reasons like this). So if you want to send the welcome email, you'll have to do that on your own... Sad

Hope this helps...

-
pgentoo
05-09-2009 10:57 AM
Find all posts by this user
sci2tech Away
Senior Member
****

Posts: 1,285
Joined: Jan 2007
Reputation: 23
Post: #8
RE: Using the CLI with ispcp (wiki article)
Maybe this will help
Needed query.
PHP Code:
    $query "
        INSERT INTO `admin` (
            `admin_name`, `admin_pass`, `admin_type`, `domain_created`,
            `created_by`, `fname`, `lname`,
            `firm`, `zip`, `city`, `state`,
            `country`, `email`, `phone`,
            `fax`, `street1`, `street2`,
            `customer_id`, `gender`
        )
        VALUES (
            ?, ?, 'user', unix_timestamp(),
            ?, ?, ?,
            ?, ?, ?, ?,
            ?, ?, ?,
            ?, ?, ?,
            ?, ?
        )
    "

Needed fields: admin_name, admin_pass, admin_type, created_by, email.
PHP Code:
$query "
        INSERT INTO `domain` (
            `domain_name`, `domain_admin_id`,
            `domain_created_id`, `domain_created`,
            `domain_mailacc_limit`, `domain_ftpacc_limit`,
            `domain_traffic_limit`, `domain_sqld_limit`,
            `domain_sqlu_limit`, `domain_status`,
            `domain_subd_limit`, `domain_alias_limit`,
            `domain_ip_id`, `domain_disk_limit`,
            `domain_disk_usage`, `domain_php`, `domain_cgi`,
            `allowbackup`, `domain_dns`
        )
        VALUES (
            ?, ?,
            ?, unix_timestamp(),
            ?, ?,
            ?, ?,
            ?, ?,
            ?, ?,
            ?, ?, '0',
            ?, ?,
            ?, ?
        )
    "

domain_admin_id must be taken from previous query field admin_id.
PHP Code:
check_for_lock_file();
send_request(); 
This are minimum operations to add a domain.
05-09-2009 05:49 PM
Visit this user's website Find all posts by this user
aseques Offline
Member
*****
Dev Team

Posts: 330
Joined: May 2008
Reputation: 4
Post: #9
RE: Using the CLI with ispcp (wiki article)
Thanks a lot. On monday I'll try to put it all together.
At the moment I was trying to adapt the user_add3.php, so I hadn't to deal on how to apply the hosting template.
Now I have much more information, I'll let you know if I suceed.

Cheers.
05-09-2009 09:41 PM
Find all posts by this user
aseques Offline
Member
*****
Dev Team

Posts: 330
Joined: May 2008
Reputation: 4
Post: #10
RE: Using the CLI with ispcp (wiki article)
Well well, I'm getting there, currently I have a script for the new domains, it checks that the required values are entered and also allow nice option passing on command line.
When I'm done with the template selection I'll post the result somewhere.

This would be what I'm currently doing:
php new_domain.php --admin_name "example.com" --admin_pass "sample_123"

Oh, the other thing I'd need is to know what algorithm are you using for the password generation, is that reversible blowfish?
05-16-2009 12:50 AM
Find all posts by this user
Thread Closed 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)