-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathipm
More file actions
45 lines (37 loc) · 1.03 KB
/
ipm
File metadata and controls
45 lines (37 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
# ipm: convenience wrapper to run a ZPM command in an IRIS session
# Usage examples:
# ipm git-source-control test -only
# ipm -U USER git-source-control test -only -verbose
CONTAINER=${IRIS_CONTAINER:-git-source-control-iris-1}
ARGS=()
CMD=()
# Allow namespace via env
if [ -n "$IRIS_NAMESPACE" ]; then
ARGS+=( -U "$IRIS_NAMESPACE" )
elif [ -n "$IRISNAMESPACE" ]; then
ARGS+=( -U "$IRISNAMESPACE" )
fi
# Optional leading -U <ns>
if [ "$1" = "-U" ] && [ -n "$2" ]; then
ARGS+=( -U "$2" )
shift 2
fi
# Remaining args compose the ZPM command string
while [[ $# -gt 0 ]]; do
CMD+=( "$1" )
shift
done
if [ ${#CMD[@]} -eq 0 ]; then
echo "Usage: ipm [ -U <NAMESPACE> ] <zpm command and args...>" >&2
exit 1
fi
# Join CMD array into a single string
CMDSTR="${CMD[*]}"
# Escape quotes for ObjectScript string literal
CMDSTR_ESC=${CMDSTR//\"/\"\"}
# Build an OS snippet and feed to iris session via docker exec
(
echo "zpm \"${CMDSTR_ESC}\":1:1"
echo "halt"
) | docker exec -i "$CONTAINER" iris session iris "${ARGS[@]}"