Linux – Network – Technology
Posts tagged plesk
Plesk – Migrate DB
Oct 26th
On source server backup the database. You may use the following command:
source ~# mysqldump -uadmin -p`cat /etc/psa/.psa.shadow` DATADASE_NAME > DATADASE_NAME.dump
On destination server create database DATADASE_NAME on domain DOMAIN.NAME with Plesk CLI /usr/local/psa/bin/database. Assign the same user and password:
destination ~# /usr/local/psa/bin/database --create DATADASE_NAME -domain DOMAIN.NAME -type mysql -passwd DB_USER_PASSWD -passwd_type plain -add_user DB_USER_NAME -server localhost
Database creation through Plesk CLI /usr/local/psa/bin/database will update Plesk database with appropriate user and password correctly. Run the utility wit “–help” to get list of all available options. After creation it is possible to login to the database through DB WebAdmin in Parallels Plesk Panel on destination server: Domains -> DOMAIN.NAME -> Databases -> DATADASE_NAME -> DB WebAdmin
On destination server restore content of the database from the dump created on source server:
destination ~# mysql -uadmin -p`cat /etc/psa/.psa.shadow` DATADASE_NAME < DATADASE_NAME.dump
Multiple Virtual FTP Accounts with Plesk
Aug 8th
ProFTPD is the FTP software that current versions of Plesk ship with, and thankfully found what I was looking for.
ProFTPD allows you to create multiple virtual users by using an AuthUserFile directive. The AuthUserFile directive sets the path of a textual file containing a list of users and passwords for authentication.
Create a user file
$ touch /etc/proftpd.authuserfile
Edit the ProFTPD configuration file. (NOT etc/proftpd.include as Plesk overwrites that file regularly.):
$ vi /etc/proftpd.conf
Add this line:
AuthUserFile /etc/proftpd.authuserfile
Creat a crypted password
$ openssl passwd -crypt passwordhere
Edit the user file like this:
username:password_encrypt:uid:gid:gecos:home:shell
Example
toto:aASDFajksASa:10022:2221::/var/www/vhosts/toto.com/httpdocs/data/web:/bin/false
And finaly, reload proftpd
Plesk – Scripting
May 17th
Add DNS
/usr/local/psa/bin/dns.sh -a DOMAIN -mx "" -mailexchanger "DNS" -priority PRIORITY
Delete DNS
/usr/local/psa/bin/dns.sh -d DOMAIN -mx "" -mailexchanger "DNS" -priority PRIORITY
Disable mail for all domains
#!/bin/bash
# This script finds all sites that have the mail service on - and then it turns it off.
SiteList=`egrep 'Server(Name)' /var/www/vhosts/*/conf/httpd.include|awk '{print $3}'|grep -v www.*|grep -v '^.*\..*\..*$'|sed 's/:80//'|sed 's/:443//'|sort -u`;
for Site in $SiteList
do
Result=`/usr/local/psa/bin/domain -i $Site | grep 'Mail service' | awk '{print $3}'`;
if [ $Result == On ]; then
Command=`/usr/local/psa/bin/domain -u $Site -mail_service false`
echo "Turning Off Mail Service: $Site";
fi
done
Add Dns sec in OVH
#!/usr/bin/python
import pprint
import sys
import getopt
from SOAPpy import WSDL
soap = WSDL.Proxy('https://www.ovh.com/soapi/soapi-re-1.11.wsdl')
DOMAIN = sys.argv[1]
#login
session = soap.login('xxxxx-ovh', '*****password*****', 'fr', 0)
print "login successfull"
#dedicatedSecondaryDNSAdd
soap.dedicatedSecondaryDNSAdd(session, 'ns*****.ovh.net', '*****IP*******', DOMAIN, 'sdns1.ovh.net', '213.251.188.140')
print "dedicatedSecondaryDNSAdd successfull"
#logout
soap.logout(session)
print "logout successfull"
Pulls email password out of Plesk database for given email address
SELECT concat(mail_name,'@',domains.name) as email,password,redirect,redir_addr,autoresponder,spamfilter,virusfilter,alias FROM mail LEFT JOIN domains ON mail.dom_id=domains.id LEFT JOIN accounts ON mail.account_id=accounts.id LEFT JOIN mail_aliases ON mail_aliases.mn_id = mail.id WHERE domains.name = '*******DOMAIN******'
Recovery all mail accounts
/usr/local/psa/admin/sbin/mchk --without-spam
Add SPF records to all domains
mysql -u admin -p`cat /etc/psa/.psa.shadow` psa -e "select dns_zone_id,displayHost from dns_recs GROUP BY dns_zone_id ORDER BY dns_zone_id ASC;" | awk '{print "INSERT INTO dns_recs (type,host,val,time_stamp,dns_zone_id,displayHost,displayVal) VALUES ('\TXT'\,'\"$2"'\,'\v=spf1 a mx ~all'\,NOW(),"$1",'\"$2"'\,'\v=spf1 a mx ~all'\);"}' | mysql -u admin -p`cat /etc/psa/.psa.shado