motd revision 197947
178344Sobrien#!/bin/sh 278344Sobrien# 398184Sgordon# $FreeBSD: head/etc/rc.d/motd 197947 2009-10-10 22:17:03Z dougb $ 478344Sobrien# 578344Sobrien 678344Sobrien# PROVIDE: motd 778344Sobrien# REQUIRE: mountcritremote 898184Sgordon# BEFORE: LOGIN 978344Sobrien 1078344Sobrien. /etc/rc.subr 1178344Sobrien 1278344Sobrienname="motd" 1378344Sobrienrcvar="update_motd" 1478344Sobrienstart_cmd="motd_start" 1578344Sobrienstop_cmd=":" 1678344Sobrien 17121068SdougbPERMS="644" 1898184Sgordon 1978344Sobrienmotd_start() 2078344Sobrien{ 2178344Sobrien # Update kernel info in /etc/motd 2278344Sobrien # Must be done *before* interactive logins are possible 2378344Sobrien # to prevent possible race conditions. 2478344Sobrien # 25197947Sdougb check_startmsgs && echo -n 'Updating motd:' 2678344Sobrien if [ ! -f /etc/motd ]; then 2798184Sgordon install -c -o root -g wheel -m ${PERMS} /dev/null /etc/motd 2878344Sobrien fi 2998184Sgordon 30121068Sdougb if [ ! -w /etc/motd ]; then 31179945Smtm echo ' /etc/motd is not writable, update failed.' 32121068Sdougb return 33121068Sdougb fi 34121068Sdougb 35121068Sdougb T=`mktemp -t motd` 36121068Sdougb uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T} 37121068Sdougb awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T} 38121068Sdougb 3998184Sgordon cmp -s $T /etc/motd || { 4098184Sgordon cp $T /etc/motd 4198184Sgordon chmod ${PERMS} /etc/motd 4298184Sgordon } 4378344Sobrien rm -f $T 44121068Sdougb 45197947Sdougb check_startmsgs && echo '.' 4678344Sobrien} 4778344Sobrien 4878344Sobrienload_rc_config $name 4978344Sobrienrun_rc_command "$1" 50