From 4c0ef3a61421217ba7b158b5e2654bd8ba2c9bf5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 16 Sep 2026 09:48:41 +0200 Subject: [PATCH] ungleich-ups: bump to 0.2.2 --- ungleich-ups/Dockerfile_0.2.0 | 19 +++++++++++++++++++ ungleich-ups/Dockerfile_0.2.1 | 1 + ungleich-ups/Dockerfile_0.2.2 | 20 ++++++++++++++++++++ ungleich-ups/README.org | 7 +++++++ ungleich-ups/daemonset.yaml | 14 +++++++------- ungleich-ups/entrypoint.sh | 16 ++++++++++++++-- 6 files changed, 68 insertions(+), 9 deletions(-) create mode 100644 ungleich-ups/Dockerfile_0.2.0 create mode 120000 ungleich-ups/Dockerfile_0.2.1 create mode 100644 ungleich-ups/Dockerfile_0.2.2 diff --git a/ungleich-ups/Dockerfile_0.2.0 b/ungleich-ups/Dockerfile_0.2.0 new file mode 100644 index 0000000..365dc0c --- /dev/null +++ b/ungleich-ups/Dockerfile_0.2.0 @@ -0,0 +1,19 @@ +FROM alpine:3.24 + +RUN apk add -U nut + +# Bug: https://gitlab.alpinelinux.org/alpine/aports/-/work_items/18437 +RUN ln -s /usr/lib/libusb-1.0.so.0.6.0 /usr/lib/libusb-1.0.so.0.5.0 + +# Allow a prometheus plugin to connect to it +RUN sed -i 's/MODE=none/MODE=netserver/' /etc/nut/nut.conf + +# Only listen on localhost, but need ipv4 for nut_exporter +RUN echo LISTEN ::1 3493 >> /etc/nut/upsd.conf + +# Needed by upsd +RUN mkdir -p /var/run/nut + +COPY entrypoint.sh / + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/ungleich-ups/Dockerfile_0.2.1 b/ungleich-ups/Dockerfile_0.2.1 new file mode 120000 index 0000000..e400b50 --- /dev/null +++ b/ungleich-ups/Dockerfile_0.2.1 @@ -0,0 +1 @@ +Dockerfile_0.2.0 \ No newline at end of file diff --git a/ungleich-ups/Dockerfile_0.2.2 b/ungleich-ups/Dockerfile_0.2.2 new file mode 100644 index 0000000..e4a6253 --- /dev/null +++ b/ungleich-ups/Dockerfile_0.2.2 @@ -0,0 +1,20 @@ +FROM alpine:3.24 + +RUN apk add -U nut + +# Bug: https://gitlab.alpinelinux.org/alpine/aports/-/work_items/18437 +RUN ln -s /usr/lib/libusb-1.0.so.0.6.0 /usr/lib/libusb-1.0.so.0.5.0 + +# Allow a prometheus plugin to connect to it +RUN sed -i 's/MODE=none/MODE=netserver/' /etc/nut/nut.conf + +# Only listen on localhost, but need ipv4 for nut_exporter +RUN echo LISTEN ::1 3493 >> /etc/nut/upsd.conf +RUN echo LISTEN 127.0.0.1 3493 >> /etc/nut/upsd.conf + +# Needed by upsd +RUN mkdir -p /var/run/nut + +COPY entrypoint.sh / + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/ungleich-ups/README.org b/ungleich-ups/README.org index 3cfa932..c48dc9e 100644 --- a/ungleich-ups/README.org +++ b/ungleich-ups/README.org @@ -11,6 +11,13 @@ - hon95/prometheus-nut-exporter:1 - port 9995 - last image 4 years ago +* 0.2.2, 2026-09-16 +* 0.2.1, 2026-09-16 + - Reduce regular logging output +* 0.2.0, 2026-09-16 + - Start upsd + - Fix run directory creation + - Fix driver running * 0.1.2, 2026-09-10 - Remove openrc, start nut directly (openrc does not exist by default anyway) diff --git a/ungleich-ups/daemonset.yaml b/ungleich-ups/daemonset.yaml index 66655ad..db69c2a 100644 --- a/ungleich-ups/daemonset.yaml +++ b/ungleich-ups/daemonset.yaml @@ -23,13 +23,13 @@ spec: operator: Exists effect: NoSchedule containers: - - name: ungleich-ups - image: harbor.k8s.ungleich.ch/ungleich-public/ungleich-ups:0.1.2 + - name: nut + image: harbor.k8s.ungleich.ch/ungleich-public/ungleich-ups:0.2.1 securityContext: privileged: true volumeMounts: - - name: usb-devices - mountPath: /dev/bus/usb + # - name: usb-devices + # mountPath: /dev/bus/usb - name: dev mountPath: /dev - name: nut-exporter @@ -38,9 +38,9 @@ spec: - name: http containerPort: 9199 volumes: - - name: usb-devices - hostPath: - path: /dev/bus/usb + # - name: usb-devices + # hostPath: + # path: /dev/bus/usb - name: dev hostPath: path: /dev diff --git a/ungleich-ups/entrypoint.sh b/ungleich-ups/entrypoint.sh index 91b8b12..c7ce063 100755 --- a/ungleich-ups/entrypoint.sh +++ b/ungleich-ups/entrypoint.sh @@ -4,12 +4,24 @@ # scan for ups & log to stdout nut-scanner -UUU 2>/dev/null | tee /etc/nut/ups.conf -/usr/sbin/upsdrvctl start +# Start drivers +/usr/sbin/upsdrvctl -u root start +# Start upsd +/usr/sbin/upsd + +# one time full detail +ups_list=$(upsc -l 2>/dev/null) +for ups in $ups_list; do + upsc $ups +done + +# Afterwards only minimal log while true; do ups_list=$(upsc -l 2>/dev/null) for ups in $ups_list; do - upsc $ups + echo ${ups}: + upsc $ups | grep -e ^ups.status -e ^input.voltage -e ^ups.load done sleep 60 done