]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - libexec/rc/rc.d/motd
Copy googletest 1.8.1 from ^/vendor/google/googletest/1.8.1 to .../contrib/googletest
[FreeBSD/FreeBSD.git] / libexec / rc / 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 desc="Update /etc/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         check_startmsgs && 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         check_startmsgs && echo '.'
47 }
48
49 load_rc_config $name
50 run_rc_command "$1"