88 then
99 function docker() {
1010 podman $@
11+ return $?
1112 }
1213 else
1314 echo " Neither docker nor podman found!!!"
1617fi
1718
1819usage () {
19- echo " Usage: $1 [encode, hash, save, load, tag, push, clean, hostsetup]" >&2
20+ echo " Usage: $1 [encode, hash, save, load, tag, push, pull, clean, hostsetup]" >&2
2021 echo " * encode: encode a string to base64" >&2
2122 echo " * hash: hash a string using SHA-256" >&2
2223 echo " * save: save images to a tar file" >&2
2324 echo " * load: load images from a tar file" >&2
2425 echo " * tag: tag images" >&2
2526 echo " * push: push images" >&2
27+ echo " * pull: pull images from a registry" >&2
2628 echo " * clean: remove node_modules, coverage, etc" >&2
2729 echo " * hostsetup: configure host for redis" >&2
2830 echo " * hostenter: sh into vm host" >&2
2931 exit 1
32+ return 1
3033}
3134
32- saveTar () {
35+ pull_images () {
36+ if [[ " $# " -lt 1 ]]; then
37+ echo " Usage: pull <TAG> [REPO] [NAMESPACE] [SUFFIX]" >&2
38+ echo " e.g. pull 7.0.0" >&2
39+ echo " e.g. pull 7.0.0 docker.io openc3inc" >&2
40+ exit 1
41+ fi
42+ tag=$1
43+ repo=${2:- docker.io}
44+ namespace=${3:- openc3inc}
45+ suffix=" "
46+ if [[ -n " $4 " ]]; then
47+ suffix=$4
48+ fi
49+
50+ set -x
51+ docker pull $repo /$namespace /openc3-buckets$suffix :$tag
52+ docker pull $repo /$namespace /openc3-cosmos-cmd-tlm-api$suffix :$tag
53+ docker pull $repo /$namespace /openc3-cosmos-init$suffix :$tag
54+ docker pull $repo /$namespace /openc3-cosmos-script-runner-api$suffix :$tag
55+ docker pull $repo /$namespace /openc3-operator$suffix :$tag
56+ docker pull $repo /$namespace /openc3-redis$suffix :$tag
57+ docker pull $repo /$namespace /openc3-traefik$suffix :$tag
58+ docker pull $repo /$namespace /openc3-tsdb$suffix :$tag
59+ set +x
60+ return 0
61+ }
62+
63+ save_tar () {
3364 if [[ " $# " -lt 3 ]]; then
3465 echo " Usage: save <REPO> <NAMESPACE> <TAG> <SUFFIX>" >&2
3566 echo " e.g. save docker.io openc3inc 5.1.0" >&2
@@ -44,33 +75,28 @@ saveTar() {
4475 mkdir -p tmp
4576
4677 set -x
47- docker pull $repo /$namespace /openc3-ruby$suffix :$tag
48- docker pull $repo /$namespace /openc3-node$suffix :$tag
49- docker pull $repo /$namespace /openc3-base$suffix :$tag
50- docker pull $repo /$namespace /openc3-operator$suffix :$tag
78+ docker pull $repo /$namespace /openc3-buckets$suffix :$tag
5179 docker pull $repo /$namespace /openc3-cosmos-cmd-tlm-api$suffix :$tag
80+ docker pull $repo /$namespace /openc3-cosmos-init$suffix :$tag
5281 docker pull $repo /$namespace /openc3-cosmos-script-runner-api$suffix :$tag
53- docker pull $repo /$namespace /openc3-traefik $suffix :$tag
82+ docker pull $repo /$namespace /openc3-operator $suffix :$tag
5483 docker pull $repo /$namespace /openc3-redis$suffix :$tag
84+ docker pull $repo /$namespace /openc3-traefik$suffix :$tag
5585 docker pull $repo /$namespace /openc3-tsdb$suffix :$tag
56- docker pull $repo /$namespace /openc3-buckets$suffix :$tag
57- docker pull $repo /$namespace /openc3-cosmos-init$suffix :$tag
5886
59- docker save $repo /$namespace /openc3-ruby$suffix :$tag -o tmp/openc3-ruby$suffix -$tag .tar
60- docker save $repo /$namespace /openc3-node$suffix :$tag -o tmp/openc3-node$suffix -$tag .tar
61- docker save $repo /$namespace /openc3-base$suffix :$tag -o tmp/openc3-base$suffix -$tag .tar
62- docker save $repo /$namespace /openc3-operator$suffix :$tag -o tmp/openc3-operator$suffix -$tag .tar
87+ docker save $repo /$namespace /openc3-buckets$suffix :$tag -o tmp/openc3-buckets$suffix -$tag .tar
6388 docker save $repo /$namespace /openc3-cosmos-cmd-tlm-api$suffix :$tag -o tmp/openc3-cosmos-cmd-tlm-api$suffix -$tag .tar
89+ docker save $repo /$namespace /openc3-cosmos-init$suffix :$tag -o tmp/openc3-cosmos-init$suffix -$tag .tar
6490 docker save $repo /$namespace /openc3-cosmos-script-runner-api$suffix :$tag -o tmp/openc3-cosmos-script-runner-api$suffix -$tag .tar
65- docker save $repo /$namespace /openc3-traefik $suffix :$tag -o tmp/openc3-traefik $suffix -$tag .tar
91+ docker save $repo /$namespace /openc3-operator $suffix :$tag -o tmp/openc3-operator $suffix -$tag .tar
6692 docker save $repo /$namespace /openc3-redis$suffix :$tag -o tmp/openc3-redis$suffix -$tag .tar
93+ docker save $repo /$namespace /openc3-traefik$suffix :$tag -o tmp/openc3-traefik$suffix -$tag .tar
6794 docker save $repo /$namespace /openc3-tsdb$suffix :$tag -o tmp/openc3-tsdb$suffix -$tag .tar
68- docker save $repo /$namespace /openc3-buckets$suffix :$tag -o tmp/openc3-buckets$suffix -$tag .tar
69- docker save $repo /$namespace /openc3-cosmos-init$suffix :$tag -o tmp/openc3-cosmos-init$suffix -$tag .tar
7095 set +x
96+ return 0
7197}
7298
73- loadTar () {
99+ load_tar () {
74100 if [[ -z " $1 " ]]; then
75101 tag=" latest"
76102 else
@@ -81,18 +107,16 @@ loadTar() {
81107 suffix=$2
82108 fi
83109 set -x
84- docker load -i tmp/openc3-ruby$suffix -$tag .tar
85- docker load -i tmp/openc3-node$suffix -$tag .tar
86- docker load -i tmp/openc3-base$suffix -$tag .tar
87- docker load -i tmp/openc3-operator$suffix -$tag .tar
110+ docker load -i tmp/openc3-buckets$suffix -$tag .tar
88111 docker load -i tmp/openc3-cosmos-cmd-tlm-api$suffix -$tag .tar
112+ docker load -i tmp/openc3-cosmos-init$suffix -$tag .tar
89113 docker load -i tmp/openc3-cosmos-script-runner-api$suffix -$tag .tar
90- docker load -i tmp/openc3-traefik $suffix -$tag .tar
114+ docker load -i tmp/openc3-operator $suffix -$tag .tar
91115 docker load -i tmp/openc3-redis$suffix -$tag .tar
116+ docker load -i tmp/openc3-traefik$suffix -$tag .tar
92117 docker load -i tmp/openc3-tsdb$suffix -$tag .tar
93- docker load -i tmp/openc3-buckets$suffix -$tag .tar
94- docker load -i tmp/openc3-cosmos-init$suffix -$tag .tar
95118 set +x
119+ return 0
96120}
97121
98122tag () {
@@ -121,18 +145,16 @@ tag() {
121145 fi
122146
123147 set -x
124- docker tag $repo1 /$namespace1 /openc3-ruby$suffix :$tag1 $repo2 /$namespace2 /openc3-ruby$suffix :$tag2
125- docker tag $repo1 /$namespace1 /openc3-node$suffix :$tag1 $repo2 /$namespace2 /openc3-node$suffix :$tag2
126- docker tag $repo1 /$namespace1 /openc3-base$suffix :$tag1 $repo2 /$namespace2 /openc3-base$suffix :$tag2
127- docker tag $repo1 /$namespace1 /openc3-operator$suffix :$tag1 $repo2 /$namespace2 /openc3-operator$suffix :$tag2
148+ docker tag $repo1 /$namespace1 /openc3-buckets$suffix :$tag1 $repo2 /$namespace2 /openc3-buckets$suffix :$tag2
128149 docker tag $repo1 /$namespace1 /openc3-cosmos-cmd-tlm-api$suffix :$tag1 $repo2 /$namespace2 /openc3-cosmos-cmd-tlm-api$suffix :$tag2
150+ docker tag $repo1 /$namespace1 /openc3-cosmos-init$suffix :$tag1 $repo2 /$namespace2 /openc3-cosmos-init$suffix :$tag2
129151 docker tag $repo1 /$namespace1 /openc3-cosmos-script-runner-api$suffix :$tag1 $repo2 /$namespace2 /openc3-cosmos-script-runner-api$suffix :$tag2
130- docker tag $repo1 /$namespace1 /openc3-traefik $suffix :$tag1 $repo2 /$namespace2 /openc3-traefik $suffix :$tag2
152+ docker tag $repo1 /$namespace1 /openc3-operator $suffix :$tag1 $repo2 /$namespace2 /openc3-operator $suffix :$tag2
131153 docker tag $repo1 /$namespace1 /openc3-redis$suffix :$tag1 $repo2 /$namespace2 /openc3-redis$suffix :$tag2
154+ docker tag $repo1 /$namespace1 /openc3-traefik$suffix :$tag1 $repo2 /$namespace2 /openc3-traefik$suffix :$tag2
132155 docker tag $repo1 /$namespace1 /openc3-tsdb$suffix :$tag1 $repo2 /$namespace2 /openc3-tsdb$suffix :$tag2
133- docker tag $repo1 /$namespace1 /openc3-buckets$suffix :$tag1 $repo2 /$namespace2 /openc3-buckets$suffix :$tag2
134- docker tag $repo1 /$namespace1 /openc3-cosmos-init$suffix :$tag1 $repo2 /$namespace2 /openc3-cosmos-init$suffix :$tag2
135156 set +x
157+ return 0
136158}
137159
138160push () {
@@ -150,27 +172,26 @@ push() {
150172 fi
151173
152174 set -x
153- docker push $repo /$namespace /openc3-ruby$suffix :$tag
154- docker push $repo /$namespace /openc3-node$suffix :$tag
155- docker push $repo /$namespace /openc3-base$suffix :$tag
156- docker push $repo /$namespace /openc3-operator$suffix :$tag
175+ docker push $repo /$namespace /openc3-buckets$suffix :$tag
157176 docker push $repo /$namespace /openc3-cosmos-cmd-tlm-api$suffix :$tag
177+ docker push $repo /$namespace /openc3-cosmos-init$suffix :$tag
158178 docker push $repo /$namespace /openc3-cosmos-script-runner-api$suffix :$tag
159- docker push $repo /$namespace /openc3-traefik $suffix :$tag
179+ docker push $repo /$namespace /openc3-operator $suffix :$tag
160180 docker push $repo /$namespace /openc3-redis$suffix :$tag
181+ docker push $repo /$namespace /openc3-traefik$suffix :$tag
161182 docker push $repo /$namespace /openc3-tsdb$suffix :$tag
162- docker push $repo /$namespace /openc3-buckets$suffix :$tag
163- docker push $repo /$namespace /openc3-cosmos-init$suffix :$tag
164183 set +x
184+ return 0
165185}
166186
167- cleanFiles () {
187+ clean_files () {
168188 find . -type d -name " node_modules" | xargs -I {} echo " Removing {}" ; rm -rf {}
169189 find . -type d -name " coverage" | xargs -I {} echo " Removing {}" ; rm -rf {}
170190 # Prompt for removing pnpm-lock.yaml files
171191 find . -type f -name " pnpm-lock.yaml" | xargs -I {} rm -i {}
172192 # Prompt for removing Gemfile.lock files
173193 find . -type f -name " Gemfile.lock" | xargs -I {} rm -i {}
194+ return 0
174195}
175196
176197if [[ " $# " -eq 0 ]]; then
@@ -219,6 +240,27 @@ case $1 in
219240 fi
220241 echo -n $2 | shasum -a 256 | sed ' s/-//'
221242 ;;
243+ pull )
244+ if [[ " $2 " == " --help" ]] || [[ " $2 " == " -h" ]]; then
245+ echo " Usage: $0 pull REPO NAMESPACE TAG [SUFFIX]"
246+ echo " "
247+ echo " Pull all OpenC3 docker images from a registry."
248+ echo " "
249+ echo " Arguments:"
250+ echo " REPO Docker repository (e.g., docker.io)"
251+ echo " NAMESPACE Image namespace (e.g., openc3inc)"
252+ echo " TAG Image tag (e.g., latest or 5.1.0)"
253+ echo " SUFFIX Optional suffix for image names (e.g., -ubi)"
254+ echo " "
255+ echo " Example:"
256+ echo " $0 pull docker.io openc3inc 5.1.0"
257+ echo " "
258+ echo " Options:"
259+ echo " -h, --help Show this help message"
260+ exit 0
261+ fi
262+ pull_images " ${@: 2} "
263+ ;;
222264 save )
223265 if [[ " $2 " == " --help" ]] || [[ " $2 " == " -h" ]]; then
224266 echo " Usage: $0 save REPO NAMESPACE TAG [SUFFIX]"
@@ -238,7 +280,7 @@ case $1 in
238280 echo " -h, --help Show this help message"
239281 exit 0
240282 fi
241- saveTar " ${@: 2} "
283+ save_tar " ${@: 2} "
242284 ;;
243285 load )
244286 if [[ " $2 " == " --help" ]] || [[ " $2 " == " -h" ]]; then
@@ -257,7 +299,7 @@ case $1 in
257299 echo " -h, --help Show this help message"
258300 exit 0
259301 fi
260- loadTar " ${@: 2} "
302+ load_tar " ${@: 2} "
261303 ;;
262304 tag )
263305 if [[ " $2 " == " --help" ]] || [[ " $2 " == " -h" ]]; then
@@ -320,7 +362,7 @@ case $1 in
320362 echo " -h, --help Show this help message"
321363 exit 0
322364 fi
323- cleanFiles
365+ clean_files
324366 ;;
325367 hostsetup )
326368 if [[ " $2 " == " --help" ]] || [[ " $2 " == " -h" ]]; then
0 commit comments