update rcng to remove FreeBSD and NetBSD
[dragonfly.git] / etc / rc.d / motd
1 #!/bin/sh
2 #
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.5 2004/01/27 00:42:45 rob Exp $
6 #
7
8 # PROVIDE: motd
9 # REQUIRE: mountcritremote
10 # BEFORE:  LOGIN
11 # KEYWORD: DragonFly
12
13 . /etc/rc.subr
14
15 name="motd"
16 rcvar="update_motd"
17 start_cmd="motd_start"
18 stop_cmd=":"
19 PERMS="644"
20
21 motd_start()
22 {
23         #       Update kernel info in /etc/motd
24         #       Must be done *before* interactive logins are possible
25         #       to prevent possible race conditions.
26         #
27         echo "Updating motd."
28         if [ ! -f /etc/motd ]; then
29                 install -c -o root -g wheel -m ${PERMS} /dev/null /etc/motd
30         fi
31
32         T=`mktemp -t motd`
33         uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T}
34         awk '{if (NR == 1) {if ($1 == "DragonFly") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T}
35         cmp -s $T /etc/motd || {
36                 cp $T /etc/motd
37                 chmod ${PERMS} /etc/motd
38         }
39         rm -f $T
40 }
41
42 load_rc_config $name
43 run_rc_command "$1"