diff --git a/config/files/usr/libexec/ublue-motd b/config/files/usr/libexec/ublue-motd new file mode 100644 index 0000000..1a37a1e --- /dev/null +++ b/config/files/usr/libexec/ublue-motd @@ -0,0 +1,27 @@ +#!/usr/bin/bash + +# Modified from https://github.com/ublue-os/bazzite/blob/main/system_files/desktop/shared/usr/libexec/ublue-motd +escape() { + sed 's/[&/\]/\\&/g' <<< "$1" +} + +IMAGE_INFO="/usr/share/ublue-os/image-info.json" +IMAGE_NAME=$(jq -r '."image-name"' < $IMAGE_INFO) +IMAGE_NAME_ESCAPED=$(escape "$IMAGE_NAME") +IMAGE_TAG=$(jq -r '."image-tag"' < $IMAGE_INFO) +IMAGE_TAG_ESCAPED=$(escape "$IMAGE_TAG") +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=$((30 * 24 * 60 * 60)) +if [ "$DIFFERENCE" -ge "$MONTH" ]; then + TIP='# 󰇻 Your current image is over 1 month old, run `ujust update`' +fi + +TIP_ESCAPED=$(escape "$TIP") + +TIP_OUTPUT=sed -e "s/%IMAGE_NAME%/$IMAGE_NAME_ESCAPED/g" -e "s/%IMAGE_TAG%/$IMAGE_TAG_ESCAPED/g" -e "s/%TIP%/$TIP_ESCAPED/g" /usr/share/ublue-os/motd/secureblue.txt | tr '~' '\n' +echo $TIP_OUTPUT \ No newline at end of file diff --git a/config/files/usr/share/ublue-os/motd/secureblue.txt b/config/files/usr/share/ublue-os/motd/secureblue.txt new file mode 100644 index 0000000..f02b7cb --- /dev/null +++ b/config/files/usr/share/ublue-os/motd/secureblue.txt @@ -0,0 +1,11 @@ +Welcome to secureblue! +Your image is: %IMAGE_NAME%:%IMAGE_TAG% + +Commands: +| `ujust` | List all available commands | +| `ujust toggle-user-motd` | Toggle this banner on/off | + +%TIP% +To report an issue: https://github.com/secureblue/secureblue/issues +FAQ: https://github.com/secureblue/secureblue/blob/live/FAQ.md +Discord: https://discord.gg/qMTv5cKfbF \ No newline at end of file