openwrt: add script for creating ups entries

This commit is contained in:
Nico Schottelius 2024-08-17 17:46:45 +02:00
commit e0f6cfe931

View file

@ -0,0 +1,30 @@
#!/bin/sh
# Nico Schottelius, 2024-08-17
# create configuration for nut based on available usb ups
if [ $# -lt 8 ] ; then
echo $0 "address"
exit 1
fi
address=$1; shift
cat <<EOF | ssh -t "root@${address}"
set -x
opkg update
i=1
for ups in \$(lsusb -vv 2>/dev/null | grep -e "iProduct.* UPS" -A1 | awk '/iSerial/ { print \$3 }'); do
uci set nut_server.ups\${i}=driver
uci set nut_server.ups\${i}.port=auto
uci set nut_server.ups\${i}.driver=usbhid-ups
uci set nut_server.ups\${i}.serial=\$ups
i=\$((i+1))
done
uci commit