Browse Source

Merge pull request #7592 from cshoredaniel/pr-nut-serial-usb

nut: Optionally set serial USB to NUT user
lilik-openwrt-22.03
Hannu Nyman 6 years ago
committed by GitHub
parent
commit
7488013df7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions
  1. +3
    -1
      net/nut/Makefile
  2. +21
    -0
      net/nut/files/nut_serial.hotplug

+ 3
- 1
net/nut/Makefile View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=nut PKG_NAME:=nut
PKG_VERSION:=2.7.4 PKG_VERSION:=2.7.4
PKG_RELEASE:=11
PKG_RELEASE:=12
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.networkupstools.org/source/2.7/ 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 ln -sf /var/etc/nut/ups.conf $(1)/etc/nut/ups.conf
# Mangle libhid.usermap into a format (hotplug shell script) useful for OpenWrt # 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/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 $(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 $(CP) $(PKG_INSTALL_DIR)/etc/hotplug/usb/libhid.usermap $(PKG_BUILD_DIR)/30-libhid-ups.middle
$(SED) '/^$$$$/d' \ $(SED) '/^$$$$/d' \


+ 21
- 0
net/nut/files/nut_serial.hotplug View File

@ -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
}
}

Loading…
Cancel
Save