Date: Sun, 2 Dec 2007 16:49:32 GMT From: Renato Botelho <garga@FreeBSD.org> To: freebsd-gnats-submit@FreeBSD.org Subject: misc/118385: /etc/rc.d/motd doesn't work on custom system Message-ID: <200712021649.lB2GnWpR010344@www.freebsd.org> Resent-Message-ID: <200712021650.lB2Go08J057932@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 118385
>Category: misc
>Synopsis: /etc/rc.d/motd doesn't work on custom system
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sun Dec 02 16:50:00 UTC 2007
>Closed-Date:
>Last-Modified:
>Originator: Renato Botelho
>Release: 7.0-BETA3
>Organization:
>Environment:
FreeBSD localhost 7.0-BETA3 FreeBSD 7.0-BETA3 #1: Sat Dec 1 17:38:41 BRST 2007 root@localhost:/usr/obj/usr/src/sys/GARGA i386
>Description:
When you customize Operating System name, /etc/rc.d/motd add a new OS information line at the top of /etc/motd on each new boot.
It happens because name "FreeBSD" is harcoded inside it, i've changed it to get OS name using uname command.
I don't know if the way i did it is the best, but it's working here.
>How-To-Repeat:
>Fix:
Index: src/etc/rc.d/motd
===================================================================
RCS file: /home/ncvs/src/etc/rc.d/motd,v
retrieving revision 1.9
diff -u -r1.9 motd
--- src/etc/rc.d/motd 7 Oct 2004 13:55:26 -0000 1.9
+++ src/etc/rc.d/motd 2 Dec 2007 16:32:33 -0000
@@ -34,14 +34,16 @@
fi
T=`mktemp -t motd`
+ export __OSNAME=`/usr/bin/uname`
uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T}
- awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T}
+ awk '{if (NR == 1) {if ($1 == ENVIRON["__OSNAME"]) {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T}
cmp -s $T /etc/motd || {
cp $T /etc/motd
chmod ${PERMS} /etc/motd
}
rm -f $T
+ unset __OSNAME
echo .
}
>Release-Note:
>Audit-Trail:
>Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200712021649.lB2GnWpR010344>
