From bfd56fec1c84ada197317ac2e34a677f8ba60817 Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Thu, 28 Apr 2022 10:12:41 -0500 Subject: [PATCH] CASMINST-4471 simplify build and properly load nexus images with new podman (#6) syntax Signed-off-by: Jacob Salmela --- .version | 2 +- systemd/nexus-init.sh | 28 ++++++++++++++++++---------- systemd/nexus-setup.sh | 9 +++++++-- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/.version b/.version index 781dcb0..65087b4 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -1.1.3 +1.1.4 diff --git a/systemd/nexus-init.sh b/systemd/nexus-init.sh index d072504..6e04311 100755 --- a/systemd/nexus-init.sh +++ b/systemd/nexus-init.sh @@ -36,18 +36,21 @@ fi NEXUS_PIDFILE="$1" NEXUS_CIDFILE="$2" -NEXUS_CONTAINER_NAME="${3-nexus3}" -NEXUS_VOLUME_NAME="${4:-${NEXUS_CONTAINER_NAME}3-data}" +NEXUS_CONTAINER_NAME="${3-nexus}" +NEXUS_VOLUME_NAME="${4:-${NEXUS_CONTAINER_NAME}-data}" NEXUS_VOLUME_MOUNT="/nexus-data:rw,exec" -set -x - # Create Nexus volume if not already present -if ! podman volume inspect "$NEXUS_VOLUME_NAME" ; then +if ! podman volume inspect "$NEXUS_VOLUME_NAME" &>/dev/null; then # Load busybox image if it doesn't already exist - if ! podman image inspect "$NEXUS_IMAGE" >/dev/null; then - podman load -i "$NEXUS_IMAGE_PATH" "$NEXUS_IMAGE" || exit + if ! podman image inspect "$NEXUS_IMAGE" &>/dev/null; then + # load the image + podman load -i "$NEXUS_IMAGE_PATH" || exit + # get the tag + NEXUS_IMAGE_ID=$(podman images --noheading --format "{{.Id}}" --filter label="name=Nexus Repository Manager") + # tag the image + podman tag "$NEXUS_IMAGE_ID" "$NEXUS_IMAGE" fi podman run --rm --network host \ -v "${NEXUS_VOLUME_NAME}:${NEXUS_VOLUME_MOUNT}" \ @@ -68,11 +71,16 @@ fi rm -f "$NEXUS_PIDFILE" # Create Nexus container -if ! podman inspect "$NEXUS_CONTAINER_NAME" ; then +if ! podman inspect --type container "$NEXUS_CONTAINER_NAME" &>/dev/null; then rm -f "$NEXUS_CIDFILE" || exit # Load nexus image if it doesn't already exist - if ! podman image inspect "$NEXUS_IMAGE" >/dev/null; then - podman load "$NEXUS_IMAGE_PATH" "$NEXUS_IMAGE" || exit + if ! podman image inspect "$NEXUS_IMAGE" &>/dev/null; then + # load the image + podman load -i "$NEXUS_IMAGE_PATH" + # get the tag + NEXUS_IMAGE_ID=$(podman images --noheading --format "{{.Id}}" --filter label="name=Nexus Repository Manager") + # tag the image + podman tag "$NEXUS_IMAGE_ID" "$NEXUS_IMAGE" fi podman create \ --conmon-pidfile "$NEXUS_PIDFILE" \ diff --git a/systemd/nexus-setup.sh b/systemd/nexus-setup.sh index be10e58..09cfd53 100755 --- a/systemd/nexus-setup.sh +++ b/systemd/nexus-setup.sh @@ -66,8 +66,13 @@ fi set -x -if ! podman image inspect "$NEXUS_SETUP_IMAGE" >/dev/null; then - podman load -i "$NEXUS_SETUP_IMAGE_PATH" "$NEXUS_SETUP_IMAGE" || exit +if ! podman image inspect --type image "$NEXUS_SETUP_IMAGE" &>/dev/null; then + # load the image + podman load -i "$NEXUS_SETUP_IMAGE_PATH" || exit + # get the image id + CRAY_NEXUS_SETUP_ID=$(podman images --noheading --format "{{.Id}}" --filter label="org.label-schema.name=cray-nexus-setup") + # tag the image + podman tag "$CRAY_NEXUS_SETUP_ID" "$NEXUS_SETUP_IMAGE" fi # Setup Nexus container (assumes Nexus is at http://localhost:8081)