Files
secureblue/files/system/usr/libexec/ublue-motd
HryshcIlya 1106f0e897 docs: update URLs to reflect new file structure (#333)
* docs: update URLs to reflect new file structure

This commit updates various documentation and configuration file URLs to match the new directory structure for the secureblue project. These changes ensure that links resolve correctly and point to the appropriate files after the recent reorganization.

* chore: delete file vanadium_comparison.readme.md

---------

Co-authored-by: qoijjj <129108030+qoijjj@users.noreply.github.com>
2024-07-26 21:22:31 -07:00

40 lines
1.7 KiB
Bash
Executable File

#!/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)
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=$(rpm-ostree status --booted | sed -n 's/.*Timestamp: \(.*\)/\1/p')
IMAGE_DATE_SECONDS=$(date -d "$IMAGE_DATE" +%s)
CURRENT_SECONDS=$(date +%s)
DIFFERENCE=$((CURRENT_SECONDS - IMAGE_DATE_SECONDS))
MONTH=$((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='~~~ NOTICE: You are on a deprecated image, please rebase. ~~~\n~~~ For more information, visit https://github.com/secureblue/secureblue/blob/live/files/system/usr/libexec/deprecated-images.json.md ~~~'
elif [ "$IMAGE_TAG" != "latest" ]; then
TIP='~~~ NOTICE: 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 "$MONTH" ]; then
TIP='~~~ NOTICE: Your current image is over 1 week old, run `ujust update`. ~~~'
else
TIP='~~~ NOTICE: There is currently no notice. ~~~'
fi
TIP_OUTPUT=$(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.txt)
while IFS= read -r line; do
echo "$line"
done <<< $TIP_OUTPUT