Skip to content
Open
Show file tree
Hide file tree
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
29 changes: 16 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
FROM alpine:3.12

LABEL maintainer="docker@upshift.fr"

ENV NUT_VERSION 2.7.4
FROM alpine:3.19.0

ENV UPS_NAME="ups"
ENV UPS_DESC="UPS"
Expand All @@ -18,19 +14,26 @@ RUN set -ex; \
# run dependencies
apk add --no-cache \
openssh-client \
libusb-compat \
libusb-dev \
git \
python3 \
perl \
autoconf \
libtool \
automake \
libltdl \
; \
# build dependencies
apk add --no-cache --virtual .build-deps \
libusb-compat-dev \
libusb-dev \
build-base \
; \
# download and extract
cd /tmp; \
wget http://www.networkupstools.org/source/2.7/nut-$NUT_VERSION.tar.gz; \
tar xfz nut-$NUT_VERSION.tar.gz; \
cd nut-$NUT_VERSION \
; \
git clone https://github.com/networkupstools/nut.git; \
cd nut; \
./autogen.sh; \
#; \
# build
./configure \
--prefix=/usr \
Expand All @@ -44,7 +47,7 @@ RUN set -ex; \
--with-drvpath=/usr/share/nut \
--with-statepath=/var/run/nut \
--with-user=nut \
--with-group=nut \
--with-group=nut\
; \
# install
make install \
Expand All @@ -56,7 +59,7 @@ RUN set -ex; \
install -d -m 750 -o nut -g nut /var/run/nut \
; \
# cleanup
rm -rf /tmp/nut-$NUT_VERSION.tar.gz /tmp/nut-$NUT_VERSION; \
rm -rf /tmp/nut; \
apk del .build-deps

COPY src/docker-entrypoint /usr/local/bin/
Expand Down
12 changes: 10 additions & 2 deletions src/docker-entrypoint
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh -ex
#!/bin/sh -x

if [ -z "$API_PASSWORD" ]
then
Expand All @@ -15,10 +15,15 @@ cat >/etc/nut/ups.conf <<EOF
desc = "$UPS_DESC"
driver = $UPS_DRIVER
port = $UPS_PORT
usb_hid_rep_index = 1
usb_hid_desc_index = 1
debug_min = 4
pollonly = "enabled"
EOF

cat >/etc/nut/upsd.conf <<EOF
LISTEN 0.0.0.0 3493
MAXAGE 60
EOF

cat >/etc/nut/upsd.users <<EOF
Expand All @@ -36,11 +41,14 @@ EOF
cat >/etc/nut/upsmon.conf <<EOF
MONITOR $UPS_NAME@localhost 1 monitor $API_PASSWORD master
SHUTDOWNCMD "$SHUTDOWN_CMD"
DEADTIME 60
EOF

chgrp -R nut /etc/nut /dev/bus/usb
chmod -R o-rwx /etc/nut

/usr/sbin/upsdrvctl start
/usr/sbin/upsd
exec /usr/sbin/upsmon -D
# exec /usr/sbin/upsmon -DDDDD
watch upsc ups@localhost
# /bin/sh