Skip to content

Instantly share code, notes, and snippets.

@nbeernink
Last active March 1, 2017 15:03
Show Gist options
  • Save nbeernink/f86aa009ba0201d6556720e453fa8212 to your computer and use it in GitHub Desktop.
Save nbeernink/f86aa009ba0201d6556720e453fa8212 to your computer and use it in GitHub Desktop.
tries to fix most of plesk users vhost ownership & permissions
#!/bin/bash
#Getting list of users and their home directories from psacln group
awk -F ":" '{print $1, $4, $6}' /etc/passwd | grep "$(getent group psacln|cut -d: -f3)" | awk -F " " '{print $1, $3}' > /root/users_list.txt
time while read -r i
do
user=$(echo $i | awk '{print $1}')
path=$(echo $i | awk '{print $2}')
echo Fixing ownership and permissions for $user
chown -f $user:psaserv $path
chown -Rf $user:psacln $path/*
chown -Rf $user:psaserv $path/anon_ftp
chown -Rf $user:psacln $path/error_docs
chown -Rf $user:psaserv $path/cgi-bin
chown -f $user:psaserv $path/httpdocs
chown -f $user:psaserv $path/httpsdocs
chown -Rf $user:root $path/logs
chown -Rf $user:psaserv $path/subdomains
chown -Rf root:root $path/bin
chown -Rf root:root $path/dev
chown -Rf root:root $path/etc
chown -Rf root:root $path/lib
chown -Rf root:root $path/tmp
chown -Rf root:root $path/usr
chown -Rf root:root $path/var
chown -Rf $user:psaserv $path/private
chown -f root:root $path/web_users
chown -Rf $user:psaserv $path/web_users/*
chmod 755 $path
chmod 750 $path/anon_ftp
chmod 755 $path/error_docs
chmod 700 $path/error_docs
chmod 750 $path/httpdocs
chmod 750 $path/httpsdocs
chmod 755 $path/bin
chmod 755 $path/dev
chmod 755 $path/etc
chmod 755 $path/lib
chmod 755 $path/tmp
chmod 755 $path/usr
chmod 755 $path/var
chmod 755 $path/web_users
chmod 750 $path/web_users/*
done < /root/users_list.txt 2>> /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment