Custombuild hooks not run during ./build update_versions n

kristian

Verified User
Joined
Nov 4, 2005
Messages
440
Location
Norway
I have a script /usr/local/directadmin/custombuild/custom/hooks/jailshell/post/jailshell_mount_update.sh that modifies /usr/bin/jailshell slightly. After running ./build update_versions n, this hook is not run. If I run ./build jailshell it is run as expected. This seems like a bug?

Code:
# ./build update_versions n
[..snip..]
Updating Jailshell
/usr/bin/jailshell has been installed.

Code:
# ./build jailshell
/usr/bin/jailshell has been installed.
Executing '/usr/local/directadmin/custombuild/custom/hooks/jailshell/post/jailshell_mount_update.sh'...
 
CustomBuild hooks does not work that way (and never did). They allow you to run any hooks prior to the main CB code and after.

When you are running ./build update_versions n CB will call hooks from .../custombuild/custom/hooks/update_versions/pre/* and after all software components are updated it will call .../custombuild/custom/hooks/update_versions/post/*.

The hooks were never designed to wrap around a particular software component, they were intended to wrap around specific CB commands. Customizing component building is done by creating custom files in .../custombuild/custom/....

Executing some hooks when a particular component is being built would be a new feature. To be honest existing CB hooks support is rather limited/strange and I did not expect anyone knowing about CB hooks or using it 😄.
 
Oh! I read about it somewhere here on the forums, thought it was common stuff. :)

My jailshell_mount_update.sh script (posted about it on https://forum.directadmin.com/threads/adding-or-editing-custom-mount-in-jailshell.65554/) adds a few --ro-bind-try options to bwrap, but still allows the main file to be updated along with the DirectAdmin software updates. Unless I'm mistaken, I can't do the same using using the custom files, e.g. if I created a file custombuild/custom/jailshell.sh I could have my own additions there, but I would miss out on any updates from DirectAdmin unless I keep it up to date somehow.

I have a similar hook for exim_conf that adds some options to log_selector in /etc/exim.conf.

I'm not really sure what the best approach would be then, if anyone have any good ideas, I'm interested!

Sometimes trying to customize things and using (ansible) automation for DirectAdmin is really really hard.. :)
 
We could consider improving CB hooks support to have "component" hooks rather than "command" hooks. But this would take some time and we would need to restructure how CB works internally. For the jailshell, the best way forward would be just to expose extra /etc files into official jailshell script. For example latest version 0.10 have added /etc/bashrc for better support on RHEL systems.

Adding /etc/manpath.config would be a clear improvement for everyone. Bash completion already works for debian based systems (since bash completion files are stored in /usr/share/bash-completion), not sure about RHEL.

As you mention in the other thread it is unlikely we can make everyone happy with a single jailshell script. I hope we could reach a point when jailshell.sh would work for 99% of users and the remaining 1% would pay the price of maintaining a custom version of custombuild/custom/jailshell.sh and would follow the change log to see when it needs updating.
 
/custombuild/custom/hooks/update_versions/pre/*

for workaround, you can get list update available with pre hook and put list into some cache file like "/custombuild/custom/cache_available_update.json"

then post hook, just read cache file that have update information in pre hook and check if there has a jailshelll update.
 
Back
Top