aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorDaniel F. Dickinson <cshored@thecshore.com>2018-12-05 01:36:45 -0500
committerDaniel F. Dickinson <cshored@thecshore.com>2018-12-06 03:31:47 -0500
commita5d06ce1106644b26a1b9d0ad87220d772d6b862 (patch)
treed9f3b41aa70a2dd2a0ad4f7fa5fa8fed1df52db5 /net
parent18a10cec4804f862409656b7f674b4d50ec149e1 (diff)
nut: Optionally set serial USB to NUT user
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>
Diffstat (limited to 'net')
-rw-r--r--net/nut/Makefile4
-rw-r--r--net/nut/files/nut_serial.hotplug21
2 files changed, 24 insertions, 1 deletions
diff --git a/net/nut/Makefile b/net/nut/Makefile
index 0074aa060..7405ad20b 100644
--- a/net/nut/Makefile
+++ b/net/nut/Makefile
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=nut
PKG_VERSION:=2.7.4
-PKG_RELEASE:=11
+PKG_RELEASE:=12
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.networkupstools.org/source/2.7/
@@ -81,6 +81,8 @@ define Package/nut-server/install
ln -sf /var/etc/nut/ups.conf $(1)/etc/nut/ups.conf
# Mangle libhid.usermap into a format (hotplug shell script) useful for OpenWrt
$(INSTALL_DIR) $(1)/etc/hotplug.d/usb
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/tty
+ $(INSTALL_BIN) ./files/nut_serial.hotplug $(1)/etc/hotplug.d/tty/40-nut_serial
$(INSTALL_BIN) ./files/30-libhid-ups.head $(1)/etc/hotplug.d/usb/30-libhid-ups
$(CP) $(PKG_INSTALL_DIR)/etc/hotplug/usb/libhid.usermap $(PKG_BUILD_DIR)/30-libhid-ups.middle
$(SED) '/^$$$$/d' \
diff --git a/net/nut/files/nut_serial.hotplug b/net/nut/files/nut_serial.hotplug
new file mode 100644
index 000000000..f320d09a6
--- /dev/null
+++ b/net/nut/files/nut_serial.hotplug
@@ -0,0 +1,21 @@
+#!/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
+ }
+}