From e38f6a1fe67efb031c325ea87f11c0bccd09453f Mon Sep 17 00:00:00 2001 From: f Date: Sat, 4 Jun 2022 16:48:38 -0300 Subject: [PATCH] syslogize a wrapper for sending output to syslog when the program doesn't support it. if adds syslogging support to daemonize as well. --- syslogize.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 syslogize.sh diff --git a/syslogize.sh b/syslogize.sh new file mode 100755 index 0000000..97060ff --- /dev/null +++ b/syslogize.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# A wrapper for programs that can't write to syslog. Output and error +# are sent to syslog. +# +# Use LOGGER environment variable to pass options to `logger`. They'll +# probably be system-dependent, so handle with care. +# +# Usage: +# +# LOGGER="-t program" syslogize program -o -p --tions argu ments +# +# daemonize syslogize program + +if test $# -eq 0 ; then + grep "^#" $0 | grep -v /bin/sh | sed -re "s/^#\s*//" >&2 + + exit 1 +fi + +$@ 2>&1 | logger ${LOGGER}