Custom Skeleton Directory Tricks for cPanel

5/5 - (1 vote)

When new accounts are created in cPanel/WHM, the system automatically copies a set of default files from the skeleton directory into the user’s home directory. This mechanism is often overlooked, but with some creativity, it can become a powerful way to automate onboarding, enforce standards, and pre-deploy useful files.

 

Where Is the Skeleton Directory?

By default, the skeleton directory lives at:

/root/cpanel3-skel/

Anything inside this directory is copied to the home directory of a new account.

  • /root/cpanel3-skel/public_html/index.html → becomes /home/username/public_html/index.html

  • /root/cpanel3-skel/.bashrc → becomes /home/username/.bashrc


Common Skeleton Customizations

1. Branded Default Index Page

Replace cPanel’s generic placeholder with your own:

/root/cpanel3-skel/public_html/index.html

Your default index page might include:

  • Company branding and logo

  • Links to support docs

  • Instructions for uploading a website


2. Preloaded .bashrc, .zshrc, or .profile

For accounts with SSH access:

/root/cpanel3-skel/.bashrc
/root/cpanel3-skel/.zshrc

Include:

  • Helpful aliases (e.g., alias ll='ls -lah')

  • Custom MOTD with support contact info

  • Path additions for developer tools


3. SEO and Security Defaults

Drop default .htaccess and robots.txt files into the skeleton:

/root/cpanel3-skel/public_html/.htaccess
/root/cpanel3-skel/public_html/robots.txt

Examples:

  • Block access to .git/, .env, and config files.

  • Disallow indexing for staging domains.


4. Git-Ready Directories

Pre-populate Git configs:

/root/cpanel3-skel/public_html/.gitignore
/root/cpanel3-skel/public_html/.gitattributes

You can also include example hooks in:

/root/cpanel3-skel/public_html/.git/hooks/

5. Developer Starter Kits

For developer-friendly hosting, seed each account with a starter project structure:

/root/cpanel3-skel/public_html/src/
/root/cpanel3-skel/public_html/package.json
/root/cpanel3-skel/public_html/README.md

Examples:

  • Node.js boilerplate

  • PHP framework stubs (Laravel, CodeIgniter)

  • Python/Flask starter files


6. CMS Defaults

For WordPress-heavy environments, preload:

/root/cpanel3-skel/public_html/wp-config-sample.php
/root/cpanel3-skel/public_html/wp-content/themes/company-default/

This makes onboarding faster for clients who install WordPress.


7. Compliance and Legal

Automatically deploy a placeholder for terms, policies, or compliance files:

/root/cpanel3-skel/public_html/terms.html
/root/cpanel3-skel/public_html/privacy.html

Ideal for GDPR/CCPA environments.


8. Cron Job Templates

You can preload cron files for accounts that need scheduled cleanup or reports. Place the file in the skeleton and adjust ownership after account creation. Example:

/root/cpanel3-skel/var/spool/cron/username

This can include tasks like clearing tmp/ or rotating logs.


Advanced Trick: Package-Based Skeletons

By default, all accounts use the same skeleton directory. But what if you want different files depending on the hosting package? For example:

  • WordPress Plan → WordPress starter files

  • Developer Plan → Git, Node.js, or Laravel boilerplate

  • Basic Plan → Only a branded index page

Here’s how to set it up.


Step 1: Create Multiple Skeleton Directories

Make separate directories for each package:

mkdir -p /root/cpanel3-skel-wordpress
mkdir -p /root/cpanel3-skel-developer
mkdir -p /root/cpanel3-skel-basic

Populate each directory with the desired defaults.


Step 2: Write a Hook Script

cPanel supports Account Creation Hooks. These scripts run automatically after a new account is created.

Example hook (/usr/local/cpanel/hooks/postacctcreate-skel.pl):

#!/usr/bin/perl
use strict;
use warnings;

my %data = @ARGV;

# Example: map package names to skeleton dirs
my %package_map = (
'WordPressPlan' => '/root/cpanel3-skel-wordpress',
'DeveloperPlan' => '/root/cpanel3-skel-developer',
'BasicPlan' => '/root/cpanel3-skel-basic',
);

if (exists $package_map{$data{'plan'}}) {
my $skeldir = $package_map{$data{'plan'}};
my $homedir = "/home/$data{'user'}";

system("cp -a $skeldir/* $homedir/");
system("chown -R $data{'user'}:$data{'user'} $homedir");
}

Make it executable:

chmod 755 /usr/local/cpanel/hooks/postacctcreate-skel.pl

Step 3: Register the Hook

Run:

/usr/local/cpanel/bin/manage_hooks add script /usr/local/cpanel/hooks/postacctcreate-skel.pl stage post acctcreate

This ensures the script runs after every new account creation.


Step 4: Test It

  1. Create a new account using the “WordPressPlan” package.

  2. Confirm that WordPress starter files appear in the home directory.

  3. Repeat for DeveloperPlan and BasicPlan.

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top