Easyapache is the component in cpanel that is responsible for downloading and compiling apache and its requisite dependencies. It includes the ability to add events to run before and after easyapache runs for 3rd parties to insert actions into or after the build and installation process.
General notes:
easyapache does not return error codes to the command line, it does however use some basic internal logic to validate the pre & post events. This is problematic for automation without human interaction.
The events:
/scripts/preeasyapache - this is invoked by /scripts/easyapache prior to starting the build process. It can be an executable of any type. This is problematic if 3rd party vendors use different languages in these events, like perl.
/scripts/posteasyapache - this is invoked by /scripts/easyapache after completing the build process. It can be an executable of any type.
Recommendation:
Both Atomicorp and Cloudlinux rely on the pre & post events in order to install our software. In order to provide a consistent experience across software, Cloudlinux developed the following method to use this part of the API, which we have also adopted.
1) pre & post easyapache are to be used as shell scripts only
2) these events invoke other scripts or executables that can be in any language your application needs.
The following is an example of /scripts/posteasyapache using this method:
Note that the Atomicorp event is now referenced from inside /scripts/posteasyapache, and the final line includes a tag: ASL_HOOK (more on this in a sec). A 3rd party change to posteasyapache would look like the following:#!/bin/sh
/var/asl/data/templates/template-cpanel-apache-hook #ASL_HOOK
This allows any number of 3rd party vendors to co-exist using the easyapache pre & post events. This simple shell script example shows how a 3rd party vendor can write an installer, or an event to verify that their script is in place in /scripts/posteasyapache:#!/bin/sh
/var/asl/data/templates/template-cpanel-apache-hook #ASL_HOOK
/path/to/my/script #MY_SCRIPT_TAG
Code: Select all
if [ -f /scripts/posteasyapache ]; then
if ! egrep "ASL_HOOK" /scripts/posteasyapache ; then
echo "/var/asl/data/templates/template-cpanel-apache-hook #ASL_HOOK" >> /scripts/posteasyapache
fi
else
install -m0755 /var/asl/data/templates/template-cpanel-posteasyapache /scripts/posteasyapache
fi
In conclusion:
1) When in doubt ask! Its in all our best interests to use a method that works across platforms
2) use shell scripting as the base language in pre & post easyapache events
3) return errror values back to the pre & posteasyapache script, it might not use them but the next vendor in the chain could
4) Reference your event from the pre & post scripts, don't overwrite it
5) And I'll repeat it, when in doubt ask!