From owner-freebsd-hackers Mon Jul 8 18:41:32 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id SAA22148 for hackers-outgoing; Mon, 8 Jul 1996 18:41:32 -0700 (PDT) Received: from clipper.cs.kiev.ua (root@cs-demon-64k.cs.kiev.ua [193.124.48.251]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id SAA22118 for ; Mon, 8 Jul 1996 18:41:08 -0700 (PDT) Received: from dog by clipper.cs.kiev.ua with uucp id m0udRUu-00050LC; Tue, 9 Jul 96 04:21 WET DST Received: (from dk@localhost) by dog.farm.org (8.7.5/dk#3) id RAA09331; Mon, 8 Jul 1996 17:59:04 -0400 (EDT) Date: Mon, 8 Jul 1996 17:59:04 -0400 (EDT) From: Dmitry Kohmanyuk Message-Id: <199607082159.RAA09331@dog.farm.org> To: mbarkah@hemi.com (Ade Barkah) Cc: hackers@freebsd.org Subject: Re: NFS install problem with 2.2-960612-SNAP, motd, etc. Newsgroups: cs-monolit.gated.lists.freebsd.hackers Organization: FARM Computing Association Reply-To: dk+@ua.net X-Newsreader: TIN [version 1.2 PL2] Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk In article <199606200510.XAA19984@hemi.com> you wrote: > rc.local has the following code in it: > | T=/tmp/_motd ... > | uname -v | sed ... > $T > | ... > | cp $T /etc/motd > The above is extremely annoying. =-) Is there a good reason to keep > such code in rc.local ? Can we get rid of it ? Please ? =-) I can > just think of all the poor FreeBSD newcomers who can't for the life > of them figure out why their /etc/motd keeps on dissappearing. Over- > writing user files is morally bad, anyways. it is not disappearing; there is just some little magic insisting on giving user an idea of the system s?he have just logged in ;-) I would comment on it line-by-line: T=/tmp/_motd # a name for the scratch file rm -f $T # delete it uname -v | sed -e '...[long]...' > $T # put massaged uname output to it echo "" >> $T # append a line to it sed '1,/^$/d' < /etc/motd >> $T # append old motd but its begginning # up to the first empty line to it cp $T /etc/motd # copy it back to /etc/motd chmod 644 /etc/motd # fix perms rm -f $T # remove scarch file the only bad possibility arising from this is: when you put something into /etc/motd and _remove_ first FreeBSD id line, all text from the beginning of /etc/motd to the first empty line (or to the end of file, if there isn't an empty line there) would be replaced. (if file starts with empty line, text until _second_ empty line would be lost.) I can consider this a suboptimal behaviour, though. (Should we put `Do not remove this tag under penalty of law' into manual page for /etc/motd? ) changing sed '1,/^$/d' to sed '/^FreeBSD /,/^$/d' can probably make anyone happy, though. -- "'Programming' is a four-letter word." --Craig Bruce