Skip to content
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

CASMINST-4471 adjust init script for podman load behavior #14

Merged
merged 1 commit into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.11
1.1.12
15 changes: 9 additions & 6 deletions init/basecamp-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,14 @@
# OTHER DEALINGS IN THE SOFTWARE.
#

set -x
if [ $# -lt 2 ]; then
echo >&2 "usage: basecamp-init PIDFILE CIDFILE [CONTAINER [VOLUME]]"
exit 1
fi

BASECAMP_PIDFILE="$1"
BASECAMP_CIDFILE="$2"
BASECAMP_CONTAINER_NAME="${3-metal\-basecamp}"
BASECAMP_VOLUME_NAME="${4:-${BASECAMP_CONTAINER_NAME}-configs}"
BASECAMP_CONTAINER_NAME="${3-basecamp}"

BASECAMP_IMAGE_PATH="@@basecamp-path@@"
BASECAMP_IMAGE="@@basecamp-image@@"
Expand Down Expand Up @@ -68,11 +66,16 @@ EOF

mkdir -pv "$(echo ${BASECAMP_VOLUME_MOUNT_STATIC} | cut -f 1 -d :)"
# Create basecamp container
if ! podman inspect "$BASECAMP_CONTAINER_NAME" ; then
if ! podman inspect "$BASECAMP_CONTAINER_NAME" &>dev/null; then
rm -f "$BASECAMP_CIDFILE" || exit
# Load basecamp image if it doesn't already exist
if ! podman image inspect "$BASECAMP_IMAGE" >dev/null; then
podman load "$BASECAMP_IMAGE_PATH" "$BASECAMP_IMAGE" || exit
if ! podman image inspect "$BASECAMP_IMAGE" &>dev/null; then
# load the image
podman load -i "$BASECAMP_IMAGE_PATH" || exit
# get the image id
BASECAMP_IMAGE_ID=$(podman images --noheading --format "{{.Id}}" --filter label="org.label-schema.name=$BASECAMP_CONTAINER_NAME")
# tag the image
podman tag "$BASECAMP_IMAGE_ID" "$BASECAMP_IMAGE"
fi
podman create \
--conmon-pidfile "$BASECAMP_PIDFILE" \
Expand Down
6 changes: 4 additions & 2 deletions init/basecamp.service
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ ExecStartPre=/usr/sbin/basecamp-init.sh %t/%n-pid %t/%n-cid basecamp
ExecStart=/usr/bin/podman start basecamp
ExecStop=/usr/bin/podman stop --ignore -t 10 basecamp
PIDFile=%t/%n-pid
KillMode=none
# all remaining processes in the control group of this unit will be killed on unit stop
# https://www.suse.com/support/kb/doc/?id=000020394
KillMode=control-group
Type=forking

[Install]
WantedBy=multi-user.target
WantedBy=multi-user.target