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