Skip to content

Commit

Permalink
Get systemd service name from config
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulh committed Mar 11, 2024
1 parent 85eda32 commit 5ecac70
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions scripts/pull_calaos_image
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,24 @@ source "$url"
image_base=$(echo "$IMAGE_SRC" | cut -d: -f 1)
image_tag=$(echo "$IMAGE_SRC" | cut -d: -f 2)

if [ -z "$SERVICE_NAME" ]; then
SERVICE_NAME="$pkgname.service"
fi

#check if $SERVICE_NAME is a valid service
if ! systemctl list-units --type=service | grep -q "$SERVICE_NAME"; then
echo "Service $SERVICE_NAME does not exist."
unset SERVICE_NAME
exit 1
fi

echo " > Pulling new image $IMAGE_SRC"
podman pull "$IMAGE_SRC"

echo " > Stoping old container"
systemctl stop "$pkgname" || true
if [ -n "$SERVICE_NAME" ]; then
echo " > Stopping service $SERVICE_NAME"
systemctl stop "$SERVICE_NAME" || true
fi

echo " > Removing old container image and get tag"
for i in $(podman images | grep "$image_base" | awk '{print $3}')
Expand Down

0 comments on commit 5ecac70

Please sign in to comment.