How to execute a Bash script on a compute

Step 1. Drop

  • Drop the Bash component on a compute (e.g., Bash_1).

../_images/7-Bash-properties.png

Figure 1. Bash_1 on Compute_1

Step 2. Write a script

  1. Click on the Bash component to open the code editor.

../_images/7-Bash-configure.png

Figure 2. Configure a Bash component

  1. Copy and paste the following script in the code editor and Save File.

#!/usr/bin/env bash

echo "Start configuring $NODE on compute $HOST"
echo "I have the ip address: $ip_address"

In this example, $NODE, $HOST, and $ip_address are pre-defined environment variables. They will be resolved to the component name (e.g., Bash_1), the hosted compute (e.g., Compute_1), and the IP address of the compute (e.g., 10.0.0.3), respectively at runtime.

Tip

For more environment variables, see Section Environment variables for Bash script.

(Alternative) Upload a script

If you have already had a script, you can upload it from your local machine:

  1. Go to Artifacts / configure artifact.

  2. Upload a Local file.

  3. Select the file you have uploaded (e.g., my_file.sh).

../_images/7-Bash-configure-upload.png

Figure 3. Providing artifacts for a Bash component

Expected result

During the deployment, the orchestrator executes Bash_1 on the Compute_1 and print out the logs:

Start configuring Bash_1 on compute Compute_1
I have the ip address: 10.0.0.3

Artifacts management

  • Go to Archive content. This section allows you to manage all file artifacts that you uploaded or created for your application.

../_images/7-Bash-archive-content.png

Figure 4. View all artifacts