Skip to content
Closed
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
74 changes: 73 additions & 1 deletion elements/bluefin-server/os-countme.bst
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@ description: |
system_files/shared, the same unit and helper every other image ships, so this
image counts through exactly the same bluefin-countme as the rest of the family.

Common main ships that client gated to Dakota: the units carry
ConditionOSRelease=ID=bluefin-dakota and ConditionPathExists=/run/ostree-booted,
and the script exits unless image-name starts with "dakota" and it can prove a
stable/testing stream from a bootc ref. This image is ID=bluefin-server,
declares image-name "server" only, and is a DDI with no bootc, so the element
installs drop-ins that clear the Dakota/ostree conditions and seds the two
script gates to accept this image instead. It reports repo=server with no tag
(a DDI has no container stream), the same metadata the original first-party
reporter pinned here would have sent.

The preset from common enables the timer; this image applies systemd presets,
so no enablement symlink is needed.

sources:
- kind: git_repo
url: github:projectbluefin/common.git
track: main
ref: v2026.08-108-gd46c4df9f9988002120cff4a66df8b163070fe6d
ref: v2026.08-207-g725dbf68ccff8ae2ad74300430f984ee9ea8206c

build-depends:
- base/base-stack.bst
Expand All @@ -33,3 +43,65 @@ config:
- install -Dm644 system_files/shared/usr/lib/systemd/system/bluefin-countme.service -t "%{install-root}%{prefix}/lib/systemd/system/"
- install -Dm644 system_files/shared/usr/lib/systemd/system/bluefin-countme.timer -t "%{install-root}%{prefix}/lib/systemd/system/"
- install -Dm644 system_files/shared/usr/lib/systemd/system-preset/03-bluefin-countme.preset -t "%{install-root}%{prefix}/lib/systemd/system-preset/"

# This image is ID=bluefin-server, not ID=bluefin-dakota, and is not
# ostree/bootc-managed. Clear the Dakota/ostree conditions so the units
# actually run here; keep every other condition (opt-outs included).
- |
install -d "%{install-root}%{prefix}/lib/systemd/system/bluefin-countme.service.d" \
"%{install-root}%{prefix}/lib/systemd/system/bluefin-countme.timer.d"
- |
cat > "%{install-root}%{prefix}/lib/systemd/system/bluefin-countme.service.d/10-bluefin-server.conf" <<'EOF'
[Unit]
ConditionOSRelease=
ConditionPathExists=
ConditionPathExists=!/etc/projectbluefin/countme/disabled
ConditionPathExists=!/etc/bluefin-countme-opt-out
ConditionPathExists=!/etc/dakota-countme/disabled
After=
After=network-online.target

[Service]
# The client exits non-zero when the ping cannot be delivered (no route,
# DNS down, endpoint unreachable); the timer retries daily and the client
# throttles to one success per week, so a failed attempt is not a service
# failure. Treat every exit status as success so a missed week never shows
# up in systemctl --failed.
SuccessExitStatus=0 1 2 3 4 5 6 7 8 28 35 52 56
EOF
- |
cat > "%{install-root}%{prefix}/lib/systemd/system/bluefin-countme.timer.d/10-bluefin-server.conf" <<'EOF'
[Unit]
ConditionOSRelease=
ConditionPathExists=
ConditionPathExists=!/etc/projectbluefin/countme/disabled
ConditionPathExists=!/etc/bluefin-countme-opt-out
ConditionPathExists=!/etc/dakota-countme/disabled
EOF

# Adapt the shared Dakota-scoped client to this image: count the
# "server" image name and report without a stream tag. A DDI delivered by
# systemd-sysupdate has no booted container ref, so there is no tag to
# wait on; reporting with repo=server alone is valid. The transform is
# POSIX shell (the sandbox runs sh; sed/grep/awk are not installed). The
# n1..n4 counters fail the build if common rewords any anchor.
- |
f="%{install-root}%{prefix}/libexec/bluefin-countme"
n1=0; n2=0; n3=0; n4=0
while IFS= read -r line; do
case "$line" in
'if [[ -z "$raw_name" ]] || [[ "$raw_name" != dakota* ]]; then')
line='if [[ -z "$raw_name" ]] || [[ "$raw_name" != dakota* && "$raw_name" != "server" ]]; then'; n1=1 ;;
'if [[ "$TAG" != "stable" && "$TAG" != "testing" ]]; then')
line='if [[ "$TAG" != "stable" && "$TAG" != "testing" && "$raw_name" != "server" ]]; then'; n2=1 ;;
'REPO="dakota"')
line='REPO="server"'; n3=1 ;;
*'tag=${TAG}'*)
line="${line//'tag=${TAG}'/'tag=${TAG:-none}'}"; n4=1 ;;
esac
printf '%s\n' "$line"
done < "$f" > "$f.new"
mv "$f.new" "$f"
chmod 755 "$f"
[ "$n1" = 1 ] && [ "$n2" = 1 ] && [ "$n3" = 1 ] && [ "$n4" = 1 ] || {
echo "ERROR: bluefin-countme anchors missing (n1=$n1 n2=$n2 n3=$n3 n4=$n4)" >&2; exit 1; }