Bring in some miscellaneous changes from OpenBSD and point to an
[dragonfly/port-amd64.git] / etc / rc.d / motd
blob4804d65b1ecb6190a0265ad9d673edcbd8cfbcbb
1 #!/bin/sh
3 # $NetBSD: motd,v 1.5 2000/09/19 13:04:38 lukem Exp $
4 # $FreeBSD: src/etc/rc.d/motd,v 1.6 2003/06/30 22:06:26 mtm Exp $
5 # $DragonFly: src/etc/rc.d/motd,v 1.10 2005/11/19 21:47:32 swildner Exp $
8 # PROVIDE: motd
9 # REQUIRE: mountcritremote
10 # BEFORE: LOGIN
12 . /etc/rc.subr
14 name="motd"
15 rcvar="update_motd"
16 start_cmd="motd_start"
17 stop_cmd=":"
18 PERMS="644"
20 motd_start()
22 # Update kernel info in /etc/motd
23 # Must be done *before* interactive logins are possible
24 # to prevent possible race conditions.
26 echo "Updating motd."
27 if [ ! -f /etc/motd ]; then
28 install -c -o root -g wheel -m ${PERMS} /dev/null /etc/motd
30 T1=`mktemp -t motd`
31 awk 'NR == 1{if ($1 == "DragonFly") {print} else {exit 1}}' < /etc/motd > $T1 && {
33 T2=`mktemp -t motd`
34 uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T2}
35 cmp -s $T1 $T2 || {
36 awk '{if (NR == 1) {next} else {print}}' < /etc/motd >> ${T2}
37 cp $T2 /etc/motd
38 chmod ${PERMS} /etc/motd
39 rm -f $T2
42 rm -f $T1 $T2
44 load_rc_config $name
45 run_rc_command "$1"