Testing out the new hooks system but am running into some issues.
Following the example here on Managing a script:
Standardized Hooks Management Interface
The output of the following gives:
/usr/local/cpanel/bin/manage_hooks add script /usr/local/oder/su/hooks/system/postupcp.php
The provided script hook is not executable
There was a failure adding a hook, removing all hooks contained with in. Please contact the maintainer of this hook for assistance.
Following the example here on Managing a script:
Standardized Hooks Management Interface
The output of the following gives:
/usr/local/cpanel/bin/manage_hooks add script /usr/local/oder/su/hooks/system/postupcp.php
The provided script hook is not executable
There was a failure adding a hook, removing all hooks contained with in. Please contact the maintainer of this hook for assistance.
PHP:
#!/usr/bin/php -q
<?php
// file - /usr/local/oder/su/hooks/system/postupcp.php
// Any switches passed to this script
$switches = (count($argv) > 1) ? $argv : array();
if (in_array('--describe', $switches)) {
echo json_encode( describe() );
exit;
} elseif (in_array('--fixfiles', $switches)) {
list($status, $msg) = fixfiles();
echo "$status $msg";
exit;
} else {
echo '0 postupcp.php needs a valid switch';
exit(1);
}
function describe() {
$my_fixfiles = array(
'category' => 'System',
'event' => 'System::upcp',
'stage' => 'post',
'hook' => '/usr/local/oder/su/hooks/system/postupcp.php --fixfiles',
'exectype' => 'script',
);
return array($my_fixfiles);
}
function fixfiles() {
shell_exec('
chgrp bb /root/test.txt
');
shell_exec('
chmod g+r /root/test.txt
');
return array(
'Success',
'File /root/test.txt should be fixed'
);
}
?>