motd revision 98184
178344Sobrien#!/bin/sh 278344Sobrien# 378344Sobrien# $NetBSD: motd,v 1.5 2000/09/19 13:04:38 lukem Exp $ 498184Sgordon# $FreeBSD: head/etc/rc.d/motd 98184 2002-06-13 22:14:37Z gordon $ 578344Sobrien# 678344Sobrien 778344Sobrien# PROVIDE: motd 878344Sobrien# REQUIRE: mountcritremote 998184Sgordon# BEFORE: LOGIN 1098184Sgordon# KEYWORD: FreeBSD NetBSD 1178344Sobrien 1278344Sobrien. /etc/rc.subr 1378344Sobrien 1478344Sobrienname="motd" 1578344Sobrienrcvar="update_motd" 1678344Sobrienstart_cmd="motd_start" 1778344Sobrienstop_cmd=":" 1878344Sobrien 1998184Sgordoncase `${CMD_OSTYPE}` in 2098184SgordonFreeBSD) 2198184Sgordon T=`mktemp /tmp/_motd.XXXXXX` 2298184Sgordon PERMS="644" 2398184Sgordon ;; 2498184SgordonNetBSD) 2598184Sgordon T="/etc/_motd" 2698184Sgordon PERMS="664" 2798184Sgordon ;; 2898184Sgordonesac 2998184Sgordon 3078344Sobrienmotd_start() 3178344Sobrien{ 3278344Sobrien # Update kernel info in /etc/motd 3378344Sobrien # Must be done *before* interactive logins are possible 3478344Sobrien # to prevent possible race conditions. 3578344Sobrien # 3678344Sobrien echo "Updating motd." 3778344Sobrien if [ ! -f /etc/motd ]; then 3898184Sgordon install -c -o root -g wheel -m ${PERMS} /dev/null /etc/motd 3978344Sobrien fi 4098184Sgordon 4198184Sgordon case `${CMD_OSTYPE}` in 4298184Sgordon FreeBSD) 4398184Sgordon uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T} 4498184Sgordon awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T} 4598184Sgordon ;; 4698184Sgordon NetBSD) 4798184Sgordon sysctl -n kern.version | while read i; do echo $i; break; done > $T 4898184Sgordon sed '1{/^NetBSD.*/{d;};};' < /etc/motd >> $T 4998184Sgordon ;; 5098184Sgordon esac 5198184Sgordon cmp -s $T /etc/motd || { 5298184Sgordon echo T=$T 5398184Sgordon cp $T /etc/motd 5498184Sgordon chmod ${PERMS} /etc/motd 5598184Sgordon } 5678344Sobrien rm -f $T 5778344Sobrien} 5878344Sobrien 5978344Sobrienload_rc_config $name 6078344Sobrienrun_rc_command "$1" 61