summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-16 08:41:34 +0300
committerPaul Buetow <paul@buetow.org>2026-04-16 08:41:34 +0300
commit71211a54519e13c9ba5ba928352fa4fef001240b (patch)
tree247196705644ac036ce65960daf3be1e996bdcec /contrib
parent6b743ff9eb937b35595ac74453e24ca3e19c4a18 (diff)
Add unified upload client script under scripts/, update contrib and docs
- scripts/goprecords-upload-client.sh: unified POSIX sh script working on all host types (FreeBSD f0-f3, Rocky Linux pi0-pi3, Fedora earth, OpenBSD blowfish/fishfinger). Key addition over the old contrib/ version: non-root support via XDG_CONFIG_HOME token path so user-session installs (earth) work without requiring a hardcoded /etc path. - contrib/goprecords-upload-client.sh: updated to match the canonical script in scripts/ (same content). - README.md: updated manual-upload section to reference scripts/ as canonical location, added host-class table, added user-session systemd example, and expanded environment variable table to show root vs non-root defaults. - Deployed new script to f0, f1, f2, pi0-pi3; tested uploads from all hosts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/goprecords-upload-client.sh38
1 files changed, 27 insertions, 11 deletions
diff --git a/contrib/goprecords-upload-client.sh b/contrib/goprecords-upload-client.sh
index e235c51..7e04cd9 100755
--- a/contrib/goprecords-upload-client.sh
+++ b/contrib/goprecords-upload-client.sh
@@ -1,10 +1,20 @@
#!/bin/sh
set -e
GOPRECORDS_BASE_URL="${GOPRECORDS_BASE_URL:-https://goprecords.f3s.buetow.org}"
-GOPRECORDS_HOST="${GOPRECORDS_HOST:?set GOPRECORDS_HOST (e.g. f0, pi0)}"
-GOPRECORDS_TOKEN_FILE="${GOPRECORDS_TOKEN_FILE:-/etc/goprecords-upload.token}"
+GOPRECORDS_HOST="${GOPRECORDS_HOST:?set GOPRECORDS_HOST (e.g. f0, pi0, earth)}"
PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:${PATH}"
+_default_token_file() {
+ if [ "$(id -u)" = "0" ]; then
+ printf '/etc/goprecords-upload.token'
+ else
+ config="${XDG_CONFIG_HOME:-${HOME}/.config}"
+ printf '%s/goprecords-upload-%s/token' "$config" "$GOPRECORDS_HOST"
+ fi
+}
+
+GOPRECORDS_TOKEN_FILE="${GOPRECORDS_TOKEN_FILE:-$(_default_token_file)}"
+
if ! test -r "$GOPRECORDS_TOKEN_FILE"; then
echo "goprecords-upload-client: cannot read $GOPRECORDS_TOKEN_FILE" >&2
exit 1
@@ -23,17 +33,21 @@ upload() {
"${GOPRECORDS_BASE_URL}/upload/${GOPRECORDS_HOST}/${kind}"
}
-records_path=
-if test -f /var/spool/uptimed/records; then
- records_path=/var/spool/uptimed/records
-elif test -f /var/db/uptimed/records; then
- records_path=/var/db/uptimed/records
-elif test -f /usr/local/var/uptimed/records; then
- records_path=/usr/local/var/uptimed/records
-else
+_find_records() {
+ for p in \
+ /var/spool/uptimed/records \
+ /var/db/uptimed/records \
+ /usr/local/var/uptimed/records; do
+ if test -f "$p"; then
+ printf '%s' "$p"
+ return 0
+ fi
+ done
echo "goprecords-upload-client: no uptimed records file found" >&2
exit 1
-fi
+}
+
+records_path=$(_find_records)
tmp=$(mktemp)
trap 'rm -f "$tmp"' 0 INT TERM HUP
@@ -51,6 +65,8 @@ fi
if test -r /etc/os-release; then
upload os.txt /etc/os-release
+elif test -r /var/run/dmesg.boot; then
+ upload os.txt /var/run/dmesg.boot
else
uname -a >"$tmp"
upload os.txt "$tmp"