-
Notifications
You must be signed in to change notification settings - Fork 27
Add iriscli and ipm container utility scripts #1124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c7bb200
Add iriscli and ipm container utility scripts
isc-dchui 1a7f2e9
Enable ipm and iriscli scripts to work outside of containers
isc-dchui 373a05e
Add documentation, -h help flag, and -i IRIS instance flag
isc-dchui a5de3fe
Fix installer because macros aren't available during bootstrapping
isc-dchui 94cde09
Merge branch 'main' into container-scripts
isc-dchui File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,5 @@ | |
| *.mac text eol=lf | ||
| *.int text eol=lf | ||
| Dockerfil* text eol=lf | ||
| ipm text eol=lf | ||
| iriscli text eol=lf | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| #!/bin/bash | ||
|
|
||
| # ipm: convenience wrapper to run an IPM command in an IRIS session | ||
| # | ||
| # Usage: ipm [-U <namespace>] [-i <instance>] <IPM command and args...> | ||
| # | ||
| # Options: | ||
| # -U <namespace> IRIS namespace to run in (default: USER, or $IRIS_NAMESPACE / $IRISNAMESPACE) | ||
| # -i <instance> IRIS instance name (default: $ISC_PACKAGE_INSTANCENAME, then "iris") | ||
| # -h, --help Show this help message | ||
| # | ||
| # Examples: | ||
| # ipm list # list all installed modules | ||
| # ipm install MyModule # install a module from the registry | ||
| # ipm test MyModule -only # run tests for a module | ||
| # ipm -U USER list # run in a specific namespace | ||
| # ipm -i iris list # run against a specific IRIS instance | ||
|
|
||
| # Arrays to accumulate iris session flags and the IPM command tokens | ||
| ARGS=() | ||
| CMD=() | ||
|
|
||
| # Default instance: prefer the container-standard env var, fall back to "iris" | ||
| INSTANCE="${ISC_PACKAGE_INSTANCENAME:-iris}" | ||
|
|
||
| # Seed ARGS with a namespace from the environment if one is set | ||
| if [ -n "$IRIS_NAMESPACE" ]; then | ||
| ARGS+=( -U "$IRIS_NAMESPACE" ) | ||
| elif [ -n "$IRISNAMESPACE" ]; then | ||
| ARGS+=( -U "$IRISNAMESPACE" ) | ||
| fi | ||
|
|
||
| # Parse command-line arguments | ||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| -h|--help) | ||
| # Print the comment block at the top of this file, stripping the leading "# " | ||
| sed -n '3,17p' "$0" | sed 's/^# \?//' | ||
| exit 0 | ||
| ;; | ||
| -U) | ||
| # Explicit -U overrides any namespace set from the environment | ||
| ARGS=( -U "$2" ) | ||
| shift 2 | ||
| ;; | ||
| -i) | ||
| INSTANCE="$2" | ||
| shift 2 | ||
| ;; | ||
| *) | ||
| # All remaining arguments form the IPM command string | ||
| CMD+=( "$1" ) | ||
| shift | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| if [ ${#CMD[@]} -eq 0 ]; then | ||
| echo "Usage: ipm [-U <namespace>] [-i <instance>] <IPM command and args...>" >&2 | ||
| echo " ipm --help for more information" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Join the CMD array into a single string for the ObjectScript zpm call | ||
| CMDSTR="${CMD[*]}" | ||
| # Escape any double-quotes in the command string ("" is a literal " in ObjectScript strings) | ||
| CMDSTR_ESC=${CMDSTR//\"/\"\"} | ||
|
|
||
| # Pipe the zpm command into iris session; :1:1 flags suppress the session banner and prompt | ||
| ( | ||
| echo "zpm \"${CMDSTR_ESC}\":1:1" | ||
| echo "halt" | ||
| ) | iris session "$INSTANCE" "${ARGS[@]}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| #!/bin/bash | ||
|
|
||
| # iriscli: convenience wrapper to open an IRIS terminal session or run a script file | ||
| # | ||
| # Usage: iriscli [-U <namespace>] [-i <instance>] [<script file> [param...]] | ||
| # | ||
| # Options: | ||
| # -U <namespace> IRIS namespace to connect to (default: $IRIS_NAMESPACE / $IRISNAMESPACE) | ||
| # -i <instance> IRIS instance name (default: $ISC_PACKAGE_INSTANCENAME, then "iris") | ||
| # -h, --help Show this help message | ||
| # | ||
| # Examples: | ||
| # iriscli # interactive session | ||
| # iriscli -U USER # interactive session in USER namespace | ||
| # iriscli -i iris # interactive session on a named instance | ||
| # iriscli /path/to/script.script # run a script file and halt | ||
| # iriscli /path/to/script.script arg1 arg2 # run with params exposed as params(1), params(2) | ||
| # | ||
| # Script file format: ObjectScript, one command per line; blank lines and lines | ||
| # starting with ;, #, or // are ignored. | ||
|
|
||
| # Arrays to accumulate iris session flags and script parameters | ||
| ARGS=() | ||
| PARAMS=() | ||
|
|
||
| # Default instance: prefer the container-standard env var, fall back to "iris" | ||
| INSTANCE="${ISC_PACKAGE_INSTANCENAME:-iris}" | ||
|
|
||
| # Path to the script file to run (empty = interactive mode) | ||
| file= | ||
|
|
||
| # Seed ARGS with a namespace from the environment if one is set | ||
| if [ -n "$IRIS_NAMESPACE" ]; then | ||
| ARGS+=( -U "$IRIS_NAMESPACE" ) | ||
| elif [ -n "$IRISNAMESPACE" ]; then | ||
| ARGS+=( -U "$IRISNAMESPACE" ) | ||
| fi | ||
|
|
||
| # Parse command-line arguments | ||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| -h|--help) | ||
| # Print the comment block at the top of this file, stripping the leading "# " | ||
| sed -n '3,20p' "$0" | sed 's/^# \?//' | ||
| exit 0 | ||
| ;; | ||
| -U) | ||
| # Explicit -U overrides any namespace set from the environment | ||
| ARGS=( -U "$2" ) | ||
| shift 2 | ||
| ;; | ||
| -i) | ||
| INSTANCE="$2" | ||
| shift 2 | ||
| ;; | ||
| *) | ||
| # First non-flag argument that is an existing file becomes the script to run; | ||
| # everything after that is treated as a parameter passed into the script. | ||
| if [ -z "$file" ] && [ -f "$1" ]; then | ||
| file=$1 | ||
| else | ||
| PARAMS+=("$1") | ||
| fi | ||
| shift | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| if [ -n "$file" ]; then | ||
| # Script mode: pipe ObjectScript into iris session and halt when done. | ||
| # The subshell groups all input so iris session receives it as a single stdin stream. | ||
| ( | ||
| # Expose any extra arguments as params(1), params(2), ... in ObjectScript. | ||
| # Double-quotes inside param values are escaped by doubling them ("" is a literal " in ObjectScript strings). | ||
| for param in "${PARAMS[@]}"; do | ||
| echo "Set params(\$i(params)) = \"${param//\"/\"\"}\"" | ||
| done | ||
| # Strip comment lines (starting with ;, #, //) and blank lines before feeding to IRIS | ||
| grep -Ev '^(;|#|//)' "$file" | grep -v '^$' | ||
| echo halt | ||
| ) | iris session "$INSTANCE" "${ARGS[@]}" | ||
| else | ||
| # Interactive mode: just open a session | ||
| iris session "$INSTANCE" "${ARGS[@]}" | ||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.