pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
snmp_exporter: install default config, add rc.d, add user/group
Module Name: pkgsrc-wip
Committed By: Thomas Klausner <wiz%gatalith.at@localhost>
Pushed By: wiz
Date: Thu Dec 21 20:55:51 2023 +0100
Changeset: 022c9fec986377c955a54619152fe90eb1964e63
Modified Files:
snmp_exporter/Makefile
snmp_exporter/PLIST
Added Files:
snmp_exporter/files/snmp_exporter.sh
Log Message:
snmp_exporter: install default config, add rc.d, add user/group
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=022c9fec986377c955a54619152fe90eb1964e63
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
snmp_exporter/Makefile | 20 +++++++++++++
snmp_exporter/PLIST | 1 +
snmp_exporter/files/snmp_exporter.sh | 54 ++++++++++++++++++++++++++++++++++++
3 files changed, 75 insertions(+)
diffs:
diff --git a/snmp_exporter/Makefile b/snmp_exporter/Makefile
index 2446093fe8..34a77cae29 100644
--- a/snmp_exporter/Makefile
+++ b/snmp_exporter/Makefile
@@ -17,10 +17,30 @@ SUBST_FILES.path+= generator/net_snmp.go
SUBST_MESSAGE.path= Fixing path to includes and libraries.
SUBST_STAGE.path= pre-configure
+LOGDIR= ${VARBASE}/log/snmp_exporter
+SNMP_EXPORTER_USER?= snmp_exporter
+SNMP_EXPORTER_GROUP?= snmp_exporter
+OWN_DIRS_PERMS+= ${LOGDIR} ${SNMP_EXPORTER_USER} ${SNMP_EXPORTER_GROUP} 0700
+PKG_USERS_VARS+= SNMP_EXPORTER_USER
+PKG_GROUPS_VARS+= SNMP_EXPORTER_GROUP
+PKG_GROUPS= ${SNMP_EXPORTER_GROUP}
+PKG_USERS= ${SNMP_EXPORTER_USER}:${SNMP_EXPORTER_GROUP}
+RCD_SCRIPTS= snmp_exporter
+
+FILES_SUBST+= SNMP_EXPORTER_USER=${SNMP_EXPORTER_USER:Q}
+FILES_SUBST+= SNMP_EXPORTER_GROUP=${SNMP_EXPORTER_GROUP:Q}
+FILES_SUBST+= LOGDIR=${LOGDIR:Q}
+
+BUILD_DEFS+= VARBASE
+
INSTALLATION_DIRS+= share/doc/snmp_exporter
+INSTALLATION_DIRS+= share/examples/snmp_exporter
+
+CONF_FILES+= share/examples/snmp_exporter/snmp.yml ${PKG_SYSCONFDIR}/snmp.yml
post-install:
${INSTALL_DATA} ${WRKSRC}/README.md ${DESTDIR}${PREFIX}/share/doc/snmp_exporter
+ ${INSTALL_DATA} ${WRKSRC}/snmp.yml ${DESTDIR}${PREFIX}/share/examples/snmp_exporter
.include "go-modules.mk"
.include "../../lang/go/go-module.mk"
diff --git a/snmp_exporter/PLIST b/snmp_exporter/PLIST
index 8d29186a71..02a9edaa24 100644
--- a/snmp_exporter/PLIST
+++ b/snmp_exporter/PLIST
@@ -2,3 +2,4 @@
bin/generator
bin/snmp_exporter
share/doc/snmp_exporter/README.md
+share/examples/snmp_exporter/snmp.yml
diff --git a/snmp_exporter/files/snmp_exporter.sh b/snmp_exporter/files/snmp_exporter.sh
new file mode 100644
index 0000000000..0c6e739e4a
--- /dev/null
+++ b/snmp_exporter/files/snmp_exporter.sh
@@ -0,0 +1,54 @@
+#!@RCD_SCRIPTS_SHELL@
+#
+# $NetBSD: snmp_exporter.sh,v 1.1 2023/12/16 22:25:07 wiz Exp $
+#
+# PROVIDE: snmp_exporter
+# REQUIRE: DAEMON
+# KEYWORD: shutdown
+#
+# Consider installing pkgtools/rc.subr in unprivileged.
+#
+# You will need to set some variables in @SYSCONFBASE@/rc.conf to start snmp_exporter:
+#
+# snmp_exporter=YES
+
+if [ -f @SYSCONFBASE@/rc.subr ]; then
+ $_rc_subr_loaded . @SYSCONFBASE@/rc.subr
+fi
+
+name="snmp_exporter"
+rcvar=$name
+snmp_exporter_user="@SNMP_EXPORTER_USER@"
+snmp_exporter_group="@SNMP_EXPORTER_GROUP@"
+command="@PREFIX@/bin/snmp_exporter"
+command_args="--config.file @PKG_SYSCONFDIR@/snmp.yml > @LOGDIR@/snmp_exporter.log 2>&1 &"
+
+
+if [ -f @SYSCONFBASE@/rc.subr -a -d @SYSCONFBASE@/rc.d -a -f @SYSCONFBASE@/rc.d/DAEMON ]; then
+ load_rc_config $name
+ run_rc_command "$1"
+else
+ if [ -f @SYSCONFBASE@/rc.conf ]; then
+ . @SYSCONFBASE@/rc.conf
+ fi
+ case "$1" in
+ start)
+ if [ -r "${pidfile}" ]; then
+ @ECHO@ "Already running ${name}."
+ else
+ @ECHO@ "Starting ${name}."
+ eval ${command} ${command_args}
+ fi
+ ;;
+ stop)
+ if [ -r "${pidfile}" ]; then
+ @ECHO@ "Stopping ${name}."
+ kill `@CAT@ "${pidfile}"` && @RM@ "${pidfile}"
+ fi
+ ;;
+ *)
+ @ECHO@ "Usage: $0 {start|stop}" 1>&2
+ exit 10
+ ;;
+ esac
+fi
Home |
Main Index |
Thread Index |
Old Index