Page 1 of 1

How to bulk add domains to vestaCP?

Posted: Thu Oct 05, 2017 11:37 am
by wooze
Hi everyone :)

That's my first topic and I'm starting my journey with VestaCP :).

I need to add in bulk:
- about 20 databases (every diffrent password and name)
- about 20 domains but every domin need to have added:
a) two different A records
b) two changes in "12 lists records" (localhost to the name of domain.

What can you recommend for me?
Regards,
W

Re: How to bulk add domains to vestaCP?

Posted: Fri Oct 06, 2017 12:11 pm
by skurudo
bash script

commands:
v-add-domain
Usage: v-add-domain USER DOMAIN [IP] [RESTART]
v-add-database
Usage: v-add-database USER DATABASE DBUSER DBPASS [TYPE] [HOST] [CHARSET]

Re: How to bulk add domains to vestaCP?

Posted: Mon Oct 09, 2017 5:31 pm
by DarthVader
This is script to bulk add email account.
You can rewrite him to use for buld add domains and databases

Code: Select all

#!/bin/bash
username='john'
emails="$(cat emails)"
outfile='passwd'
if [ -a $outfile ]; then
    rm -f $outfile
fi

for email in $emails;
do

    account="$(echo $email | awk --field-separator='@' '{print $1}')"
    domain="$(echo $email | awk --field-separator='@' '{print $2}')"
    password="$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-12};echo;)"

    #Usage: v-add-mail-account USER DOMAIN ACCOUNT PASSWORD [QUOTA]    
    /usr/local/vesta/bin/v-add-mail-account $username $domain $account $password 1000
    echo $email	$password >> $outfile
    
done