1#!/bin/sh 2# 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 $ 5# $DragonFly: src/etc/rc.d/motd,v 1.9 2004/04/08 17:35:22 dillon Exp $ 6# 7 8# PROVIDE: motd 9# REQUIRE: mountcritremote 10# BEFORE: LOGIN 11# KEYWORD: DragonFly 12 13. /etc/rc.subr 14 15name="motd" 16rcvar="update_motd" 17start_cmd="motd_start" 18stop_cmd=":" 19PERMS="644" 20 21motd_start() 22{ 23 # Update kernel info in /etc/motd 24 # Must be done *before* interactive logins are possible 25 # to prevent possible race conditions. 26 # 27 echo "Updating motd." 28 if [ ! -f /etc/motd ]; then 29 install -c -o root -g wheel -m ${PERMS} /dev/null /etc/motd 30 fi 31 T1=`mktemp -t motd` 32 awk 'NR == 1{if ($1 == "DragonFly") {print} else {exit 1}}' < /etc/motd > $T1 && { 33 34 T2=`mktemp -t motd` 35 uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T2} 36 cmp -s $T1 $T2 || { 37 awk '{if (NR == 1) {next} else {print}}' < /etc/motd >> ${T2} 38 cp $T2 /etc/motd 39 chmod ${PERMS} /etc/motd 40 rm -f $T2 41 } 42 } 43 rm -f $T1 $T2 44} 45load_rc_config $name 46run_rc_command "$1" 47