Skip to main content

By script

This document explains the differences between the interactive and non-interactive canister management scripts, their use cases, and the prerequisites required to run them.


Prerequisites

1. Install Required Tools:

2. Set Up a Toolkit Hotkey

Both scripts require your DFX identity principal to be configured as a hotkey in the Toolkit UI for authentication.

Steps:

  1. Open the Toolkit UI.
  2. Navigate to Settings > Hotkeys.
  3. Add your principal as a hotkey:
    • Get your DFX principal using:
      dfx identity get-principal
  4. Save the changes.

Script Comparison: Interactive vs Non-Interactive

1. Interactive Script

Path: scripts/manage-canister-interactive.sh

The interactive script provides a step-by-step workflow for managing canisters. It guides you through:

  1. Operation Selection: Choose between installing, reinstalling, or upgrading a canister.
  2. Input Collection: Prompts you for the root canister ID, target canister ID, WASM module path, and optional Candid arguments.
  3. Input Persistence: Remembers your inputs from previous runs and offers them as defaults.

Use Case:

Ideal for developers who want a simple and user-friendly interface for managing canisters during development or testing.

Benefits:

  • No prior configuration required.
  • Input persistence reduces repetitive tasks.
  • Guides users through each step with validation and confirmations.

2. Non-Interactive Script

Path: scripts/upgrade_canister.sh

The non-interactive script is designed for automation and can be tailored for specific use cases. Unlike the interactive script, it does not prompt for inputs and requires modification of the script itself.

How It Works:

  • You define the root canister ID, target canister ID, WASM module path, and optional Candid arguments directly in the script.
  • It executes the operation (install, reinstall, or upgrade) without user input.

Use Case:

Perfect for CI/CD pipelines or automated workflows where you need consistent, repeatable, and unattended operations.

Benefits:

  • Fully automated once configured.
  • Ideal for integrating with CI/CD pipelines.
  • Reduces manual errors in repetitive tasks.

Summary of Differences

FeatureInteractive ScriptNon-Interactive Script
Input CollectionPrompts the user interactivelyHardcoded in the script
Use CaseDevelopment/testing environmentsCI/CD pipelines, automation
Input PersistenceSaves previous inputs for reuseNot applicable
User ConfirmationRequires confirmation before runningNo user interaction required
ExecutionGuided and manualAutomated and repeatable

Choosing the Right Script

  • Use the interactive script if you’re managing canisters manually and need flexibility during development or testing.
  • Use the non-interactive script if you want to automate canister management in CI/CD pipelines or other workflows.