When using serial-port based UPSes with NUT, it is handy to be able to configure a USB serial port to have be set tot the NUT runas user, so that NUT can access the serial port automagically. Closes #6997 Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
21 lines
434 B
Bash
21 lines
434 B
Bash
#!/bin/sh
|
|
|
|
nut_serial() {
|
|
local cfg="$cfg"
|
|
config_get runas upsd runas "nut"
|
|
config_get_bool enable_usb_serial "$cfg" enable_usb_serial 0
|
|
}
|
|
|
|
[ "$ACTION" = "add" ] && [ -n "$DEVNAME" ] && [ -z "${DEVNAME%ttyUSB*}" ] && {
|
|
config load nut_server
|
|
config_foreach nut_serial driver
|
|
|
|
[ -z "$RUNAS" ] && {
|
|
RUNAS="$runas"
|
|
}
|
|
|
|
[ "$enable_usb_serial" -eq 1 ] && {
|
|
chown "${RUNAS:-nut}" /dev/$DEVNAME
|
|
chmod g+rw /dev/$DEVNAME
|
|
}
|
|
}
|