Automatically remove public_html symlink

Aeonis

New member
Joined
Nov 6, 2011
Messages
3
Hi folks,

My question is how I can automatically remove the public_html symlink folder (home/[user]/public_html) when I create a new user.

The reason for this is to prevent mistakes. When there are multiple domains for a single user, this public_html folder will go to the default domain. I want to force our programmers to always use home/[user]/domains/[domain]/public_html.

I've read that when I remove the public_html symlink folder it will break up using server-ip/~[user], how can I automatically make it available through server-ip/[domain]? (by creating a symlink in /var/www/html/[domain])

I can do both of these things manually, but I'm wondering how I can do this automatically when I create a new user. Will removing the public_html symlink have any more consequences by the way?

Thanks in advance!
 
This should work:

edit this file

Code:
/usr/local/directadmin/scripts/custom/domain_create_post.sh

and in

Code:
/usr/local/directadmin/scripts/custom/user_create_post.sh

and put in it:

Code:
#!/bin/sh
rm /home/$username/public_html

This should remove the symlink everytime a new user is created or a new domain is added to an existing user.

Regards
 
Thanks SeLLeRoNe :) that'll do the trick!

Any idea if removing this symlink will have any unwanted consequences for DA when deleting/modifying users?
 
AFAIK the only feature you will lose is the IP/~username one but, i dont think is that usefull :)

Regards

Thanks, that is no problem indeed. I think it is better to edit the hostsfile on your computer and then simply use domain.com -> serverip.
 
Sorry to drag up a very old thread

This should work:

edit this file

Code:
/usr/local/directadmin/scripts/custom/domain_create_post.sh

and in

Code:
/usr/local/directadmin/scripts/custom/user_create_post.sh

and put in it:

Code:
#!/bin/sh
rm /home/$username/public_html

This should remove the symlink everytime a new user is created or a new domain is added to an existing user.

Regards

Sorry to drag up a very very old thread, but I wanted to do this to so tried your solution above. It works perfectly when creating the initial user account and domin, but if I add further domains then symlink to public_html returns.

I have tried to add

Code:
#!/bin/sh
rm /home/$username/public_html

to both

Code:
/usr/local/directadmin/scripts/custom/domain_create_post.sh

and in

Code:
/usr/local/directadmin/scripts/custom/user_create_post.sh

If I add it to both, on creating a new domain it shows the message that the public_html file cannot be deleted as it doesn't exist - but it does recreate the symlink

If I only add it to user_create_post.sh it doesnt show the message above but it also re-creates the symlink

Has anything changed in DA since this very old thread that would prevent this from working?

As I said, the problem only occurs when creating an additional domain name after a user account and intial domain has been created.

Thanks in advance for any suggestions.
 
Are you wanting it to not show the message about public_html not existing?

Code:
rm /home/$username/public_html >/dev/null 2>/dev/null
 
Are you wanting it to not show the message about public_html not existing?

Code:
rm /home/$username/public_html >/dev/null 2>/dev/null

I was kind of hoping that it wouldn't create the symlink at all.

This works when then the account was created, but if any further domains are added, then the symlink appears to return.

The message above only appears when this is placed into /usr/local/directadmin/scripts/custom/domain_create_post.sh. It shows the message and the symlink is recreated.
 
Back
Top