Files
nut-ups/bluewalker-vfi-icr/install-master.sh
T

53 lines
1.7 KiB
Bash

#!/usr/bin/env bash
# install-master.sh -- deploy NUT master config for PowerWalker VFI ICR IoT
# Run as root on the USB-connected host. ASCII only.
set -euo pipefail
SRC="$(cd "$(dirname "$0")" && pwd)/master/etc/nut"
DST="/etc/nut"
if [ "$(id -u)" -ne 0 ]; then
echo "ERROR: run as root (sudo)." >&2
exit 1
fi
echo "== Installing NUT (if missing) =="
if command -v apt-get >/dev/null 2>&1; then
apt-get update && apt-get install -y nut
elif command -v dnf >/dev/null 2>&1; then
dnf install -y nut
else
echo "WARN: unknown package manager, install 'nut' manually." >&2
fi
echo "== Copying config files to ${DST} =="
install -d "$DST"
cp -v "$SRC/ups.conf" "$DST/ups.conf"
cp -v "$SRC/nut.conf" "$DST/nut.conf"
cp -v "$SRC/upsd.conf" "$DST/upsd.conf"
cp -v "$SRC/upsmon.conf" "$DST/upsmon.conf"
if [ ! -f "$DST/upsd.users" ]; then
cp -v "$SRC/upsd.users.example" "$DST/upsd.users"
echo "NOTE: created upsd.users from example -- edit the passwords now."
else
echo "NOTE: upsd.users already exists, left untouched."
fi
echo "== Setting ownership and permissions =="
chown root:nut "$DST"/*.conf "$DST/upsd.users" 2>/dev/null || true
chmod 640 "$DST/upsd.users" "$DST/upsmon.conf"
echo
echo "NEXT STEPS (manual):"
echo " 1. Edit ${DST}/upsd.users and ${DST}/upsmon.conf -- replace CHANGE_ME_* passwords."
echo " 2. Plug in the UPS via USB and test the driver:"
echo " nutdrv_qx -a test -DD -x port=auto"
echo " (add -x protocol=voltronic -x novendor if values are missing)"
echo " 3. Enable services:"
echo " systemctl enable --now nut-server nut-monitor"
echo " 4. Verify:"
echo " upsc ups@localhost"
echo " 5. Open 3493/tcp in the firewall for your client subnets."