Module Name:    src
Committed By:   martin
Date:           Sun Sep 13 12:13:13 UTC 2020

Modified Files:
        src/etc/rc.d [netbsd-8]: motd
        src/share/man/man5 [netbsd-8]: rc.conf.5

Log Message:
Pull up following revision(s) (requested by kim in ticket #1603):

        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.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.9.86.1 src/etc/rc.d/motd
cvs rdiff -u -r1.166.6.2 -r1.166.6.3 src/share/man/man5/rc.conf.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/etc/rc.d/motd
diff -u src/etc/rc.d/motd:1.9 src/etc/rc.d/motd:1.9.86.1
--- src/etc/rc.d/motd:1.9	Fri Aug 13 18:08:03 2004
+++ src/etc/rc.d/motd	Sun Sep 13 12:13:13 2020
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: motd,v 1.9 2004/08/13 18:08:03 mycroft Exp $
+# $NetBSD: motd,v 1.9.86.1 2020/09/13 12:13:13 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
 	)

Index: src/share/man/man5/rc.conf.5
diff -u src/share/man/man5/rc.conf.5:1.166.6.2 src/share/man/man5/rc.conf.5:1.166.6.3
--- src/share/man/man5/rc.conf.5:1.166.6.2	Thu Apr 23 13:43:42 2020
+++ src/share/man/man5/rc.conf.5	Sun Sep 13 12:13:13 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: rc.conf.5,v 1.166.6.2 2020/04/23 13:43:42 martin Exp $
+.\"	$NetBSD: rc.conf.5,v 1.166.6.3 2020/09/13 12:13:13 martin Exp $
 .\"
 .\" Copyright (c) 1996 Matthew R. Green
 .\" All rights reserved.
@@ -55,7 +55,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd April 23, 2020
+.Dd September 11, 2020
 .Dt RC.CONF 5
 .Os
 .Sh NAME
@@ -575,6 +575,18 @@ version string in the
 file to reflect the version of the running kernel.
 See
 .Xr motd 5 .
+.It Sy update_motd_release
+Boolean value.
+If enabled in addition to
+.Sy update_motd ,
+updates a second
+.Nx
+version string in the
+.Pa /etc/motd
+file to reflect the version, architecture, and Build ID of
+the installed userland.
+An optional prefix can be provided for this version string in
+.Sy motd_release_tag .
 .It Sy virecover
 Boolean value.
 Send notification mail to users if any recoverable files exist in

Reply via email to