]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - etc/rc.d/motd
This commit was generated by cvs2svn to compensate for changes in r157001,
[FreeBSD/FreeBSD.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$
5 #
6
7 # PROVIDE: motd
8 # REQUIRE: mountcritremote
9 # BEFORE:  LOGIN
10
11 . /etc/rc.subr
12
13 name="motd"
14 rcvar="update_motd"
15 start_cmd="motd_start"
16 stop_cmd=":"
17
18 PERMS="644"
19
20 motd_start()
21 {
22         #       Update kernel info in /etc/motd
23         #       Must be done *before* interactive logins are possible
24         #       to prevent possible race conditions.
25         #
26         echo -n 'Updating motd'
27         if [ ! -f /etc/motd ]; then
28                 install -c -o root -g wheel -m ${PERMS} /dev/null /etc/motd
29         fi
30
31         if [ ! -w /etc/motd ]; then
32                 echo ' ... /etc/motd is not writable, update failed.'
33                 return
34         fi
35
36         T=`mktemp -t motd`
37         uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T}
38         awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T}
39
40         cmp -s $T /etc/motd || {
41                 cp $T /etc/motd
42                 chmod ${PERMS} /etc/motd
43         }
44         rm -f $T
45
46         echo .
47 }
48
49 load_rc_config $name
50 run_rc_command "$1"