Initial import: nasmon health monitor, split out of home_nas

Go service (nasmon/) plus nfpm packaging (packaging/), carried over from
the home_nas monorepo. Adds rpm packaging alongside the existing deb
build (Fedora/RHEL/Rocky dependency names via nfpm overrides, per-format
systemd unit path, dpkg+rpm-compatible maintainer scripts) and a Gitea
Actions workflow that builds both formats on every push.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-19 10:24:34 +03:00
co-authored by Claude Sonnet 5
commit 09159a5f31
61 changed files with 7882 additions and 0 deletions
+56
View File
@@ -0,0 +1,56 @@
#!/usr/bin/env bash
# Builds the nasmon binary (linux/amd64, static) and packs it into .deb and .rpm with nfpm.
# Output: dist/nasmon_<version>_amd64.deb and dist/nasmon-<version>.<arch>.rpm
#
# One-time setup:
# go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest
#
# Usage:
# ./build.sh # version from git tag, or 0.1.0+<timestamp>
# VERSION=0.2.0 ./build.sh
# TEST=1 ./build.sh # run go vet + go test first
set -euo pipefail
root="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
dist="$root/dist"
for tool in go nfpm; do
command -v "$tool" >/dev/null 2>&1 || { echo "$tool not found - see the setup notes at the top of build.sh" >&2; exit 1; }
done
version="${VERSION:-}"
if [ -z "$version" ] && command -v git >/dev/null 2>&1; then
tag="$(cd "$root" && git describe --tags --always --dirty 2>/dev/null || true)"
if [[ "$tag" =~ ^v?([0-9]+\.[0-9]+\.[0-9]+)(-([0-9]+)-g([0-9a-f]+))?(-dirty)?$ ]]; then
version="${BASH_REMATCH[1]}"
[ -n "${BASH_REMATCH[3]}" ] && version+="+git${BASH_REMATCH[3]}.${BASH_REMATCH[4]}"
[ -n "${BASH_REMATCH[5]}" ] && version+=".dirty"
fi
fi
[ -z "$version" ] && version="0.1.0+$(date +%Y%m%d.%H%M)"
mkdir -p "$dist"
if [ "${TEST:-}" = "1" ]; then
echo "==> go vet / go test"
(cd "$root" && go vet ./... && go test ./...)
fi
echo "==> Building nasmon $version (linux/amd64)"
(cd "$root" && GOOS=linux GOARCH=amd64 CGO_ENABLED=0 \
go build -trimpath -ldflags "-s -w -X main.version=$version" -o "$dist/nasmon" ./cmd/nasmon)
echo "==> Packaging .deb"
rm -f "$dist"/nasmon_*.deb
(cd "$root/packaging" && NASMON_VERSION="$version" nfpm package -f nfpm.yaml -p deb -t "$dist")
echo "==> Packaging .rpm"
rm -f "$dist"/nasmon-*.rpm
(cd "$root/packaging" && NASMON_VERSION="$version" nfpm package -f nfpm.yaml -p rpm -t "$dist")
for pkg in "$dist"/nasmon*.deb "$dist"/nasmon*.rpm; do
[ -e "$pkg" ] || continue
size_mb=$(du -m "$pkg" | cut -f1)
echo "==> $pkg (${size_mb} MB)"
done