• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Events and the order they are executed in

KarelB

New Pleskian
I made a small script that sets some permissions of a subdomain after being created:

Code:
#!/bin/bash
SUBSCRIPTION_DIR=/var/www/vhosts/${NEW_DOMAIN_NAME}
SUBDOMAIN_DIR=$SUBSCRIPTION_DIR/${NEW_SUBDOMAIN_NAME}.${NEW_DOMAIN_NAME}

# Fix permissions for the subscription basedir
chmod 755 $SUBSCRIPTION_DIR

# Fix permissions for the subdomain
chown -R karel $SUBDOMAIN_DIR
#chown -R ${NEW_SUBDOMAIN_NAME} $SUBDOMAIN_DIR
chmod 755 $SUBDOMAIN_DIR
#rm -rf $SUBDOMAIN_DIR/www

The script works fine, but the chmod and chown commands are not working. I think they are working, but that the builtin Plesk commands that change permissions and owners overwrite my changes made in my custom script.

I tried playing around with the priority from 0 to 100, but that didn't fix it.

Any suggestions on how to fix this? I really want to be able to alter these permissions and owners after creating a subdom
 
Last edited:
Plesk will always fix these permissions on updates and other circumstances ...
Am not sure if
Code:
chattr
can help you here ...

Code:
man chattr
For details
 
I don't see how chattr could help me here.

I've started looking where Plesk determines what the permissions of the subdomain folder should be, some template or config script? But I haven't found it so far.
 
Instead of meddling with plesk's engine fines (which could lead your server into serious trouble), why don't you just create a cron job that runs every (say 5 mins) to check if permissions have changed and change them back to your preference...
 
I can think of a 101 of those hacky solutions to work around this problem, but doing this with event hooks is the proper way to do it. And doing it the proper way is how I still prefer to do things as a programmer.
 
The post you linked didn't help me, as you read in his 2nd post his problem was something else so he didn't go through with the event manager solution.

But I did figure out what the problem was: the event wasn't being overwritten, my actions were taking place before the subdomain directory had actually been created.
So adding a simple "mkdir -p $SUDOMAIN_DIR" to my script before setting the permissions finally made it work like I wanted to.
 
Back
Top