motd update
Dylan Reinhold
dylan at ocnetworking.com
Fri Jan 30 19:07:20 PST 2004
Matthew Dillon wrote:
:
:> ? It works for me. If you want to augment it to not update the
:> motd if the motd does not already have a DragonFly line I think that's
:> fine, but don't just turn it off.
:
:I don't see why the uname output should be in motd. Every sysadmin out there
:knows how to use uname if they want to see what OS/version its running.
The solution is clear... the code should be adjusted such that if
there is a DragonFly release string in the motd, the boot code adjusts
it, and if there is no DragonFly release string in the motd, the boot
code doesn't mess with it.
The default motd has a DragonFly release string so insofar as new
installs go, the motd will have the release. But if the sysop doesn't
like it he can just delete it from the motd without messing with rc.conf.
Would someone like to have a go at 'fixing' /etc/rc.d/motd to
generate this behavior?
-Matt
Matthew Dillon
<dillon at xxxxxxxxxxxxx>
Ok here it is...
This was only tested on a FreeBSD-5.2 system, I haven't had a chance to
install DragonFly (Soon..). /etc/motd will only be updated if the first
work of the first line is DragonFly..
Dylan
Index: motd
===================================================================
RCS file: /home/dragonfly/cvsroot/src/etc/rc.d/motd,v
retrieving revision 1.5
diff -u -r1.5 motd
--- motd 27 Jan 2004 00:42:45 -0000 1.5
+++ motd 31 Jan 2004 02:59:54 -0000
@@ -29,14 +29,20 @@
install -c -o root -g wheel -m ${PERMS} /dev/null /etc/motd
fi
- 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
+ T1=`mktemp -t motd`
+ awk 'NR == 1 {if ($1 == "DragonFly") {print} else {exit 1}}' < /etc/motd > $T1 && {
+
+ 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 $T1
}
- rm -f $T
+
}
load_rc_config $name
More information about the Submit
mailing list