I recommend to consider using the postupcp script hook, where you would setup a custom script that applies any needed customizations or executes other scripts to perform the desired changes. The postupcp script hook is automatically executed after cPanel & WHM updates are performed; you would simply need to ensure your custom postupcp script exists and is executable.
Example contents of /scripts/postupcp:
Code:
#!/bin/sh
perl -pi -e 's/^memory_limit\s*=\s*\d+M/memory_limit = 256M/g' /usr/local/cpanel/3rdparty/etc/php.ini.dist
/usr/local/cpanel/bin/checkphpini
/usr/local/cpanel/bin/install_php_inis
Additional script hook information is detailed in the following documentation: cPanel & WHM Script Hooks