Plesk restore user permissions and ownership in /var/www/vhosts/ script

Rebuild all user permissions and ownership in /var/www/vhosts from parallels plesk passwd file.

Tested on Centos5 (64b) – Plesk 9

#!/bin/sh
#
# rebuild vhost permisions for Parallels plesk 9 on centos 5
# arjen [AT] hostingondemand.nl
#
for i in `cat /etc/passwd | grep /var/www/vhosts`; do
#
path=`echo $i | cut -d: -f6`
user=`echo $i | cut -d: -f1`
echo $user : $path
#
#
chown -R -f $user:psacln $path/httpdocs/* >> /dev/null
chown -R -f $user:psacln $path/httpdocs/.* >> /dev/null
chown -R -f $user:psacln $path/httpsdocs/* >> /dev/null
chown -R -f $user:psacln $path/httpsdocs/.* >> /dev/null
chown -f $user:psaserv $path/httpdocs >> /dev/null
chown -f $user:psaserv $path/httpsdocs >> /dev/null
chown -f $user:psaserv $path/cgi-bin >> /dev/null
chown -f $user:psaserv $path/anon_ftp >> /dev/null
chown -f $user:psaserv $path/statistics >> /dev/null
chown -f $user:psaserv $path/statistics/anon_ftpstat >> /dev/null
chown -f $user:psacln $path/statistics/anon_ftpstat/* >> /dev/null
chown -f $user:psaserv $path/statistics/ftpstat >> /dev/null
chown -f $user:psacln $path/statistics/ftpstat/* >> /dev/null
chown -f $user:psaserv $path/statistics/logs >> /dev/null
chown -f $user:psacln $path/statistics/logs/* >> /dev/null
chown -f $user:psaserv $path/statistics/webstat >> /dev/null
chown -f $user:psacln $path/statistics/webstat/* >> /dev/null
chown -f $user:psaserv $path/statistics/webstat-ssl >> /dev/null
chown -f $user:psacln $path/statistics/webstat-ssl/* >> /dev/null
chown -f $user:psaserv $path/pd >> /dev/null
chown -f apache:apache $path/pd/* >> /dev/null
chown -f $user:psaserv $path/conf >> /dev/null
chown -f root:root $path/conf/* >> /dev/null
#subdomains
chown -f $user:psaserv $path/subdomains/*/cgi-bin >> /dev/null
chown -f $user:psaserv $path/subdomains/*/httpdocs >> /dev/null
chmod -f 755 $path/subdomains/*/cgi-bin >> /dev/null
#
done
#

0 Comments

Leave A Reply

You must be logged in to post a comment.