From 0b12bee66a89a3e53d91709aec0e5400e2387953 Mon Sep 17 00:00:00 2001 From: Christian Korber Date: Thu, 25 Jul 2024 11:28:51 +0200 Subject: [PATCH] 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 --- net/net-snmp/Makefile | 2 +- net/net-snmp/files/snmpd.init | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/net/net-snmp/Makefile b/net/net-snmp/Makefile index 68eb9abbd0..6d4a55ed36 100644 --- a/net/net-snmp/Makefile +++ b/net/net-snmp/Makefile @@ -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 diff --git a/net/net-snmp/files/snmpd.init b/net/net-snmp/files/snmpd.init index daecb73c9a..0fbf575aa8 100644 --- a/net/net-snmp/files/snmpd.init +++ b/net/net-snmp/files/snmpd.init @@ -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 -- 2.30.2