rc.conf: Add and document the missing root_rw_mount=YES
[dragonfly.git] / etc / rc.d / motd
blobcb29a149ca95d76ba17cf90d046495cdeb73df99
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 $
7 # PROVIDE: motd
8 # REQUIRE: mountcritremote
9 # BEFORE: LOGIN
11 . /etc/rc.subr
13 name="motd"
14 rcvar="update_motd"
15 start_cmd="motd_start"
16 stop_cmd=":"
18 motd_start()
20 # Update kernel info in /etc/motd
21 # Must be done *before* interactive logins are possible
22 # to prevent possible race conditions.
24 local target="/etc/motd"
25 local old new exp temp
27 echo "Updating motd."
28 if [ ! -f "${target}" ]; then
29 install -o root -g wheel -m 0644 /dev/null ${target}
32 old=$(awk '
33 NR == 1 {
34 if ($1 == "DragonFly") { print } else { exit 1 }
35 }' < ${target})
36 if [ $? -ne 0 ]; then
37 return # custom motd
40 exp='s@([^#]*) #(.* [1-2][0-9]{3}).*/([^/ ]+) *$@\1 (\3) #\2@'
41 new=$(uname -v | sed -E -e "${exp}")
42 if [ "${old}" != "${new}" ]; then
43 temp=$(mktemp -t motd)
44 printf '%s\n' "${new}" > ${temp}
45 tail -n +2 ${target} >> ${temp}
46 cat ${temp} > ${target}
47 rm -f ${temp}
51 load_rc_config $name
52 run_rc_command "$1"