git: 67e1373470a6 - main - net-mgmt/icingadb: Add new port

From: Dan Langille <dvl_at_FreeBSD.org>
Date: Tue, 26 Sep 2023 15:25:33 UTC
The branch main has been updated by dvl:

URL: https://cgit.FreeBSD.org/ports/commit/?id=67e1373470a6751d7843cdbba88e13facb43acac

commit 67e1373470a6751d7843cdbba88e13facb43acac
Author:     Dan Langille <dvl@FreeBSD.org>
AuthorDate: 2023-09-26 15:19:52 +0000
Commit:     Dan Langille <dvl@FreeBSD.org>
CommitDate: 2023-09-26 15:22:01 +0000

    net-mgmt/icingadb: Add new port
    
    Publish, synchronize, and visualize Icinga data
    
    https://icinga.com/docs/icinga-db/latest/doc/02-Installation/
---
 net-mgmt/Makefile                                  |  1 +
 net-mgmt/icingadb/Makefile                         | 48 +++++++++++++++++++
 net-mgmt/icingadb/distinfo                         |  7 +++
 net-mgmt/icingadb/files/icingadb.in                | 55 ++++++++++++++++++++++
 net-mgmt/icingadb/files/patch-pkg_config_config.go | 11 +++++
 net-mgmt/icingadb/pkg-descr                        | 11 +++++
 net-mgmt/icingadb/pkg-plist                        |  8 ++++
 7 files changed, 141 insertions(+)

diff --git a/net-mgmt/Makefile b/net-mgmt/Makefile
index 0c7b72eec009..19f98aed89f7 100644
--- a/net-mgmt/Makefile
+++ b/net-mgmt/Makefile
@@ -87,6 +87,7 @@
     SUBDIR += icinga-php-library
     SUBDIR += icinga-php-thirdparty
     SUBDIR += icinga2
+    SUBDIR += icingadb
     SUBDIR += icingaweb2
     SUBDIR += icingaweb2-module-businessprocess
     SUBDIR += icingaweb2-module-cube
diff --git a/net-mgmt/icingadb/Makefile b/net-mgmt/icingadb/Makefile
new file mode 100644
index 000000000000..2bf4a417406a
--- /dev/null
+++ b/net-mgmt/icingadb/Makefile
@@ -0,0 +1,48 @@
+PORTNAME=	icingadb
+DISTVERSIONPREFIX=	v
+DISTVERSION=	1.1.1
+PORTREVISION=	5
+CATEGORIES=	net-mgmt
+
+MAINTAINER=	dvl@FreeBSD.org
+COMMENT=	Publish, synchronize, and visualize Icinga data
+WWW=		https://icinga.com/docs/icinga-db/latest/doc/02-Installation/
+
+LICENSE=	GPLv2
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+USES=		go:modules
+
+USE_RC_SUBR=	icingadb
+
+PLIST_SUB=	PORTNAME=${PORTNAME}
+
+# As copied from net-mgmt/icinga2
+ICINGA2USER?=	icinga
+ICINGA2GROUP?=	icinga
+USERS=		${ICINGA2USER}
+GROUPS=		${ICINGA2GROUP}
+
+SUB_LIST=	ICINGA2GROUP=${ICINGA2GROUP} \
+		ICINGA2USER=${ICINGA2USER}
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	Icinga
+GH_PROJECT=	icingadb
+
+GO_MODULE=	github.com/icinga/icingadb
+GO_TARGET=	./cmd/icingadb
+
+SUB_LIST+=	ICINGA2USER=${ICINGA2USER} \
+		PREFIX=${PREFIX}
+
+post-patch:
+	@${REINPLACE_CMD} -e 's|%%PREFIX|${PREFIX}|g' ${WRKSRC}/pkg/config/config.go
+
+post-install:
+	${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
+	${MKDIR} ${STAGEDIR}${ETCDIR}
+	(cd ${WRKSRC} && ${COPYTREE_SHARE} . ${STAGEDIR}${EXAMPLESDIR})
+	${INSTALL_DATA} ${WRKSRC}/config.example.yml ${STAGEDIR}${ETCDIR}/config.yml.sample
+
+.include <bsd.port.mk>
diff --git a/net-mgmt/icingadb/distinfo b/net-mgmt/icingadb/distinfo
new file mode 100644
index 000000000000..29e6472e8ee5
--- /dev/null
+++ b/net-mgmt/icingadb/distinfo
@@ -0,0 +1,7 @@
+TIMESTAMP = 1694197114
+SHA256 (go/net-mgmt_icingadb/Icinga-icingadb-v1.1.1_GH0/v1.1.1.mod) = a1c31eb3ce2da460c847b048f5020a1707273df2d46169f37511de4cee9b5685
+SIZE (go/net-mgmt_icingadb/Icinga-icingadb-v1.1.1_GH0/v1.1.1.mod) = 1508
+SHA256 (go/net-mgmt_icingadb/Icinga-icingadb-v1.1.1_GH0/v1.1.1.zip) = 7988ae8a59b5904a461b922bb50d35c9e1ebd5e659486d40425f01594fc2a21c
+SIZE (go/net-mgmt_icingadb/Icinga-icingadb-v1.1.1_GH0/v1.1.1.zip) = 3872935
+SHA256 (go/net-mgmt_icingadb/Icinga-icingadb-v1.1.1_GH0/Icinga-icingadb-v1.1.1_GH0.tar.gz) = 8f4246765dc364917170905e38b01c62a6c44eab7d333c131fc46691a47c150a
+SIZE (go/net-mgmt_icingadb/Icinga-icingadb-v1.1.1_GH0/Icinga-icingadb-v1.1.1_GH0.tar.gz) = 3868785
diff --git a/net-mgmt/icingadb/files/icingadb.in b/net-mgmt/icingadb/files/icingadb.in
new file mode 100644
index 000000000000..ab55bbfa3f37
--- /dev/null
+++ b/net-mgmt/icingadb/files/icingadb.in
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+# PROVIDE: icingadb
+# REQUIRE: SERVERS mysql postgresql
+# KEYWORD: shutdown
+#
+# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
+# to enable this service:
+#
+# icingadb_enable:	Set to NO by default.
+#			Set it to YES to enable icingadb
+# icingadb_user:	The user account used to run the daemon.
+#			Default: %%ICINGA2USER%%
+# icingadb_group:	The group account used to run the daemon.
+#			Default: %%ICINGA2GROUP%%
+#
+
+. /etc/rc.subr
+
+name=icingadb
+rcvar="${name}_enable"
+
+load_rc_config $name
+
+: ${icingadb_enable:="NO"}
+: ${icingadb_user:="%%ICINGA2USER%%"}
+: ${icingadb_group:="%%ICINGA2GROUP%%"}
+
+icingadb_pid="/var/run/icingadb/icingadb.pid"
+icingadb_logfile="/var/log/icinga2/$name.log"
+icingadb_daemonflags="-o ${icingadb_logfile}"
+
+pidfile="$icingadb_pid"
+command="/usr/sbin/daemon"
+
+start_precmd=icingadb_precmd
+
+icingadb_precmd()
+{
+	[ -f ${icingadb_logfile} ] || install -g $icingadb_group -o $icingadb_user -m 644 /dev/null ${icingadb_logfile}
+
+	if [ ! -d "/var/run/icingadb" ]; then
+		install -d -o ${icingadb_user} -g ${icingadb_group} -m 0775 "/var/run/icingadb"
+	fi
+	if [ ! -e ${pidfile} ]; then
+		install -o ${icingadb_user} -g ${icingadb_group} /dev/null ${pidfile};
+	else
+		chown ${icingadb_user}:${icingadb_group} ${pidfile};
+	fi
+
+}
+
+command_args="$icingadb_daemonflags -P $pidfile -t ${name} -T ${name} %%PREFIX%%/bin/$name -c %%PREFIX%%/etc/icingadb/config.yml"
+
+run_rc_command "$1"
diff --git a/net-mgmt/icingadb/files/patch-pkg_config_config.go b/net-mgmt/icingadb/files/patch-pkg_config_config.go
new file mode 100644
index 000000000000..1b5b0066118c
--- /dev/null
+++ b/net-mgmt/icingadb/files/patch-pkg_config_config.go
@@ -0,0 +1,11 @@
+--- pkg/config/config.go.orig	2023-09-08 17:19:58 UTC
++++ pkg/config/config.go
+@@ -46,7 +46,7 @@ type Flags struct {
+ 	// Version decides whether to just print the version and exit.
+ 	Version bool `long:"version" description:"print version and exit"`
+ 	// Config is the path to the config file
+-	Config string `short:"c" long:"config" description:"path to config file" required:"true" default:"/etc/icingadb/config.yml"`
++	Config string `short:"c" long:"config" description:"path to config file" required:"true" default:"%%PREFIX%%/etc/icinga2/icingadb.yml"`
+ }
+ 
+ // FromYAMLFile returns a new Config value created from the given YAML config file.
diff --git a/net-mgmt/icingadb/pkg-descr b/net-mgmt/icingadb/pkg-descr
new file mode 100644
index 000000000000..44543ed68c3c
--- /dev/null
+++ b/net-mgmt/icingadb/pkg-descr
@@ -0,0 +1,11 @@
+Icinga DB is a set of components for publishing, synchronizing and visualizing
+monitoring data in the Icinga ecosystem, consisting of:
+
+* Icinga DB Web which connects to both a Redis server and a database to view and
+  work with most up-to-date monitoring data
+* Icinga 2 with its Icinga DB feature enabled, responsible for publishing the
+  data to the Redis server, i.e. configuration and its runtime updates, check
+  results, state changes, downtimes, acknowledgements, notifications, and other
+  events such as flapping
+* And the Icinga DB daemon, which synchronizes the data between the Redis server
+  and the database
diff --git a/net-mgmt/icingadb/pkg-plist b/net-mgmt/icingadb/pkg-plist
new file mode 100644
index 000000000000..dd7f07a70e47
--- /dev/null
+++ b/net-mgmt/icingadb/pkg-plist
@@ -0,0 +1,8 @@
+bin/%%PORTNAME%%
+@sample(root,wheel,0640) etc/%%PORTNAME%%/config.yml.sample
+%%EXAMPLESDIR%%/schema/pgsql/upgrades/1.1.1.sql
+%%EXAMPLESDIR%%/schema/pgsql/schema.sql
+%%EXAMPLESDIR%%/schema/mysql/schema.sql
+%%EXAMPLESDIR%%/schema/mysql/upgrades/1.1.1.sql
+%%EXAMPLESDIR%%/schema/mysql/upgrades/1.0.0.sql
+%%EXAMPLESDIR%%/schema/mysql/upgrades/1.0.0-rc2.sql