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
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM alpine:3.12
FROM alpine:3.18

LABEL maintainer="docker@upshift.fr"
LABEL maintainer="bandawg93"

ENV NUT_VERSION 2.7.4
ENV NUT_VERSION 2.8.0

ENV UPS_NAME="ups"
ENV UPS_DESC="UPS"
Expand All @@ -24,10 +24,11 @@ RUN set -ex; \
apk add --no-cache --virtual .build-deps \
libusb-compat-dev \
build-base \
curl \
; \
# download and extract
cd /tmp; \
wget http://www.networkupstools.org/source/2.7/nut-$NUT_VERSION.tar.gz; \
wget http://www.networkupstools.org/source/2.8/nut-$NUT_VERSION.tar.gz; \
tar xfz nut-$NUT_VERSION.tar.gz; \
cd nut-$NUT_VERSION \
; \
Expand Down
14 changes: 13 additions & 1 deletion src/docker-entrypoint
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh -ex
#!/bin/sh

if [ -z "$API_PASSWORD" ]
then
Expand All @@ -10,17 +10,25 @@ then
ADMIN_PASSWORD=$(dd if=/dev/urandom bs=18 count=1 2>/dev/null | base64)
fi

if [ ! -f /etc/nut/ups.conf ]
then
cat >/etc/nut/ups.conf <<EOF
[$UPS_NAME]
desc = "$UPS_DESC"
driver = $UPS_DRIVER
port = $UPS_PORT
EOF
fi

if [ ! -f /etc/nut/upsd.conf ]
then
cat >/etc/nut/upsd.conf <<EOF
LISTEN 0.0.0.0 3493
EOF
fi

if [ ! -f /etc/nut/upsd.users ]
then
cat >/etc/nut/upsd.users <<EOF
[admin]
password = $ADMIN_PASSWORD
Expand All @@ -32,11 +40,15 @@ cat >/etc/nut/upsd.users <<EOF
password = $API_PASSWORD
upsmon master
EOF
fi

if [ ! -f /etc/nut/upsmon.conf ]
then
cat >/etc/nut/upsmon.conf <<EOF
MONITOR $UPS_NAME@localhost 1 monitor $API_PASSWORD master
SHUTDOWNCMD "$SHUTDOWN_CMD"
EOF
fi

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