Execute custom script after cPanel updates

Execute custom script after cPanel updates

cPanel update script that is executed every night is /scripts/upcp and according to its code, file named /scripts/postupcp will get executed at the end:

if (-e "/scripts/postupcp") {
   system("/scripts/postupcp");
}

We can use this file to add a custom command that will execute after the update.

Cloudlinux already uses it:

cat /scripts/postupcp
#!/bin/bash
/usr/share/cloudlinux-linksafe/cpanel/hooks/cloudlinux_linksafe_hook.sh   #cloudlinux-linksafe
/usr/share/l.v.e-manager/cpanel/hooks/l.v.e-manager_postupcp_hook.sh   #l.v.e-manager
/usr/share/cagefs/cpanel/cagefs_postupcp_hook.sh   #CageFS Version 2.0. Update CageFS after update of CPanel
/usr/share/lve/dbgovernor/cpanel/upgrade-mysql-disabler.sh   #dbgovernor

If the file does not exist, create it and add your custom script:

nano /scripts/postupcp
/usr/share/something-custom/run-after-update.sh   #my custom script

We can even use our custom install script to add code to the /scripts/postupcp

line_to_add="/usr/share/something-custom/run-after-update.sh   #my custom script"

# Check if already added, if not add it
if ! grep -qF "$line_to_add" /scripts/postupcp; then
  echo "$line_to_add" >> /scripts/postupcp
fi
whoami
Stefan Pejcic
Join the discussion

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.