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:
Navigate to the Device Management page
Click the Scripts tab
Click the Create Script button
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:
Navigate to the Device Management page
Click the Scripts tab
Find the script you want to edit
Click the Edit button (pencil icon)
Update the script information and content
Click Save Script
Deleting a Script
To delete a script:
Navigate to the Device Management page
Click the Scripts tab
Find the script you want to delete
Click the Delete button (trash icon)
Confirm the deletion
Deploying Scripts
Deploying to an Individual Device
Navigate to the Device Management page
Click the Scripts tab
Find the script you want to deploy
Click the Deploy button
Select a device from the dropdown
Click Deploy Script
Script Execution
After deploying a script, you can execute it:
Navigate to the Device Management page
Click the Scripts tab
Click the Executions tab
Find the script execution you want to run
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:
Navigate to the Device Management page
Click the Scripts tab
Click the Executions tab
Find the script execution you want to cancel
Click the Cancel button
Script Execution Flow
Script Creation: The script is created in the dashboard
Script Deployment: The script is deployed to the device
Script Execution: The script is executed on the device
Result Reporting: The device sends the execution result back to the dashboard
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