blob: fa3bafeb8aa0388ff92f5de747ec0959e3cf2b63 (
plain)
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
|
#!/bin/sh
nut_serial() {
local cfg="$cfg"
local runas enable_usb_serial port
config_get_bool enable_usb_serial "$cfg" enable_usb_serial 0
config_get port "$cfg" port
config_get runas "$cfg" runas "nut"
[ -z "$runas" ] && config_get runas upsd runas "nut"
[ "$enable_usb_serial" -eq 1 ] && {
# If port is specified only change tty's matching port
if [ -n "$port" ] && [ "$port" != /dev/"$DEVNAME" ]; then
return 0
fi
[ -n "$runas" ] && chgrp "$(id -gn "${runas}")" /dev/"$DEVNAME"
chmod g+rw /dev/"$DEVNAME"
}
}
nut_on_hotplug_add() {
. "${IPKG_INSTROOT}"/lib/functions.sh
config load nut_server
config_foreach nut_serial driver
}
[ "$ACTION" = "add" ] && [ -n "$DEVNAME" ] && {
# On add of a serial port with name ttyUSB*
[ -z "${DEVNAME%ttyUSB*}" ] && nut_on_hutplug_add
# On add of a serial port with name ttyAMA*
[ -z "${DEVNAME%ttyAMA*}" ] && nut_on_hutplug_add
}
|