From 7bfc02130ff66e43a1cb2ab18aebbe1220e91334 Mon Sep 17 00:00:00 2001 From: Henning Heinold Date: Wed, 11 Dec 2013 17:44:01 +0100 Subject: [PATCH] busybox-syslog: unify configuration place of systemd und sysvinit scripts for dora * systemd has no way to set flexible enviroment variables, though setting or dropping variables based on other settings is not possible * EnvironmentFile option in systemd can only have name value pairs no logic * Best solution for this problem found at http://www.mail-archive.com/systemd-devel@lists.freedesktop.org/msg05091.html using a shell before starting the service * move the parameter logic from sysvinit startup file to syslog-startup.conf and source syslog-startup.conf from the busybox-syslog default file * /etc/syslog-startup.conf is now the only config file * works with bash and busybox-shell * bump PRINC --- .../busybox-systemd/busybox-syslog.default | 2 + .../busybox-systemd/busybox-syslog.service.in | 12 +++++ recipes-core/busybox/busybox-systemd/syslog | 44 +++++++++++++++ .../busybox-systemd/syslog-startup.conf | 54 +++++++++++++++---- recipes-core/busybox/busybox_sysmocom.inc | 2 +- 5 files changed, 104 insertions(+), 10 deletions(-) create mode 100644 recipes-core/busybox/busybox-systemd/busybox-syslog.default create mode 100644 recipes-core/busybox/busybox-systemd/busybox-syslog.service.in create mode 100644 recipes-core/busybox/busybox-systemd/syslog diff --git a/recipes-core/busybox/busybox-systemd/busybox-syslog.default b/recipes-core/busybox/busybox-systemd/busybox-syslog.default new file mode 100644 index 0000000..cbc4759 --- /dev/null +++ b/recipes-core/busybox/busybox-systemd/busybox-syslog.default @@ -0,0 +1,2 @@ +# source the sysvinit configuration file +. /etc/syslog-startup.conf diff --git a/recipes-core/busybox/busybox-systemd/busybox-syslog.service.in b/recipes-core/busybox/busybox-systemd/busybox-syslog.service.in new file mode 100644 index 0000000..7e524ca --- /dev/null +++ b/recipes-core/busybox/busybox-systemd/busybox-syslog.service.in @@ -0,0 +1,12 @@ +[Unit] +Description=System Logging Service +Wants=busybox-klogd.service + +[Service] +ExecStart=/bin/sh -c '. /etc/default/busybox-syslog; exec @base_sbindir@/syslogd -n $SYSLOG_ARGS +Sockets=syslog.socket + +[Install] +WantedBy=multi-user.target +Also=busybox-klogd.service +Alias=syslog.service diff --git a/recipes-core/busybox/busybox-systemd/syslog b/recipes-core/busybox/busybox-systemd/syslog new file mode 100644 index 0000000..6d9663f --- /dev/null +++ b/recipes-core/busybox/busybox-systemd/syslog @@ -0,0 +1,44 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: sysklogd +# Required-Start: $remote_fs $time +# Required-Stop: $remote_fs $time +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: System logger +### END INIT INFO + +set -e + +if [ -f /etc/syslog-startup.conf ]; then + . /etc/syslog-startup.conf + +else + # default: log to 16K shm circular buffer + SYSLOG_ARGS="-C" +fi + +case "$1" in + start) + echo -n "Starting syslogd/klogd: " + start-stop-daemon -S -b -n syslogd -a /sbin/syslogd -- -n $SYSLOG_ARGS + start-stop-daemon -S -b -n klogd -a /sbin/klogd -- -n + echo "done" + ;; + stop) + echo -n "Stopping syslogd/klogd: " + start-stop-daemon -K -n syslogd + start-stop-daemon -K -n klogd + echo "done" + ;; + restart) + $0 stop + $0 start + ;; + *) + echo "Usage: syslog { start | stop | restart }" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/recipes-core/busybox/busybox-systemd/syslog-startup.conf b/recipes-core/busybox/busybox-systemd/syslog-startup.conf index b434291..d252934 100644 --- a/recipes-core/busybox/busybox-systemd/syslog-startup.conf +++ b/recipes-core/busybox/busybox-systemd/syslog-startup.conf @@ -1,10 +1,46 @@ # sysmocom default configuration for systemd -DESTINATION="buffer" # log destinations (buffer file remote) -MARKINT=20 # intervall between --mark-- entries -LOGFILE=/var/log/messages # where to log (file) -REMOTE=loghost:514 # where to log (syslog remote) -REDUCE=no # reduce-size logging -#ROTATESIZE=0 # rotate log if grown beyond X [kByte] (incompatible with busybox) -#ROTATEGENS=3 # keep X generations of rotated logs (incompatible with busybox) -BUFFERSIZE=64 # size of circular buffer [kByte] -FOREGROUND=no # run in foreground (don't use!) +DESTINATION="buffer" # log destinations (buffer file remote) +MARKINT=20 # intervall between --mark-- entries +LOGFILE=/var/log/messages # where to log (file) +REMOTE=loghost:514 # where to log (syslog remote) +REDUCE=no # reduce-size logging +#ROTATESIZE=0 # rotate log if grown beyond X [kByte] (incompatible with busybox) +#ROTATEGENS=3 # keep X generations of rotated logs (incompatible with busybox) +BUFFERSIZE=64 # size of circular buffer [kByte] +FOREGROUND=no # run in foreground (don't use!) + +LOG_LOCAL=0 +LOG_REMOTE=0 +for D in $DESTINATION; do + if [ "$D" = "buffer" ]; then + SYSLOG_ARGS="$SYSLOG_ARGS -C$BUFFERSIZE" + LOG_LOCAL=1 + elif [ "$D" = "file" ]; then + if [ -n "$LOGFILE" ]; then + SYSLOG_ARGS="$SYSLOG_ARGS -O $LOGFILE" + fi + if [ -n "$ROTATESIZE" ]; then + SYSLOG_ARGS="$SYSLOG_ARGS -s $ROTATESIZE" + fi + if [ -n "$ROTATEGENS" ]; then + SYSLOG_ARGS="$SYSLOG_ARGS -b $ROTATEGENS" + fi + LOCAL=0 + elif [ "$D" = "remote" ]; then + SYSLOG_ARGS="$SYSLOG_ARGS -R $REMOTE" + LOG_REMOTE=1 + fi +done + +if [ "$LOG_LOCAL" = "1" -a "$LOG_REMOTE" = "1" ]; then + SYSLOG_ARGS="$SYSLOG_ARGS -L" +fi +if [ "$REDUCE" = "yes" ]; then + SYSLOG_ARGS="$SYSLOG_ARGS -S" +fi +if [ "$DROPDUPLICATES" = "yes" ]; then + SYSLOG_ARGS="$SYSLOG_ARGS -D" +fi +if [ -n "$LOGLEVEL" ]; then + SYSLOG_ARGS="$SYSLOG_ARGS -l $LOGLEVEL" +fi diff --git a/recipes-core/busybox/busybox_sysmocom.inc b/recipes-core/busybox/busybox_sysmocom.inc index 9691f30..9b64562 100644 --- a/recipes-core/busybox/busybox_sysmocom.inc +++ b/recipes-core/busybox/busybox_sysmocom.inc @@ -1,6 +1,6 @@ SYSMOCOM := "${@os.path.dirname(bb.data.getVar('FILE', d, True))}" FILESEXTRAPATHS_prepend := "${SYSMOCOM}/busybox-${SYSMOCOM_ORIG_PV}:${SYSMOCOM}/files:" -PRINC = "18" +PRINC = "19" SRC_URI += "file://busybox-ifplugd.sh \ file://ifplugd.sh"