Script Management

The Script Management feature allows you to create, deploy, and execute scripts on devices remotely.

Scripts Overview

Scripts in Kinuxota OTA are shell scripts and additional files that can be deployed to devices for execution. This feature is useful for:

  • Performing complex operations that require multiple commands

  • Running diagnostic procedures

  • Automating configuration tasks

  • Collecting detailed system information

  • Implementing custom update procedures

Script List

The Scripts tab in the Device Management page displays all available scripts with their key information:

  • Name: The name of the script

  • Description: A brief description of the script’s purpose

  • Created By: The user who created the script

  • Created At: When the script was created

  • Last Updated: When the script was last modified

Creating a Script

To create a new script:

  1. Navigate to the Device Management page

  2. Click the Scripts tab

  3. Click the Create Script button

  4. Fill in the required information:

    • Name: A name for the script

    • Description (optional): A description of the script’s purpose

    • Main Script: The primary script file (e.g., main.sh)

    • Additional Files (optional): Any additional files needed by the script

Script Editor

The script editor provides a code editor for creating and editing scripts. The editor supports:

  • Syntax highlighting for shell scripts

  • Line numbering

  • Code folding

  • Search and replace

Main Script

The main script is the entry point for execution. It should be a shell script (e.g., main.sh) that will be executed on the device. The main script should have a shebang line (e.g., #!/bin/bash) and be executable.

Additional Files

You can include additional files that will be deployed alongside the main script. These files can be:

  • Configuration files

  • Data files

  • Helper scripts

  • Libraries

Editing a Script

To edit an existing script:

  1. Navigate to the Device Management page

  2. Click the Scripts tab

  3. Find the script you want to edit

  4. Click the Edit button (pencil icon)

  5. Update the script information and content

  6. Click Save Script

Deleting a Script

To delete a script:

  1. Navigate to the Device Management page

  2. Click the Scripts tab

  3. Find the script you want to delete

  4. Click the Delete button (trash icon)

  5. Confirm the deletion

Deploying Scripts

Deploying to an Individual Device

  1. Navigate to the Device Management page

  2. Click the Scripts tab

  3. Find the script you want to deploy

  4. Click the Deploy button

  5. Select a device from the dropdown

  6. Click Deploy Script

Script Execution

After deploying a script, you can execute it:

  1. Navigate to the Device Management page

  2. Click the Scripts tab

  3. Click the Executions tab

  4. Find the script execution you want to run

  5. Click the Execute button

Script Execution Status

Script executions can have the following statuses:

  • PENDING: The script execution has been created but not yet deployed

  • DEPLOYING: The script is being deployed to the device

  • DEPLOYED: The script has been deployed to the device but not yet executed

  • EXECUTING: The script is currently running on the device

  • COMPLETED: The script has completed successfully

  • FAILED: The script failed to execute

  • CANCELLED: The script execution was cancelled

Script Execution Details

Click on a script execution in the list to view its details, which includes:

  • Execution Information: Status, start time, completion time, etc.

  • Script Content: The content of the main script and additional files

  • Execution Logs: The output of the script execution

  • Exit Code: The exit code of the script (0 for success, non-zero for failure)

Cancelling Script Execution

To cancel a script execution:

  1. Navigate to the Device Management page

  2. Click the Scripts tab

  3. Click the Executions tab

  4. Find the script execution you want to cancel

  5. Click the Cancel button

Script Execution Flow

  1. Script Creation: The script is created in the dashboard

  2. Script Deployment: The script is deployed to the device

  3. Script Execution: The script is executed on the device

  4. Result Reporting: The device sends the execution result back to the dashboard

  5. Result Display: The dashboard displays the execution result

Script Best Practices

  • Error Handling: Include error handling in your scripts to gracefully handle failures

  • Logging: Add logging statements to help troubleshoot issues

  • Idempotence: Design scripts to be idempotent (can be run multiple times without side effects)

  • Timeouts: Implement timeouts for operations that might hang

  • Cleanup: Include cleanup code to remove temporary files and restore the system state

  • Exit Codes: Return appropriate exit codes to indicate success or failure