]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
move start from udev to initqueue/online
authorBrendan Germain <brendan.germain@nasdaqomx.com>
Wed, 25 May 2016 17:25:09 +0000 (13:25 -0400)
committerBrendan Germain <brendan.germain@nasdaqomx.com>
Tue, 11 Oct 2016 12:43:20 +0000 (08:43 -0400)
modules.d/98syslog/module-setup.sh
modules.d/98syslog/parse-syslog-opts.sh
modules.d/98syslog/rsyslogd-start.sh
modules.d/98syslog/syslog-genrules.sh [deleted file]

index 4458229bad9fab59cfcc6eab23ca55eb5364bc84..e18aecbcf1f866d52ed0c03098a7b315f52d7580 100755 (executable)
@@ -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
index 394325889379c82f8c0f6310e24e7658f8a4e7bb..50ec27597c727a86a9d6a99a2fb34f8aae16d4cf 100755 (executable)
@@ -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
index c08e6675744147e2766c99bf6d9f6e9a2aa21748..25dfb16d136fc51548e7a29a80d5e927199e2d9f 100755 (executable)
@@ -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 (executable)
index 072bdea..0000000
+++ /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