From 0f85a3d4ba9ff457fc23578eb9b4fd6ff241856a Mon Sep 17 00:00:00 2001 From: Lukas Nykryn Date: Tue, 27 Aug 2024 11:35:40 +0200 Subject: [PATCH 1/4] netconsole: remove trailing whitespaces --- usr/libexec/netconsole | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/usr/libexec/netconsole b/usr/libexec/netconsole index 3f2872dd2..26c9baabc 100755 --- a/usr/libexec/netconsole +++ b/usr/libexec/netconsole @@ -1,5 +1,5 @@ #!/bin/bash -# +# # netconsole This loads the netconsole module with the configured parameters. # # chkconfig: - 50 50 @@ -50,7 +50,7 @@ print_address_info () local route via target route=$(LANG=C ip -o route get to $host/32) - + [ -z "$DEV" ] && DEV=$(echo $route | sed "s|.* dev \([^ ]*\).*|\1|") echo "DEV=$DEV" echo "LOCALADDR=$(echo $route | sed "s|.* src \([^ ]*\).*|\1|")" @@ -63,9 +63,9 @@ print_address_info () if [ -z "$SYSLOGMACADDR" ]; then arp=$(LANG=C /sbin/arping -f -c 1 -I $DEV $target 2>/dev/null | awk '/ reply from .*[.*]/ { print gensub(".* reply from .* \\[(.*)\\].*","\\1","G"); exit }') [ -n "$arp" ] && echo "SYSLOGMACADDR=$arp" - fi -} - + fi +} + start () { [ -f /etc/sysconfig/netconsole ] || exit 6 @@ -101,7 +101,7 @@ start () exit 6 fi eval $(print_address_info $SYSLOGADDR) - + if [ -z "$SYSLOGMACADDR" ]; then echo $"netconsole: can't resolve MAC address of $SYSLOGADDR" 1>&2 exit 1 @@ -140,7 +140,6 @@ status () fi } - restart () { stop @@ -152,7 +151,6 @@ condrestart () [ -e /var/lock/subsys/netconsole ] && restart } - case "$1" in stop) stop ;; status) status ;; From 370b5f40aec9070f99b8c883209c4bcaec359411 Mon Sep 17 00:00:00 2001 From: Lukas Nykryn Date: Tue, 27 Aug 2024 11:36:14 +0200 Subject: [PATCH 2/4] netconsole: remove unused variables --- usr/libexec/netconsole | 3 --- 1 file changed, 3 deletions(-) diff --git a/usr/libexec/netconsole b/usr/libexec/netconsole index 26c9baabc..20bee9d43 100755 --- a/usr/libexec/netconsole +++ b/usr/libexec/netconsole @@ -20,7 +20,6 @@ PATH=/sbin:/usr/sbin:$PATH RETVAL=0 -SERVER_ADDRESS_RESOLUTION= # Check that networking is up. . /etc/sysconfig/network @@ -36,8 +35,6 @@ SYSLOGADDR= SYSLOGPORT=514 SYSLOGMACADDR= -kernel=$(uname -r | cut -d. -f1-2) - usage () { echo $"Usage: $0 {start|stop|status|restart|condrestart}" 1>&2 From 3e54b73c94dd3929e457edc7d53da5b7c19ea9a8 Mon Sep 17 00:00:00 2001 From: Lukas Nykryn Date: Tue, 27 Aug 2024 11:36:49 +0200 Subject: [PATCH 3/4] netconsole: source sysconfig/network only if it exists Although the comment said "check if network is up", the code only sourced the configuration file, but did not fail if it did not exist and happily continued. Also on current versions of Fedora, the sysconfig/network does not exist by default, so you see a warning message when you start the service. So let's just check if the file exists and only source it if it does (for backwards compatibility). --- usr/libexec/netconsole | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/usr/libexec/netconsole b/usr/libexec/netconsole index 20bee9d43..31ed526a3 100755 --- a/usr/libexec/netconsole +++ b/usr/libexec/netconsole @@ -21,8 +21,7 @@ PATH=/sbin:/usr/sbin:$PATH RETVAL=0 -# Check that networking is up. -. /etc/sysconfig/network +[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network # Source function library. . /etc/rc.d/init.d/functions From b12aa8a64a7d302cb21837cdb481469a96b9d5b7 Mon Sep 17 00:00:00 2001 From: Lukas Nykryn Date: Tue, 27 Aug 2024 12:29:42 +0200 Subject: [PATCH 4/4] netconsole: var/lock -> run/lock /var/lock is a symlink to /run/lock, so let's use proper location --- usr/libexec/netconsole | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usr/libexec/netconsole b/usr/libexec/netconsole index 31ed526a3..92c79c62d 100755 --- a/usr/libexec/netconsole +++ b/usr/libexec/netconsole @@ -112,7 +112,7 @@ start () $SYSLOGOPTS [ "$?" != "0" ] && RETVAL=1 fi - touch /var/lock/subsys/netconsole + touch /run/lock/subsys/netconsole } stop () @@ -122,7 +122,7 @@ stop () [ "$?" != "0" ] && RETVAL=1 fi - rm -f /var/lock/subsys/netconsole + rm -f /run/lock/subsys/netconsole } status () @@ -144,7 +144,7 @@ restart () condrestart () { - [ -e /var/lock/subsys/netconsole ] && restart + [ -e /run/lock/subsys/netconsole ] && restart } case "$1" in