File:  [DragonFly] / src / etc / rc.d / motd
Revision 1.4: download - view: text, annotated - select for diffs
Fri Dec 12 16:03:48 2003 UTC (10 years, 10 months ago) by eirikn
Branches: MAIN
CVS tags: HEAD
 * Indentation cleanup

#!/bin/sh
#
# $NetBSD: motd,v 1.5 2000/09/19 13:04:38 lukem Exp $
# $FreeBSD: src/etc/rc.d/motd,v 1.6 2003/06/30 22:06:26 mtm Exp $
# $DragonFly: src/etc/rc.d/motd,v 1.4 2003/12/12 16:03:48 eirikn Exp $
#

# PROVIDE: motd
# REQUIRE: mountcritremote
# BEFORE:  LOGIN
# KEYWORD: DragonFly FreeBSD NetBSD

. /etc/rc.subr

name="motd"
rcvar="update_motd"
start_cmd="motd_start"
stop_cmd=":"

case ${OSTYPE} in
DragonFly)
	PERMS="644"
	;;
FreeBSD)
	PERMS="644"
	;;
NetBSD)
	PERMS="664"
	;;
esac

motd_start()
{
	#	Update kernel info in /etc/motd
	#	Must be done *before* interactive logins are possible
	#	to prevent possible race conditions.
	#
	echo "Updating motd."
	if [ ! -f /etc/motd ]; then
		install -c -o root -g wheel -m ${PERMS} /dev/null /etc/motd
	fi

	case ${OSTYPE} in
	DragonFly)
		T=`mktemp -t motd`
		uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T}
		awk '{if (NR == 1) {if ($1 == "DragonFly") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T}
		;;
	FreeBSD)
		T=`mktemp -t motd`
		uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T}
		awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T}
		;;
	NetBSD)
		T='/etc/_motd'
		sysctl -n kern.version | while read i; do echo $i; break; done > $T
		sed '1{/^NetBSD.*/{d;};};' < /etc/motd >> $T
		;;
	esac
	cmp -s $T /etc/motd || {
		cp $T /etc/motd
		chmod ${PERMS} /etc/motd
	}
	rm -f $T
}

load_rc_config $name
run_rc_command "$1"