Distributing and running scripts

It is possible to play out and run complex scripts with qbee.io. The function used for this is file distribution. Please upload your files or scripts with the qbee file manager and follow the following steps:

  1. Upload any files with the file manager. Please note the pathes.

  2. In the qbee app go to "Configure" and select "System->File Distribution".

    On the device tab select the group or device that is in scope. For more inofrmation please see the configure documentation.

  3. Start the actual file distribution definition:

    File Source:

    Production/somescript.sh
    

    File Destination:

    /usr/local/bin/somescript.sh
    

    When does this file gets played out?

    qbee checks if the file exists in the defined destination. If not it will be transfered. Both the file in the file manager and the file on the machine have a hash. If the file manager file is replaced a new file distribution happens. Likewise, if the file on the target machine is changed this will also trigger a new file download and the changes will be overwritten with the original file from the file manager.

    Warning

    This behaviour is very useful. But if a process on the target device is working against a file that is watched by qbee file distribution this can cause continuous file downloads. This will be seen in the logs.

  4. In order to do anything with the script the optional "Command to run" function can be used. Here commands can be chained using "&&" and this opens up for a lot of options. In this case we do two simple operations:

    Change the script permissions to executable and run the script:

    chmod +x /usr/local/bin/somescript.sh && /usr/local/bin/somescript.sh
    

    These commands will be triggered any time the file is distributed again

    If the file in the file manager or the file on the target is replaced or changed these commands get run again.

  5. (Optional) It is possible to parametrize the scripts from the qbee UI. Any number of key-value pairs can be defined. By abstracting certain things in the somescript.sh file with Mustache notation the key-value can be defined in the UI. One example could be username and password. Please check the Template box and add key-value inputs with the green "+".

    username = "{{username}}"
    password = "{{password}}"

    These key-value pairs will be defined in the UI and then replaced in the somescript.sh file that is written on the target. This way different groups could get different usernames and passwords easily

Simple script distribution:

qbee-script-distribution-simple

Script distribution with Templating:

qbee-script-distribution-templating