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, 4 months ago) by eirikn
Branches: MAIN
CVS tags: HEAD
 * Indentation cleanup

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