From 1342d2dfa0060157754ee26ffc4c099794a9efa9 Mon Sep 17 00:00:00 2001 From: Robert Garrett Date: Sun, 1 Feb 2004 03:32:08 +0000 Subject: [PATCH] only update motd if the first word of the first line is Dragonfly Submitted by: Dylan Reinhold --- etc/rc.d/motd | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/etc/rc.d/motd b/etc/rc.d/motd index 4e988e00a8..a0665e5776 100644 --- a/etc/rc.d/motd +++ b/etc/rc.d/motd @@ -2,7 +2,7 @@ # # $NetBSD: motd,v 1.5 2000/09/19 13:04:38 lukem Exp $ # $FreeBSD: src/etc/rc.d/motd,v 1.6 2003/06/30 22:06:26 mtm Exp $ -# $DragonFly: src/etc/rc.d/motd,v 1.5 2004/01/27 00:42:45 rob Exp $ +# $DragonFly: src/etc/rc.d/motd,v 1.6 2004/02/01 03:32:08 rob Exp $ # # PROVIDE: motd @@ -28,16 +28,19 @@ motd_start() if [ ! -f /etc/motd ]; then install -c -o root -g wheel -m ${PERMS} /dev/null /etc/motd fi + T1='mktem -t motd' + awk 'NR == 1{if ($1 == "DragonFly") {print} else {exit 1}}' < /etc/motd > $t1 && { - T=`mktemp -t motd` - uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T} - awk '{if (NR == 1) {if ($1 == "DragonFly") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T} - cmp -s $T /etc/motd || { - cp $T /etc/motd - chmod ${PERMS} /etc/motd + T2=`mktemp -t motd` + uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T2} + cmp -s $T1 $T2 || { + awk '{if (NR == 1) {next} else {print}}' < /etc/motd >> ${T2} + cp $T2 /etc/motd + chmod ${PERMS} /etc/motd + rm -f $T2 + } } rm -f $T } - load_rc_config $name run_rc_command "$1" -- 2.41.0