Creating our first module
Getting the helper script
To create our first module we will be using zentyal-module-skel, a script that will help us create the structure and basic files for a Zentyal module. You just need to download it and give it executable permissions:
wget https://raw.github.com/Zentyal/zentyal/master/extra/scripts/zentyal-module-skel chmod +x zentyal-module-skel
Selecting a service
During this tutorial we will create a module to manage an HTTP server, in this case, it will be Apache2.
There is already an implementation of an Apache module in Zentyal. However, this is a step-by-step tutorial which will simplify some things for the sake of clarity. We usually pick this service for documentation purposes as it allows us to explain most of the features in Zentyal.
In our first iteration we will create a module that will allow the user to just choose which port Apache will listen on.
Let's get it started!
First of all we need to create all the scaffolding for a new module. Usually this can be done copying the whole folder from an other simple module, deleting not necessary stuff and renaming namespaces, but we are going to see how to do it using zentyal-module-skel.
Run the following command:
./zentyal-module-skel Apache2 apache2
The above will create a directory called apache2 with all the files that compose a Zentyal module.
Usually a module is composed by the following files:
debian/ (Debian/Ubuntu packaging) debian/precise/ (packaging for Precise, every distro gets its own dir here) debs-ppa/ (builded packages will be stored in this directory) schemas/ (schemas to define module depends and LDAP objectClasses and attributes) schemas/module_name.yaml (module depends to enable and on reconfiguration) src/ (source of the module) src/EBox/ (Perl source of the module) src/EBox/ModuleName.pm (main class of the module) src/EBox/ModuleName/ (contains models and composites) src/EBox/ModuleName/Model/ (models are forms or tables to define configuration) src/EBox/ModuleName/Composite/ (composites are views of multiple models) stubs/ (templates for the configuration files for the service)