From 15a7077a06327e8a92f41a9aab35b0ef929fc777 Mon Sep 17 00:00:00 2001 From: David Johnson Date: Mon, 1 May 2023 16:36:46 -0400 Subject: [PATCH] package/netsnmp: add systemd service file Signed-off-by: David Johnson Signed-off-by: Thomas Petazzoni --- package/netsnmp/netsnmp.mk | 10 ++++++++++ package/netsnmp/snmpd.service | 15 +++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 package/netsnmp/snmpd.service diff --git a/package/netsnmp/netsnmp.mk b/package/netsnmp/netsnmp.mk index 15bc318e36..0218e65b91 100644 --- a/package/netsnmp/netsnmp.mk +++ b/package/netsnmp/netsnmp.mk @@ -41,6 +41,12 @@ NETSNMP_INSTALL_TARGET_OPTS = DESTDIR=$(TARGET_DIR) LIB_LDCONFIG_CMD=true instal NETSNMP_MAKE = $(MAKE1) NETSNMP_CONFIG_SCRIPTS = net-snmp-config +ifeq ($(BR2_INIT_SYSTEMD),y) +NETSNMP_CONF_OPTS += --with-systemd +else +NETSNMP_CONF_OPTS += --without-systemd +endif + ifeq ($(BR2_ENDIAN),"BIG") NETSNMP_CONF_OPTS += --with-endianness=big else @@ -104,6 +110,10 @@ define NETSNMP_INSTALL_INIT_SYSV $(INSTALL) -D -m 0755 package/netsnmp/S59snmpd \ $(TARGET_DIR)/etc/init.d/S59snmpd endef +define NETSNMP_INSTALL_INIT_SYSTEMD + $(INSTALL) -D -m 0644 package/netsnmp/snmpd.service \ + $(TARGET_DIR)/usr/lib/systemd/system/snmpd.service +endef endif $(eval $(autotools-package)) diff --git a/package/netsnmp/snmpd.service b/package/netsnmp/snmpd.service new file mode 100644 index 0000000000..2a1e6e9715 --- /dev/null +++ b/package/netsnmp/snmpd.service @@ -0,0 +1,15 @@ +[Unit] +Description=SNMP Daemon +After=network.target +ConditionPathExists=/etc/snmp/snmpd.conf + +[Service] +Type=simple +Environment=MIBDIRS=/usr/share/snmp/mibs +Environment=SNMPDOPTS='-Lsd -Lf /dev/null -p /var/run/snmpd.pid 127.0.0.1' +EnvironmentFile=-/etc/default/snmpd +PassEnvironment=MIBDIRS +ExecStart=/usr/sbin/snmpd -f $SNMPDOPTS + +[Install] +WantedBy=multi-user.target