Skip to content

Check if configuration files already exist. #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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="[email protected]"
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