motd revision 296373
1#!/bin/sh 2# 3# $FreeBSD: releng/10.3/etc/rc.d/motd 197947 2009-10-10 22:17:03Z dougb $ 4# 5 6# PROVIDE: motd 7# REQUIRE: mountcritremote 8# BEFORE: LOGIN 9 10. /etc/rc.subr 11 12name="motd" 13rcvar="update_motd" 14start_cmd="motd_start" 15stop_cmd=":" 16 17PERMS="644" 18 19motd_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 48load_rc_config $name 49run_rc_command "$1" 50