HostingKiller

Mass change web hosting and mail settings quickly and easily with Plesk CLI

Mass change web hosting and mail settings quickly and easily with Plesk CLI


2. List of Business Objects to Configure

A list of business objects that your cycle will process, for example domain names, can be manually written line by line as a text file or generated from the Plesk database using a Plesk CLI command or database query . But the list can also be an export from other data sources, such as a spreadsheet application.

The tedious manual way

For example, you could use a text editor to type domain names or email addresses line by line into a text file. Either with the Windows text editor, a spreadsheet whose lines you export as a text file and upload to the server, with the Linux editors “vi” or “nano”, or in any other way imaginable. Just note that each entry is alone on a line of the text file, for example

first-domain.tldsecond-domain.tldthird-domain.tld…nth-domain.tld

A lot of effort writing this by hand. Therefore, in most cases, you will have a list created automatically, for example, by a database query or a Plesk CLI command.

The Simple Way of Plesk Commands

Maybe you need a list of all the websites. For this, you can use “plesk bin site –list” and save the result to a file via the “>” output redirection.

# plesk bin site –list > web sites.txt

Or maybe you want to make bulk changes to mailbox settings. To do this, you can run the command “plesk bin mail -l” (show all mail addresses) and filter the output with a “grep ‘Mail Name’” to get only mailboxes. Then you’ll only want the third column (because that’s the name of the mailbox), so add “awk ‘{print $3}'”, and finally save the result to a file using the “>” output redirection:

# plesk bin mail -l | grep “MailName” | awk ‘{print $3}’ > mailboxes.txt

Work with database queries like a pro

Some tasks may be more complex. You may just want a list of mailboxes that match certain criteria. To do this, you could generate the list of items from a database query and filter it by criteria. For example, a list of all mailboxes could be generated as follows instead of using the “plesk bin mail” command:

# plesk db -Ne “SELECT CONCAT_WS(‘@’, a.mail_name, b.name) FROM psa.mail LIKE \INNER JOIN psa.domains as b ON b.id = a.dom_id WHERE a.postbox LIKE ‘true ‘ ;” \> mailboxes.txt

There you could insert arbitrary conditions, for example, only all mailboxes whose name starts with “x”:

# plesk db -Ne “SELECT CONCAT_WS(‘@’, a.mail_name, b.name) FROM psa.mail LIKE \INNER JOIN psa.domains as b ON b.id = a.dom_id WHERE a.postbox LIKE ‘true ‘ \Y un.mail_name LIKE ‘x%’;” > mailboxes_starting_with_a.txt

There are no limits to your imagination. With Plesk, this and much more is possible, because you always have full access to all data managed by Plesk. If you plan to use database queries, the “psa” database is the place to look for all your Plesk configurations and business objects.



Source link

댓글 달기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다