net-snmp: set hostname as sysname

This commit writes the option hostname obtained via uci_get
system.@system[0].hostname to the snmpd.conf file if sysName
is not defined in /etc/config/snmpd.

Signed-off-by: Christian Korber <ckorber@tdt.de>
pull/24651/head
Christian Korber 2024-07-25 11:28:51 +02:00
parent 8d68f0b0db
commit 0b12bee66a
2 changed files with 4 additions and 1 deletions

View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=net-snmp
PKG_VERSION:=5.9.4
PKG_RELEASE:=2
PKG_RELEASE:=3
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@SF/net-snmp

View File

@ -24,12 +24,15 @@ snmpd_agentx_add() {
snmpd_system_add() {
local cfg="$1"
local hostname
config_get syslocation "$cfg" sysLocation
[ -n "$syslocation" ] && echo "sysLocation $syslocation" >> $CONFIGFILE
config_get syscontact "$cfg" sysContact
[ -n "$syscontact" ] && echo "sysContact $syscontact" >> $CONFIGFILE
config_get sysname "$cfg" sysName
[ -n "$sysname" ] && echo "sysName $sysname" >> $CONFIGFILE
[ -z "$sysname" ] && hostname=$(uci_get system.@system[0].hostname) && echo "sysName $hostname" >> $CONFIGFILE
config_get sysservice "$cfg" sysService
[ -n "$sysservice" ] && echo "sysService $sysservice" >> $CONFIGFILE
config_get sysdescr "$cfg" sysDescr