CLI command to automate creation of new ERPNext site

Hello, I am new to frappe and i am making my own custom app
I want to provide a CLI command to automate creation of new ERPNext site/db on the same bench for a new client
and i want to be able to run this CLI command through Page or API Endpoint request with passing these paramteres (ClientID-SubscriptionID-VATID-ClientName)

any help will be appreciated

Yes Meena, you can automatically create a new site in the same bench using a shell command. I have created a new site using a wildcard subdomain so that when a user adds a company name, it creates a new site based on that name.

Create a shell script named create_site.sh inside the frappe-bench directory to execute the necessary commands. Here’s an example script
#!/bin/bash

COMPANY=$1
BENCH_DIR=“/home/frappe/frappe-bench” # Move shell to frappe-bench directory
SITE_NAME=“${COMPANY,}.site.com” # Convert to lowercase and use as subdomain

cd $BENCH_DIR

bench new-site $SITE_NAME
–admin-password admin
–mariadb-root-password root

bench --site $SITE_NAME install-app erpnext

bench setup nginx
sudo service nginx reload

echo “Site created at https://$SITE_NAME”

This script creates a new site when you provide a company name and execute it.