-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathentrypoint.sh
More file actions
42 lines (34 loc) · 951 Bytes
/
entrypoint.sh
File metadata and controls
42 lines (34 loc) · 951 Bytes
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
#!/bin/bash
set -e
echo "Starting NUT Server..."
echo "UPS Name: $NAME"
echo "Driver: $DRIVER"
echo "Port: $PORT"
echo "Poll Frequency: $POLLFREQ seconds"
# Set timezone
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Configure UPS
echo "Configuring UPS..."
cat > /etc/nut/ups.conf << EOF
[$NAME]
driver = $DRIVER
port = $PORT
pollfreq = $POLLFREQ
desc = $DESC
EOF
# Configure users if provided
if [ "$USERSSTRING" != "#" ]; then
echo "Configuring NUT users..."
echo -e "$USERSSTRING" > /etc/nut/upsd.users
fi
# Set permissions for USB devices if they exist
if [ -d /dev/bus/usb ]; then
echo "Setting USB device permissions..."
chgrp nut /dev/bus/usb/*/* 2>/dev/null || echo "No USB devices found or permission already set"
fi
# Set correct permissions
chgrp nut /etc/nut/* 2>/dev/null || true
echo "Starting UPS driver..."
upsdrvctl start
echo "Starting UPS daemon..."
exec upsd -D