Developer Tools
Here you can find some info about tools shipped with Zentyal by default that can help you when developing, specially for debugging.
zentyal-shell
It is executed with the /usr/share/zentyal/shell command. It works like perlconsole, it's just an interactive Perl console with a preloaded Zentyal environment, so you can make calls to the Zentyal API without having to create a script with all the initialization code. It adds some internal commands to make Zentyal developer's life even easier.
Example
You want to list all the network interfaces. You can do it by writing the following script:
#!/usr/bin/perl
use warnings;
use strict;
use EBox;
use EBox::Global;
EBox::init();
my $network = EBox::Global->modInstance('network');
my $ifaces = $network->allIfaces();
for my $iface (@{$ifaces}) {
print "$iface\n";
}
And execute it:
# chmod +x show-ifaces.pl # ./show-ifaces.pl eth0 eth1 #
Or you can just do the following to get the same information:
# /usr/share/zentyal/shell
zentyal> instance network
$network
zentyal> $network->allIfaces();
$VAR1 = [
'eth0',
'eth1'
];
zentyal>
Even with a single non-interactive command:
# /usr/share/zentyal/shell 'instance network' '$network->allIfaces()'
$network
$VAR1 = [
'eth0',
'eth1'
];
Internal commands reference
instance <module>
Shortcut for EBox::Global->modInstance('<module>'); instances the requested module in a variable called $module.
model <ModelName>
Shortcut for EBox::Model::ModelManager->instance()->model('<ModelName>'; instances the requested model name in a variable called $modelname (lowercased).
call <method>
Shortcut for use EBox::Foo; EBox::Foo::bar() or EBox::Foo->bar(), basically it automatically imports the package extracting it from the full qualified method name and calls the requested method after that.
redisvi
Usage: /usr/share/zentyal/redisvi [path]
It allows to directly edit the redis database in a YAML format, using vi or whatever your default $EDITOR is. This is inspired in the ldapvi tool and you should know what you are doing if you use it, because you can easily break everything :)
If you decide to use it because you need to modify any value directly for some reason, please make first a backup (just using the save to file option of your editor) so you can paste it again using redisvi if you wreak havoc.
After saving your changes in the editor and exiting it, a diff of your changes will be shown on the console, but they will be already applied, so if you notice any mistake, you should open redisvi again and fix it asap.
The path argument is optional, it allows you to edit just any subtree of the configuration, if not passed, the whole /ebox tree will appear on your editor.
Note: The unsaved changes are stored in /ebox, if you want to look at the already saved values, you need to edit the /ebox-ro subtree.
grep-redis
Usage: /usr/share/zentyal/grep-redis <pattern> [path]
This tool is much safer than redisvi, because it only performs read operations in the redis database. It works like grep, matching the given regexp against the key names and their values, and printing any line on screen that matches either the key or the value.
As with redisvi, the path argument is optional, it can search of any subtree of the configuration, if not passed, it will search on the full tree.
Example
You are getting the automatic time (chosen randomly) of the automatic updates (if enabled) of the Software Management module:
# /usr/share/zentyal/grep-redis time /ebox/modules/software /ebox/modules/software/automatic_time: 01:17