Creating AE scripts

You can find information related to the AE script.

Scripts

You can create custom templates and their scripts. It is implied that if you create your templates, the template has custom scripts to execute the new rules that you have created in your templates. The scriptsDirectory in template settings is the place to define the location of your scripts. If you want to link a particular section to a script that must be executed by AE in your section, then you must place the script in location defined by scriptsDirectory.

It is expected that all the created scripts to be executed by the Activation Engine, must follow a certain set of criteria. The important requirement is that the created scripts must accept the set of arguments passed to them by the Activation Engine, as defined in the RuleSet section of the template files linking to these scripts. For example, the network section of the template file contains:
<section name="network" script="ae_network.sh">
        <ruleset>
          <address>9.3.148.163</address>
          <mask>255.255.254.0</mask>
          <gateway>9.3.148.0</gateway>
          <routes>default:0:9.3.149.1</routes>
        </ruleset>
</section>

The script ae_network.sh is expected to accept all three arguments as defined in the included RuleSet: address, mask, and gateway. The script also has to provide a proper return code to the Activation Engine. It must return 0 for SUCCESS and 1 for FAILURE.

Return code of 2 is reserved for SUCCESS_WITH_WARNINGS, which informs AE the script was successful with minor warnings and AE must log it in the execution logs. The scripts are also not expected to pipe their output to any external file. Any verbose/error messages must be sent to STDOUT, or STDERR where they are piped by AE to the appropriate destination log files, as defined in the template settings section. See, Template settings, for more details.

The scripts have certain expectations from the templates created by you. Firstly, any custom template file must follow the defined structure as defined in Schema. See Creating AE Template File for more information. The template must contain a Settings section and a Rules section. The Settings section might or might not be filled out. If any or all of the rules in Settings section is not filled out by the template then its parents' rules are used. (The parent template is the ae_template.xml template file). Note that if the scriptsDirectory settings are not present in the custom template file, then the AE cannot call any scripts that are not defined in the parent template.

The rules section of the XML file must be filled out and it must follow the rigid structure of rules:
<rules>
      <section name="SECTION_NAME" script="SCRIPT">
          <ruleset>
              <argument1>value1</argument1>
              <argument2>value2</argument2>
          </ruleset>
      </section>
</rules>
In the above example, SCRIPT is a placeholder for a custom string that names the subscript. SCRIPT can be a filename of any system executable script, as long as its location is defined in the scriptsDirectory element. The above script will be run as follows:
PATH/SCRIPT argument1=value1 argument2=value2
All argument and value pairs are processed and passed to the script in the way described above. PATH represents the scriptsDirectory path defined in the settings section. See Template settings for more details.