148 lines
5.3 KiB
Diff
148 lines
5.3 KiB
Diff
|
From 223547feab5eb85ee96e0e097b6172705803e260 Mon Sep 17 00:00:00 2001
|
||
|
From: Brendan Germain <brendan.germain@nasdaqomx.com>
|
||
|
Date: Wed, 25 May 2016 13:25:09 -0400
|
||
|
Subject: [PATCH] move start from udev to initqueue/online
|
||
|
|
||
|
---
|
||
|
modules.d/98syslog/module-setup.sh | 3 +--
|
||
|
modules.d/98syslog/parse-syslog-opts.sh | 22 +++++++++++++++++++++-
|
||
|
modules.d/98syslog/rsyslogd-start.sh | 21 +++++++++++++++------
|
||
|
modules.d/98syslog/syslog-genrules.sh | 30 ------------------------------
|
||
|
4 files changed, 37 insertions(+), 39 deletions(-)
|
||
|
delete mode 100755 modules.d/98syslog/syslog-genrules.sh
|
||
|
|
||
|
diff --git a/modules.d/98syslog/module-setup.sh b/modules.d/98syslog/module-setup.sh
|
||
|
index 4458229..e18aecb 100755
|
||
|
--- a/modules.d/98syslog/module-setup.sh
|
||
|
+++ b/modules.d/98syslog/module-setup.sh
|
||
|
@@ -29,9 +29,8 @@ install() {
|
||
|
if [ -n "$_installs" ]; then
|
||
|
inst_multiple cat $_installs
|
||
|
inst_hook cmdline 90 "$moddir/parse-syslog-opts.sh"
|
||
|
- inst_hook pre-udev 61 "$moddir/syslog-genrules.sh"
|
||
|
inst_hook cleanup 99 "$moddir/syslog-cleanup.sh"
|
||
|
- inst_simple "$moddir/rsyslogd-start.sh" /sbin/rsyslogd-start
|
||
|
+ inst_hook initqueue/online 70 "$moddir/rsyslogd-start.sh"
|
||
|
inst_simple "$moddir/rsyslogd-stop.sh" /sbin/rsyslogd-stop
|
||
|
mkdir -m 0755 -p ${initdir}/etc/templates
|
||
|
inst_simple "${moddir}/rsyslog.conf" /etc/templates/rsyslog.conf
|
||
|
diff --git a/modules.d/98syslog/parse-syslog-opts.sh b/modules.d/98syslog/parse-syslog-opts.sh
|
||
|
index 3943258..50ec275 100755
|
||
|
--- a/modules.d/98syslog/parse-syslog-opts.sh
|
||
|
+++ b/modules.d/98syslog/parse-syslog-opts.sh
|
||
|
@@ -9,10 +9,30 @@
|
||
|
# Don't auto detect syslog but set it
|
||
|
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||
|
|
||
|
+detect_syslog() {
|
||
|
+ syslogtype=""
|
||
|
+ if [ -e /sbin/rsyslogd ]; then
|
||
|
+ syslogtype="rsyslogd"
|
||
|
+ elif [ -e /sbin/syslogd ]; then
|
||
|
+ syslogtype="syslogd"
|
||
|
+ elif [ /sbin/syslog-ng ]; then
|
||
|
+ syslogtype="syslog-ng"
|
||
|
+ else
|
||
|
+ warn "Could not find any syslog binary although the syslogmodule is selected to be installed. Please check."
|
||
|
+ fi
|
||
|
+ echo "$syslogtype"
|
||
|
+ [ -n "$syslogtype" ]
|
||
|
+}
|
||
|
+
|
||
|
syslogserver=$(getarg syslog.server -d syslog)
|
||
|
syslogfilters=$(getargs syslog.filter -d filter)
|
||
|
syslogtype=$(getarg syslog.type -d syslogtype)
|
||
|
|
||
|
[ -n "$syslogserver" ] && echo $syslogserver > /tmp/syslog.server
|
||
|
[ -n "$syslogfilters" ] && echo "$syslogfilters" > /tmp/syslog.filters
|
||
|
-[ -n "$syslogtype" ] && echo "$syslogtype" > /tmp/syslog.type
|
||
|
+if [ -n "$syslogtype" ]; then
|
||
|
+ echo "$syslogtype" > /tmp/syslog.type
|
||
|
+else
|
||
|
+ syslogtype=$(detect_syslog)
|
||
|
+ echo $syslogtype > /tmp/syslog.type
|
||
|
+fi
|
||
|
diff --git a/modules.d/98syslog/rsyslogd-start.sh b/modules.d/98syslog/rsyslogd-start.sh
|
||
|
index c08e667..25dfb16 100755
|
||
|
--- a/modules.d/98syslog/rsyslogd-start.sh
|
||
|
+++ b/modules.d/98syslog/rsyslogd-start.sh
|
||
|
@@ -1,9 +1,15 @@
|
||
|
#!/bin/sh
|
||
|
|
||
|
-# Triggered by udev and starts rsyslogd with bootparameters
|
||
|
+# Triggered by initqueue/online and starts rsyslogd with bootparameters
|
||
|
|
||
|
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||
|
|
||
|
+# prevent starting again if already running
|
||
|
+if [ -f /var/run/syslogd.pid ]; then
|
||
|
+ read pid < /var/run/syslogd.pid
|
||
|
+ kill -0 $pid && exit 0
|
||
|
+fi
|
||
|
+
|
||
|
rsyslog_config() {
|
||
|
local server=$1
|
||
|
shift
|
||
|
@@ -17,17 +23,20 @@ rsyslog_config() {
|
||
|
for filter in $filters; do
|
||
|
echo "${filter} @${server}"
|
||
|
done
|
||
|
-# echo "*.* /tmp/syslog"
|
||
|
+ #echo "*.* /tmp/syslog"
|
||
|
}
|
||
|
|
||
|
+read type < /tmp/syslog.type
|
||
|
read server < /tmp/syslog.server
|
||
|
read filters < /tmp/syslog.filters
|
||
|
[ -z "$filters" ] && filters="kern.*"
|
||
|
read conf < /tmp/syslog.conf
|
||
|
[ -z "$conf" ] && conf="/etc/rsyslog.conf" && echo "$conf" > /tmp/syslog.conf
|
||
|
|
||
|
-template=/etc/templates/rsyslog.conf
|
||
|
-if [ -n "$server" ]; then
|
||
|
- rsyslog_config "$server" "$template" "$filters" > $conf
|
||
|
- rsyslogd -c3
|
||
|
+if [ $type == "rsyslogd" ]; then
|
||
|
+ template=/etc/templates/rsyslog.conf
|
||
|
+ if [ -n "$server" ]; then
|
||
|
+ rsyslog_config "$server" "$template" "$filters" > $conf
|
||
|
+ rsyslogd -c3
|
||
|
+ fi
|
||
|
fi
|
||
|
diff --git a/modules.d/98syslog/syslog-genrules.sh b/modules.d/98syslog/syslog-genrules.sh
|
||
|
deleted file mode 100755
|
||
|
index 072bdea..0000000
|
||
|
--- a/modules.d/98syslog/syslog-genrules.sh
|
||
|
+++ /dev/null
|
||
|
@@ -1,30 +0,0 @@
|
||
|
-#!/bin/sh
|
||
|
-
|
||
|
-# Creates the syslog udev rules to be triggered when interface becomes online.
|
||
|
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||
|
-
|
||
|
-detect_syslog() {
|
||
|
- syslogtype=""
|
||
|
- if [ -e /sbin/rsyslogd ]; then
|
||
|
- syslogtype="rsyslogd"
|
||
|
- elif [ -e /sbin/syslogd ]; then
|
||
|
- syslogtype="syslogd"
|
||
|
- elif [ /sbin/syslog-ng ]; then
|
||
|
- syslogtype="syslog-ng"
|
||
|
- else
|
||
|
- warn "Could not find any syslog binary although the syslogmodule is selected to be installed. Please check."
|
||
|
- fi
|
||
|
- echo "$syslogtype"
|
||
|
- [ -n "$syslogtype" ]
|
||
|
-}
|
||
|
-
|
||
|
-read syslogtype < /tmp/syslog.type
|
||
|
-if [ -z "$syslogtype" ]; then
|
||
|
- syslogtype=$(detect_syslog)
|
||
|
- echo $syslogtype > /tmp/syslog.type
|
||
|
-fi
|
||
|
-if [ -e "/sbin/${syslogtype}-start" ]; then
|
||
|
- printf 'ACTION=="online", SUBSYSTEM=="net", RUN+="/sbin/initqueue --onetime /sbin/'${syslogtype}'-start $env{INTERFACE}"\n' > /etc/udev/rules.d/70-syslog.rules
|
||
|
-else
|
||
|
- warn "syslog-genrules: Could not find binary to start syslog of type \"$syslogtype\". Syslog will not be started."
|
||
|
-fi
|