#!/usr/bin/bash # Modified from https://github.com/ublue-os/bazzite/blob/main/system_files/desktop/shared/usr/libexec/ublue-motd RPM_OSTREE_STATUS=$(rpm-ostree status --json --booted) IMAGE_REF_NAME=$(echo $RPM_OSTREE_STATUS | jq -r '.deployments[0]."container-image-reference" // empty | split("/")[-1]') IMAGE_TAG=$(echo $RPM_OSTREE_STATUS | jq -r '.deployments[0]."container-image-reference" // empty | split(":")[-1]') TIP="" IMAGE_DATE=$(echo $RPM_OSTREE_STATUS | jq -r '.deployments[0].timestamp') CURRENT_SECONDS=$(date +%s) DIFFERENCE=$((CURRENT_SECONDS - IMAGE_DATE)) WEEK=$((7 * 24 * 60 * 60)) readarray -t imageTypes < <(jq -r '.imageTypes[]' /usr/libexec/deprecated-images.json) isDeprecated=false for imageType in "${imageTypes[@]}"; do if [[ "$IMAGE_REF_NAME" == *"$imageType"* ]]; then isDeprecated=true break fi done if $isDeprecated; then TIP='**You are on a deprecated image,** [rebase:](https://github.com/secureblue/secureblue/blob/live/files/system/usr/libexec/deprecated-images.json.md)' elif [ "$IMAGE_TAG" != "latest" ]; then TIP='**You are on a specific tag, which is unsupported by secureblue. Rebase to the `latest` tag to ensure you continue to receive updates.**' elif [ "$DIFFERENCE" -ge "$WEEK" ]; then TIP='**Your current image is over 1 week old, run `ujust update`.**' else TIP='**For secureblue release notifications,** [subscribe:](https://github.com/secureblue/secureblue/blob/live/FAQ.md#release-notifications)' fi sed -e "s/%IMAGE_REF_NAME%/$IMAGE_REF_NAME/g" -e "s/%IMAGE_TAG%/$IMAGE_TAG/g" -e "s|%TIP%|$TIP|g" /usr/share/ublue-os/motd/secureblue.md | tr '~' '\n' | glow -s auto -w 78 -