ISPConfig CLI Tools

During a recent migration project, I ran into a limitation of ISPConfig automation. While this web hosting management platform provides an API, working with SOAP is notoriously uncomfortable and clunky. I've faced this problem before—for example, check out my very old post about mass email user creation.

This time, I needed to create websites, databases, and database users while migrating hundreds of sites from DirectAdmin (you can read about that massive migration here). Writing custom PHP scripts for every individual task would have been slow and messy, so I decided to build a proper tool instead.

The ISPConfig CLI Tools provide a more comfortable and modern way to automate ISPConfig operations directly from the terminal. The project is still a work in progress, but it already covers the most essential operations.

Implemented Functions

The CLI toolkit currently covers the following ISPConfig operations, returning clean JSON for easy piping:

  • System & API: get_function_list.php (list SOAP functions) and get_jobqueue_count.php (monitor pending changes).
  • Client Management: client_get.php and client_get_all.php.
  • Web Domain Management: Add, Get, List, Edit, and Delete domains.
  • Database Management: Full control over databases and database users.

Usage Example: Creating a Site from Scratch

Instead of clicking through the UI, you can now chain commands in a script:

# Step 1: Create the web domain
./sites_web_domain_add.php --domain=myblog.com
# {"success":true,"domain_id":12,"domain":"myblog.com"}

# Step 2: Create a database user
./sites_database_user_add.php --user=bloguser --password=PASSWORD
# {"success":true,"database_user_id":5,"database_user":"c3bloguser","server_id":1}

# Step 3: Create the database and link it to the domain
./sites_database_add.php --database_name=blogdb --database_user_id=5 --domain_id=12
# {"success":true,"database_id":8,"database_name":"blogdb","database_user_id":5}

# Step 4: Wait for ISPConfig to process the changes
./get_jobqueue_count.php
# {"success":true,"jobqueue_count":0,"server_id":1}

Updating Existing Components

Need to change settings for an existing domain? It's just as simple. For example, updating backup copies or intervals:

# Update backup copies from 2 to 5 for a specific domain
./sites_web_domain_edit.php --id=12 --data='{"backup_copies":5}'

# Switch database to weekly backups and keep 4 copies
./sites_database_edit.php --id=8 --data='{"backup_interval":"weekly","backup_copies":4}'

The response will always be a JSON object, which you can easily parse with jq:

{
  "success": true,
  "affected_rows": 1,
  "domain_id": 12
}

This project is part of my "vibe-coding" workflow, focusing on solving real migration problems quickly. You can find the source code and contribute on GitHub.

GitHub Repository: https://github.com/alan-lt/ispconfig-cli

Human Logic, AI Syntax... Note on Content: I'm a Systems Engineer, not a native English writer. To ensure my technical ideas are clear and accessible, I use AI tools to polish the grammar and style. The workflow is simple: I provide the logic, the code, and the real-world experience. The AI handles the "English-to-Human" translation layer. If you find a bug, that's on me. If you find a perfectly placed comma, that's probably the AI.

Comments

Popular posts from this blog

FreeRadius with Google Workspace LDAP

Fixing pssh (parallel-ssh) Problems on Debian 10 with Python 3.7