Bash script task

A bash script task will inject and execute the same bash script on several unix nodes concurrently.

This kind of task allows you to maintain the scripts of all your servers through a single interface.

This only works with Unix nodes.

Feel free to use the shebang to launch your script with the interpreter of your choice:

  • Bash script

    #!/bin/bash
    echo "Hello!"
    
  • PHP script

    #!/usr/bin/php
    <?php
    echo "Hello!";
    
  • Python script

    #!/usr/bin/env python3 -u
    print("Hello!")
    

Using project constants

Project constants can be used in the script content as environment variables prefixed with CPC_ (for CtFreak Project Constant).

Here’s an example using a project constant named NUMBER_OF_RETENTION_DAYS:

#!/bin/bash
echo "Delete backup files older than $CPC_NUMBER_OF_RETENTION_DAYS days"
…

If you later decide to increase the retention period of your backups, you’ll only need to modify the constant value to affect all cleanup scripts referring to it.

Using task parameters

Like project constants, task parameters can be used in the script content as environment variables prefixed with CTP_ (for CtFreak Task Parameter).

Here’s an example using a text task parameter named FIRST_NAME:

#!/bin/bash
echo "Hello $CTP_FIRST_NAME !"

Task parameters values are converted to text format when assigned to an environment variable.

The following conversion rules are applied according to parameter type:

  • Checkbox → Checked: true, Unchecked: false
  • Date → Formatting with the YYYY-MM-DD pattern
  • Selector, Integer and Text → No specific formatting