motd revision 99609
1#!/bin/sh 2# 3# $NetBSD: motd,v 1.5 2000/09/19 13:04:38 lukem Exp $ 4# $FreeBSD: head/etc/rc.d/motd 99609 2002-07-08 21:04:16Z gordon $ 5# 6 7# PROVIDE: motd 8# REQUIRE: mountcritremote 9# BEFORE: LOGIN 10# KEYWORD: FreeBSD NetBSD 11 12. /etc/rc.subr 13 14name="motd" 15rcvar="update_motd" 16start_cmd="motd_start" 17stop_cmd=":" 18 19case `${CMD_OSTYPE}` in 20FreeBSD) 21 T=`mktemp /tmp/_motd.XXXXXX` 22 PERMS="644" 23 ;; 24NetBSD) 25 T="/etc/_motd" 26 PERMS="664" 27 ;; 28esac 29 30motd_start() 31{ 32 # Update kernel info in /etc/motd 33 # Must be done *before* interactive logins are possible 34 # to prevent possible race conditions. 35 # 36 echo "Updating motd." 37 if [ ! -f /etc/motd ]; then 38 install -c -o root -g wheel -m ${PERMS} /dev/null /etc/motd 39 fi 40 41 case `${CMD_OSTYPE}` in 42 FreeBSD) 43 uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T} 44 awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T} 45 ;; 46 NetBSD) 47 sysctl -n kern.version | while read i; do echo $i; break; done > $T 48 sed '1{/^NetBSD.*/{d;};};' < /etc/motd >> $T 49 ;; 50 esac 51 cmp -s $T /etc/motd || { 52 cp $T /etc/motd 53 chmod ${PERMS} /etc/motd 54 } 55 rm -f $T 56} 57 58load_rc_config $name 59run_rc_command "$1" 60