summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authormartin <martin@NetBSD.org>2020-09-13 12:11:07 +0000
committermartin <martin@NetBSD.org>2020-09-13 12:11:07 +0000
commitc95d68cdaf806fc94968524b20f4e6d20629443c (patch)
tree5f702032076ba89a819cd3c7a6fa844b981b147f /etc
parent5ce9937df72d433b5dbc634b28fb35eb2de96276 (diff)
Pull up following revision(s) (requested by kim in ticket #1080):
etc/rc.d/motd: revision 1.10 etc/rc.d/motd: revision 1.11 share/man/man5/rc.conf.5: revision 1.186 share/man/man5/rc.conf.5: revision 1.187 etc/defaults/rc.conf: revision 1.159 Add optional release info in /etc/motd My personal preferencese for /etc/rc.conf: update_motd_release=YES motd_release_tag='Binaries: ' This provides an explanation to users about the second version in motd. Document update_motd_release and motd_release_tag New sentence, new line. Make a ": " suffix a fixed part of the release info tag This results in correct updates to /etc/motd even when the value of motd_release_tag is changed (a likely event). Add safe quoting to outputting the read kernel version. Thanks to kre@ for the feedback.
Diffstat (limited to 'etc')
-rw-r--r--etc/defaults/rc.conf3
-rwxr-xr-xetc/rc.d/motd17
2 files changed, 15 insertions, 5 deletions
diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf
index ad9e40dacc8..768348ebc8f 100644
--- a/etc/defaults/rc.conf
+++ b/etc/defaults/rc.conf
@@ -1,4 +1,4 @@
-# $NetBSD: rc.conf,v 1.151.2.1 2019/09/27 09:18:38 martin Exp $
+# $NetBSD: rc.conf,v 1.151.2.2 2020/09/13 12:11:07 martin Exp $
#
# /etc/defaults/rc.conf --
# default configuration of /etc/rc.conf
@@ -132,6 +132,7 @@ per_user_tmp=NO # per-user /tmp directories
per_user_tmp_dir="/private/tmp" # real storage for /tmp
clear_tmp=YES # clear /tmp after reboot
update_motd=YES # updates /etc/motd
+update_motd_release=NO motd_release_tag="" # release info in /etc/motd
dmesg=YES dmesg_flags="-t" # write /var/run/dmesg.boot
accounting=NO # uses /var/account/acct
newsyslog=NO newsyslog_flags="" # trim log files
diff --git a/etc/rc.d/motd b/etc/rc.d/motd
index 818d811c431..3d3b9ec0f28 100755
--- a/etc/rc.d/motd
+++ b/etc/rc.d/motd
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $NetBSD: motd,v 1.9 2004/08/13 18:08:03 mycroft Exp $
+# $NetBSD: motd,v 1.9.96.1 2020/09/13 12:11:07 martin Exp $
#
# PROVIDE: motd
@@ -16,7 +16,7 @@ stop_cmd=":"
motd_start()
{
- # Update kernel info in /etc/motd
+ # Update kernel and release info in /etc/motd
# Must be done *before* interactive logins are possible
# to prevent possible race conditions.
#
@@ -26,8 +26,17 @@ motd_start()
fi
( umask 022
T=/etc/_motd
- sysctl -n kern.version | while read i; do echo $i; break; done > $T
- sed '1{/^NetBSD.*/{d;};};' < /etc/motd >> $T
+ sysctl -n kern.version | while read i; do echo "$i"; break; done > $T
+ if checkyesno update_motd_release; then
+ local t=$(echo "${motd_release_tag%%:*}" | tr -d /)
+ sed -En '1{/^NetBSD/{'"${t:+s/^/${t}: /;}"'h;d;};q;}
+ /^ *Build ID */{s//(/;s/$/)/;H;g;y/\n/ /;p;q;}
+ ${g;p;}' < /etc/release >> $T
+ sed -E '1,2{/^([^:]*: )?NetBSD/{d;};};' \
+ < /etc/motd >> $T
+ else
+ sed '1{/^NetBSD.*/{d;};};' < /etc/motd >> $T
+ fi
cmp -s $T /etc/motd || cp $T /etc/motd
rm -f $T
)