Mail archive
alpine-aports

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

From: Natanael Copa <ncopa_at_alpinelinux.org>
Date: Wed, 27 Feb 2019 08:32:18 +0100

On Fri, 22 Feb 2019 16:13:34 +0100
Milan P. Stani* <mps_at_arvanta.net> wrote:

> ---
> 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/metalog.confd b/testing/metalog/metalog.confd
> new file mode 100644
> index 0000000000..f3c7a277d1
> --- /dev/null
> +++ b/testing/metalog/metalog.confd
> _at_@ -0,0 +1,10 @@
> +# Configuration file
> +CONFIGFILE="/etc/metalog.conf"
> +
> +# PID file
> +PIDFILE="/var/run/metalog.pid"

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


> +
> +# 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
> _at_@ -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 $?
> +}

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

> +
> +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 $?
> +}



---
Unsubscribe:  alpine-aports+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-aports+help_at_lists.alpinelinux.org
---
Received on Wed Feb 27 2019 - 08:32:18 UTC