I’m looking for some help in creating a shell script in Linux to perform a batch ownership change for certain folders in a Plesk environment where the owner:group is apache:apache.
I want to change the owner:group to :psacln.
The FTP user can be ascertained by looking at the owner of the httpdocs folder.
^this is the section I’m having trouble with.
If I was to set all owners to be the same, I could do a one-line:
find /var/www/vhosts/*/httpdocs -user apache -group apache -exec chown user:psacln {} ;
Can anyone help plug the user in to this command?
Thanks
2
Answers
Figured it out... for those who may want to use it in the future:
Since
stat
doesn’t work on al unices in the same way, I thought I would share my script to set the ownership of all websites to the correct owners in Plesk (tested on Plesk 11, 11.5, 12 and 12.5):\
Explanation of code:
cd
in a loophttpdocs
folders exists for the current website, thancd
back to vhosts folder, so we can continue looping\