diff --git a/recipes/core/syslog-ng.yaml b/recipes/core/syslog-ng.yaml index 4d03dffa..df6e27e4 100644 --- a/recipes/core/syslog-ng.yaml +++ b/recipes/core/syslog-ng.yaml @@ -1,4 +1,4 @@ -inherit: [autotools] +inherit: [autotools, init] metaEnvironment: PKG_VERSION: "4.11.0" @@ -31,6 +31,11 @@ buildScript: | --disable-python \ --disable-example-modules + # add init script + if initIsAnySysvinit; then + install -D -m 0755 $<@syslog-ng/S11syslog-ng.sh@> install/etc/init.d/S11syslog-ng.sh + fi + packageScript: | autotoolsPackageTgt provideDeps: ['*-tgt'] diff --git a/recipes/core/syslog-ng/S11syslog-ng.sh b/recipes/core/syslog-ng/S11syslog-ng.sh new file mode 100755 index 00000000..3bdecfb1 --- /dev/null +++ b/recipes/core/syslog-ng/S11syslog-ng.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# +# Starts syslog (syslog-ng) daemon +# + +DAEMON="syslog-ng" +PIDFILE="/var/run/$DAEMON.pid" + +# shellcheck source=/dev/null +[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON" + +start() { + printf 'Starting %s: ' "$DAEMON" + # shellcheck disable=SC2086 # we need the word splitting + start-stop-daemon -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return "$status" +} + +stop() { + printf 'Stopping %s: ' "$DAEMON" + start-stop-daemon -K -q -p "$PIDFILE" + status=$? + if [ "$status" -eq 0 ]; then + rm -f "$PIDFILE" + echo "OK" + else + echo "FAIL" + fi + return "$status" +} + +restart() { + stop + sleep 1 + start +} + +case "$1" in + start|stop|restart) + "$1";; + reload) + # Restart, since there is no true "reload" feature. + restart;; + *) + echo "Usage: $0 {start|stop|restart|reload}" + exit 1 +esac