Automatic creation of extra public_html folders.

Paulgeee

Member
Feb 22, 2019
5
0
1
gloucestershire
cPanel Access Level
Root Administrator
Hello EV1, I am new here and have been using cpanel since it first started many moons ago.


I would ideally like a default folder to be created when a new account is created with cpanel in /home/*/public_html/mynewfolder and/or a file in /home/*/public_html/mynewfile.html and be persistently created even if the user deletes it.

I have noticed that cgi-bin is persistent on my machine even if deleted also the .well-known folder has appeared.

This is mainly for instructions how to set up their site so it can be shared, I also would like to automatically create an index.php file either copied or automatically created if one does not exist as a default document.

I can do this on a straight Linux machine @ command line however cpanel is so embedded and I would prefer to do it the correct way and in such a way that does not break a live machine :)

Has anyone done this here before and if so would welcome some help.

Thanks
 

Paulgeee

Member
Feb 22, 2019
5
0
1
gloucestershire
cPanel Access Level
Root Administrator
Hi
And Thank you I gathered as much after reading your FAQ just hoped there was something I missed, I looked at the SKEL directory but also prefer an application that systematically does the entire job.

I am thinking of rolling this out to several of my servers and forgetting a step in the process is not an option.

so now have now created an application using cron that does all this for me monitoring user account directories that does not interfere with cpanel itself, although at a later date I may turn it into a plugin.

Thanks for the confirmation.

Paul

Hello @Paulgeee,

The Skeleton Directory feature supports what you need for new accounts:

Skeleton Directory - Version 78 Documentation - cPanel Documentation

For existing accounts, or for cases where a user deletes the directory/files, you'd have to develop a custom script to re-create the files and then setup that custom script to run automatically as part of a cron job.

Thank you.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,222
463
Hi Paul,

I'm glad to see you were able to develop a custom script to do what you need. If you decide to create a plugin and have any questions, feel free to reach out and let us know.

Thank you.