Subject: [alpine-aports] [PATCH] testing/metalog: new aport

From: Milan P. Stanić <[email-masked]>
Date: Fri, 22 Feb 2019 16:13:34 +0100

---
 testing/metalog/APKBUILD      | 53 +++++++++++++++++++++++++++++++++++
 testing/metalog/metalog.confd | 10 +++++++
 testing/metalog/metalog.initd | 40 ++++++++++++++++++++++++++
 3 files changed, 103 insertions(+)
 create mode 100644 testing/metalog/APKBUILD
 create mode 100644 testing/metalog/metalog.confd
 create mode 100644 testing/metalog/metalog.initd

diff --git a/testing/metalog/APKBUILD b/testing/metalog/APKBUILD
new file mode 100644
index 0000000000..306bd665d8
--- /dev/null
+++ b/testing/metalog/APKBUILD
@@ -0,0 +1,53 @@
+# Contributor: Milan P. Stanić <[email-masked]>
+# Maintainer: Milan P. Stanić <[email-masked]>
+pkgname=metalog
+pkgver=20181125
+pkgrel=0
+pkgdesc="small, simple to config, flexible syslogd/klogd daemon"
+url="https://github.com/hvisage/metalog"
+arch="all"
+license="GPL-2.0-only"
+depends=""
+makedepends="pcre-dev automake autoconf autoconf-archive"
+subpackages="$pkgname-doc $pkgname-openrc"
+source="$pkgname-$pkgver.tar.gz::https://github.com/hvisage/metalog/archive/${pkgver}.tar.gz
+	metalog.initd
+	metalog.confd
+	"
+builddir="$srcdir/$pkgname-$pkgver"
+
+prepare() {
+	cd "$builddir"
+	./autogen.sh
+}
+
+build() {
+	cd "$builddir"
+	./configure \
+		--build=$CBUILD \
+		--host=$CHOST \
+		--prefix=/usr \
+		--sysconfdir=/etc \
+		--mandir=/usr/share/man \
+		--localstatedir=/var
+	make
+}
+
+check() {
+	cd "$builddir"
+	make check
+}
+
+package() {
+	cd "$builddir"
+	make DESTDIR="$pkgdir" install
+
+	install -m755 -D "$srcdir"/$pkgname.initd \
+		"$pkgdir"/etc/init.d/$pkgname
+	install -m644 -D "$srcdir"/$pkgname.confd \
+		"$pkgdir"/etc/conf.d/$pkgname
+}
+
+sha512sums="8ab6713e158a50a330efd0f81764bb4e9be16da3194eea8043d3758474171841adbca86c735a387b87df7f69b1567d3fcf320fc5dfcd5b6ad88f7ce4c6622d58  metalog-20181125.tar.gz
+c77d4a01e6a9d89e170f77531a9814e7cc2bbf0c0cc7247bc79708a5bea90e60325dbbbe25b96d067c7df1fd349b39e3da5e82db4d2218834eed1a4e13fc8f67  metalog.initd
+6e1e1249b90f98c70c8493f55d42f378b4111a0f7b80eaee9a51875967b297bf12ca80804e8fa9a39249b2a981dbc6f60ddadb93397e7fa0ad6959dd7c8b28be  metalog.confd"
diff --git a/testing/metalog/metalog.confd b/testing/metalog/metalog.confd
new file mode 100644
index 0000000000..f3c7a277d1
--- /dev/null
+++ b/testing/metalog/metalog.confd
@@ -0,0 +1,10 @@
+# Configuration file
+CONFIGFILE="/etc/metalog.conf"
+
+# PID file
+PIDFILE="/var/run/metalog.pid"
+
+# Options to metalog
+# "-B" start server in background/daemon mode
+# "-s" tells metalog to run in sync mode
+METALOG_OPTS="-B -s"
diff --git a/testing/metalog/metalog.initd b/testing/metalog/metalog.initd
new file mode 100644
index 0000000000..c7f25f1d37
--- /dev/null
+++ b/testing/metalog/metalog.initd
@@ -0,0 +1,40 @@
+#!/sbin/openrc-run
+
+extra_started_commands="reload"
+
+description="syslog server"
+name=metalog
+command="/usr/sbin/$name"
+
+depend() {
+	need clock hostname localmount
+	provide logger
+}
+
+start() {
+	ebegin "Starting metalog"
+	start-stop-daemon \
+		--start --quiet --exec $command \
+		-- ${METALOG_OPTS} -p "${PIDFILE}" -C "${CONFIGFILE}"
+	eend $?
+}
+
+stop() {
+	ebegin "Stopping metalog"
+	start-stop-daemon \
+		--stop --quiet \
+		--pidfile "${PIDFILE}"
+	eend $?
+}
+
+reload() {
+	if [ ! -f "${PIDFILE}" ]; then
+		eerror "metalog not running"
+		return 1
+	fi
+
+	ebegin "Re-opening metalog log files"
+	start-stop-daemon --stop --signal HUP \
+		--pidfile "${PIDFILE}"
+	eend $?
+}
-- 
2.20.1

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Natanael Copa <[email-masked]>
Date: Wed, 27 Feb 2019 08:32:18 +0100

On Fri, 22 Feb 2019 16:13:34 +0100

>  create mode 100644 testing/metalog/metalog.initd

....

> +++ b/testing/metalog/metalog.confd

We should use /run instead of /var/run.
http://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s15.html

> +++ b/testing/metalog/metalog.initd

I think we can factor out start and stop functions by:

change PIDFILE to pidfile
use: command_args="$METALOG_OPTS -p $pidfile -C $CONFIGFILE"

We may want check that $CONFIGFILE exists in a start_pre function too.

I guess we could also just steal the gentoo script:
https://gitweb.gentoo.org/repo/gentoo.git/tree/app-admin/metalog/files/metalog.initd-r1

---

---

From: Milan P. Stanić <[email-masked]>
Date: Sun, 3 Mar 2019 09:44:53 +0100

> On Fri, 22 Feb 2019 16:13:34 +0100
[...]
> http://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s15.html

Fixed.
[...]
> https://gitweb.gentoo.org/repo/gentoo.git/tree/app-admin/metalog/files/metalog.initd-r1
 
Fixed, i.e. use stolen Gentoo init script.

I posted updated patch according to your suggestions
https://patchwork.alpinelinux.org/patch/4538/

Thanks for help

-- 
regards

---