1#!/bin/sh 2# 3# $FreeBSD$ 4# 5 6# PROVIDE: motd 7# REQUIRE: mountcritremote 8# BEFORE: LOGIN 9 10. /etc/rc.subr 11 12name="motd" 13desc="Update /etc/motd" 14rcvar="update_motd" 15start_cmd="motd_start" 16stop_cmd=":" 17 18PERMS="644" 19 20motd_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 49load_rc_config $name 50run_rc_command "$1" 51