-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint
More file actions
executable file
·51 lines (41 loc) · 1 KB
/
docker-entrypoint
File metadata and controls
executable file
·51 lines (41 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash -ex
if [ -z "$API_PASSWORD" ]
then
API_PASSWORD=$(dd if=/dev/urandom bs=18 count=1 2>/dev/null | base64)
echo "API_PASSWORD:" $API_PASSWORD
fi
if [ -z "$ADMIN_PASSWORD" ]
then
ADMIN_PASSWORD=$(dd if=/dev/urandom bs=18 count=1 2>/dev/null | base64)
echo "ADMIN_PASSWORD:" $ADMIN_PASSWORD
fi
nut-scanner > /etc/nut/ups.conf
cat > /etc/nut/upsd.conf <<EOF
LISTEN 0.0.0.0 3493
EOF
cat > /etc/nut/upsd.users <<EOF
[admin]
password = $ADMIN_PASSWORD
actions = set
actions = fsd
instcmds = all
[monitor]
password = $API_PASSWORD
upsmon master
EOF
# upsmon settings shared across all UPSes
cat > /etc/nut/upsmon.conf <<EOF
SHUTDOWNCMD "$SHUTDOWN_CMD"
EOF
# upsmon settings per-UPS
for upsnum in $(seq $UPS_COUNT)
do
cat >> /etc/nut/upsmon.conf <<EOF
MONITOR nutdev-usb$upsnum@localhost 1 monitor $API_PASSWORD primary
EOF
done
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