28 lines
577 B
Bash
Executable file
28 lines
577 B
Bash
Executable file
#!/bin/sh
|
|
# Nico Schottelius, 2024-08-17
|
|
# create configuration for nut based on available usb ups
|
|
|
|
|
|
if [ $# -lt 1 ] ; then
|
|
echo $0 "address"
|
|
exit 1
|
|
fi
|
|
|
|
address=$1; shift
|
|
|
|
cat <<EOF | ssh -t "root@${address}"
|
|
set -x
|
|
i=1
|
|
|
|
for ups in \$(lsusb -vv 2>/dev/null | grep -e "iProduct.* UPS" -e "iProduct.*Innova Unity" -e "iProduct.*LIHVX2K0" -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
|