From f477cbe86134f1dd5456c012c2fd9c3770e1a12b Mon Sep 17 00:00:00 2001 From: "S.F" Date: Sun, 1 Nov 2020 16:39:25 -0500 Subject: [PATCH] OpenBSD packaging files (#853) --- ports/OpenBSD/README.md | 11 ++++++ ports/OpenBSD/VictoriaMetrics/Makefile | 38 +++++++++++++++++++ ports/OpenBSD/VictoriaMetrics/distinfo | 2 + ports/OpenBSD/VictoriaMetrics/pkg/DESCR | 3 ++ ports/OpenBSD/VictoriaMetrics/pkg/PLIST | 34 +++++++++++++++++ ports/OpenBSD/VictoriaMetrics/pkg/vmetrics.rc | 19 ++++++++++ ports/OpenBSD/VictoriaMetrics/pkg/vmlogger.pl | 18 +++++++++ 7 files changed, 125 insertions(+) create mode 100644 ports/OpenBSD/README.md create mode 100644 ports/OpenBSD/VictoriaMetrics/Makefile create mode 100644 ports/OpenBSD/VictoriaMetrics/distinfo create mode 100644 ports/OpenBSD/VictoriaMetrics/pkg/DESCR create mode 100644 ports/OpenBSD/VictoriaMetrics/pkg/PLIST create mode 100644 ports/OpenBSD/VictoriaMetrics/pkg/vmetrics.rc create mode 100644 ports/OpenBSD/VictoriaMetrics/pkg/vmlogger.pl diff --git a/ports/OpenBSD/README.md b/ports/OpenBSD/README.md new file mode 100644 index 000000000..9c98b3f9c --- /dev/null +++ b/ports/OpenBSD/README.md @@ -0,0 +1,11 @@ +# OpenBSD ports + +Tested with Release 6.7 + +The VictoriaMetrics DB must be place in `/usr/ports/sysutils` directory +and the file `/usr/ports/infrastructure/db/user.list` +should be modified with a new line +``` +855 _vmetrics _vmetrics sysutils/VictoriaMetrics +``` + diff --git a/ports/OpenBSD/VictoriaMetrics/Makefile b/ports/OpenBSD/VictoriaMetrics/Makefile new file mode 100644 index 000000000..57e4103d4 --- /dev/null +++ b/ports/OpenBSD/VictoriaMetrics/Makefile @@ -0,0 +1,38 @@ +# $OpenBSD$ + +COMMENT = fast, cost-effective and scalable time series database + +GH_ACCOUNT = VictoriaMetrics +GH_PROJECT = VictoriaMetrics +GH_TAGNAME = v1.44.0 + +CATEGORIES = sysutils + +HOMEPAGE = https://victoriametrics.com/ + +MAINTAINER = VictoriaMetrics + +# Apache License 2.0 +PERMIT_PACKAGE = Yes + +WANTLIB = c pthread + +USE_GMAKE = Yes + +MODULES= lang/go +MODGO_GOPATH= ${MODGO_WORKSPACE} + +do-build: + cd ${WRKSRC} && GOOS=openbsd ${MAKE_ENV} ${MAKE_PROGRAM} victoria-metrics-pure + cd ${WRKSRC} && GOOS=openbsd ${MAKE_ENV} ${MAKE_PROGRAM} vmbackup + +do-install: + ${INSTALL_PROGRAM} ./pkg/vmlogger.pl ${PREFIX}/bin/vmetricslogger.pl + ${INSTALL_PROGRAM} ${WRKSRC}/bin/victoria-metrics-pure ${PREFIX}/bin/vmetrics + ${INSTALL_PROGRAM} ${WRKSRC}/bin/vmbackup ${PREFIX}/bin/vmetricsbackup + ${INSTALL_DATA_DIR} ${PREFIX}/share/doc/vmetrics/ + ${INSTALL_DATA} ${WRKSRC}/README.md ${PREFIX}/share/doc/vmetrics/ + ${INSTALL_DATA} ${WRKSRC}/LICENSE ${PREFIX}/share/doc/vmetrics/ + ${INSTALL_DATA} ${WRKSRC}/docs/* ${PREFIX}/share/doc/vmetrics/ + +.include diff --git a/ports/OpenBSD/VictoriaMetrics/distinfo b/ports/OpenBSD/VictoriaMetrics/distinfo new file mode 100644 index 000000000..b1910b2a0 --- /dev/null +++ b/ports/OpenBSD/VictoriaMetrics/distinfo @@ -0,0 +1,2 @@ +SHA256 (VictoriaMetrics-1.44.0.tar.gz) = OIXIyqiijWvAPDgq5wMoDpv1rENcIOWIcXmz4T5v1lU= +SIZE (VictoriaMetrics-1.44.0.tar.gz) = 8898365 diff --git a/ports/OpenBSD/VictoriaMetrics/pkg/DESCR b/ports/OpenBSD/VictoriaMetrics/pkg/DESCR new file mode 100644 index 000000000..653a93e4f --- /dev/null +++ b/ports/OpenBSD/VictoriaMetrics/pkg/DESCR @@ -0,0 +1,3 @@ +VictoriaMetrics is fast, +cost-effective and scalable time-series database. + diff --git a/ports/OpenBSD/VictoriaMetrics/pkg/PLIST b/ports/OpenBSD/VictoriaMetrics/pkg/PLIST new file mode 100644 index 000000000..1f5ea2639 --- /dev/null +++ b/ports/OpenBSD/VictoriaMetrics/pkg/PLIST @@ -0,0 +1,34 @@ +@comment $OpenBSD$ +@newgroup _vmetrics:855 +@newuser _vmetrics:855:_vmetrics:daemon:VictoriaMetrics:${VARBASE}/db/vmetrics:/sbin/nologin +@sample ${SYSCONFDIR}/prometheus/ +@rcscript ${RCDIR}/vmetrics +@bin bin/vmetricslogger.pl +@bin bin/vmetrics +@bin bin/vmetricsbackup +share/doc/vmetrics/ +share/doc/vmetrics/Articles.md +share/doc/vmetrics/CaseStudies.md +share/doc/vmetrics/Cluster-VictoriaMetrics.md +share/doc/vmetrics/ExtendedPromQL.md +share/doc/vmetrics/FAQ.md +share/doc/vmetrics/Home.md +share/doc/vmetrics/LICENSE +share/doc/vmetrics/MetricsQL.md +share/doc/vmetrics/Quick-Start.md +share/doc/vmetrics/README.md +share/doc/vmetrics/Release-Guide.md +share/doc/vmetrics/SampleSizeCalculations.md +share/doc/vmetrics/Single-server-VictoriaMetrics.md +share/doc/vmetrics/logo.png +share/doc/vmetrics/robots.txt +share/doc/vmetrics/vmagent.md +share/doc/vmetrics/vmagent.png +share/doc/vmetrics/vmalert.md +share/doc/vmetrics/vmauth.md +share/doc/vmetrics/vmbackup.md +share/doc/vmetrics/vmrestore.md +@mode 0755 +@owner _vmetrics +@group _vmetrics +@sample ${VARBASE}/db/vmetrics diff --git a/ports/OpenBSD/VictoriaMetrics/pkg/vmetrics.rc b/ports/OpenBSD/VictoriaMetrics/pkg/vmetrics.rc new file mode 100644 index 000000000..d9cdfe6ee --- /dev/null +++ b/ports/OpenBSD/VictoriaMetrics/pkg/vmetrics.rc @@ -0,0 +1,19 @@ +#!/bin/sh +# +# $OpenBSD$ + +daemon="${TRUEPREFIX}/bin/vmetrics" +daemon_flags="-storageDataPath=/var/db/vmetrics/ ${daemon_flags}" +daemon_user=_vmetrics + +. /etc/rc.d/rc.subr + +pexp="${daemon}.*" +rc_bg=YES +rc_reload=NO + +rc_start() { + ${rcexec} "${daemon} -loggerDisableTimestamps ${daemon_flags} < /dev/null 2>&1 | ${TRUEPREFIX}/bin/vmetricslogger.pl" +} + +rc_cmd $1 diff --git a/ports/OpenBSD/VictoriaMetrics/pkg/vmlogger.pl b/ports/OpenBSD/VictoriaMetrics/pkg/vmlogger.pl new file mode 100644 index 000000000..02b6b8746 --- /dev/null +++ b/ports/OpenBSD/VictoriaMetrics/pkg/vmlogger.pl @@ -0,0 +1,18 @@ +#!/usr/bin/perl +use Sys::Syslog qw(:standard :macros); + +openlog("victoria-metrics", "pid", "daemon"); + +while (my $l = <>) { + my @d = split /\t/, $l; + # go level : "INFO", "WARN", "ERROR", "FATAL", "PANIC": + my $lvl = $d[0]; + $lvl = LOG_EMERG if ($lvl eq 'panic'); + $lvl = 'crit' if ($lvl eq 'fatal'); + $lvl = 'err' if ($lvl eq 'error'); + $lvl = 'warning' if ($lvl eq 'warn'); + chomp $d[2]; + syslog( $lvl, $d[2] ); +} + +closelog();