summaryrefslogtreecommitdiffstats
path: root/source/a/sysvinit-scripts/scripts/rc.S
diff options
context:
space:
mode:
author Patrick J Volkerding <volkerdi@slackware.com>2024-01-07 20:24:51 +0000
committer Eric Hameleers <alien@slackware.com>2024-01-07 21:58:43 +0100
commit360a12d5d90dc285bebff21b774cea64dffe1ca4 (patch)
treec5332cc840ea1b367559bac87e1f196d71f0ef34 /source/a/sysvinit-scripts/scripts/rc.S
parentbf38de5939ff0d03f10882392a1e61c7a169de50 (diff)
downloadcurrent-360a12d5d90dc285bebff21b774cea64dffe1ca4.tar.gz
current-360a12d5d90dc285bebff21b774cea64dffe1ca4.tar.xz
Sun Jan 7 20:24:51 UTC 202420240107202451
a/sysvinit-scripts-15.1-noarch-11.txz: Rebuilt. rc.S: Don't attempt to edit /etc/motd unless it exists, it is writable, and the first line starts with "Linux <wrong kernel version>." Thanks to lostintime. kde/okteta-0.26.15-x86_64-1.txz: Upgraded. l/at-spi2-core-2.50.1-x86_64-1.txz: Upgraded.
Diffstat (limited to 'source/a/sysvinit-scripts/scripts/rc.S')
-rw-r--r--source/a/sysvinit-scripts/scripts/rc.S13
1 files changed, 11 insertions, 2 deletions
diff --git a/source/a/sysvinit-scripts/scripts/rc.S b/source/a/sysvinit-scripts/scripts/rc.S
index 310fdd288..2466cd77a 100644
--- a/source/a/sysvinit-scripts/scripts/rc.S
+++ b/source/a/sysvinit-scripts/scripts/rc.S
@@ -405,8 +405,17 @@ mkdir -p /var/run/faillock
# Update the current kernel level in the /etc/motd (Message Of The Day) file,
# if the first line of that file begins with the word 'Linux'.
# You are free to modify the rest of the file as you see fit.
-if [ -x /bin/sed ]; then
- /bin/sed -i "{1s/^Linux.*/$(/bin/uname -sr)\./}" /etc/motd
+# We'll only do this if /etc/motd already exists, is writable, and the first
+# line starts with "Linux" followed by a version number that needs to be
+# updated.
+#
+if [ -w /etc/motd ]; then
+ if head -n 1 /etc/motd | grep -q "^Linux " ; then
+ # Replace the kernel version if it is not correct:
+ if [ ! "$(/bin/uname -r)." = "$(head -n 1 /etc/motd | cut -f 2 -d ' ')" ]; then
+ sed -i "{1s/^Linux.*/$(/bin/uname -sr)\./}" /etc/motd
+ fi
+ fi
fi
# If there are SystemV init scripts for this runlevel, run them.