Deleted Added
full compact
motd (117088) motd (121068)
1#!/bin/sh
2#
3# $NetBSD: motd,v 1.5 2000/09/19 13:04:38 lukem Exp $
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 117088 2003-06-30 22:06:26Z mtm $
4# $FreeBSD: head/etc/rc.d/motd 121068 2003-10-13 08:44:07Z dougb $
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
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 ${OSTYPE} in
20FreeBSD)
21 PERMS="644"
22 ;;
23NetBSD)
24 PERMS="664"
25 ;;
26esac
19PERMS="644"
27
28motd_start()
29{
30 # Update kernel info in /etc/motd
31 # Must be done *before* interactive logins are possible
32 # to prevent possible race conditions.
33 #
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 #
34 echo "Updating motd."
27 echo -n 'Updating motd'
35 if [ ! -f /etc/motd ]; then
36 install -c -o root -g wheel -m ${PERMS} /dev/null /etc/motd
37 fi
38
28 if [ ! -f /etc/motd ]; then
29 install -c -o root -g wheel -m ${PERMS} /dev/null /etc/motd
30 fi
31
39 case ${OSTYPE} in
40 FreeBSD)
41 T=`mktemp -t motd`
42 uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T}
43 awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T}
44 ;;
45 NetBSD)
46 T='/etc/_motd'
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
32 if [ ! -w /etc/motd ]; then
33 echo ' ... /etc/motd is not writable, update failed.'
34 return
35 fi
36
37 T=`mktemp -t motd`
38 uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T}
39 awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T}
40
51 cmp -s $T /etc/motd || {
52 cp $T /etc/motd
53 chmod ${PERMS} /etc/motd
54 }
55 rm -f $T
41 cmp -s $T /etc/motd || {
42 cp $T /etc/motd
43 chmod ${PERMS} /etc/motd
44 }
45 rm -f $T
46
47 echo .
56}
57
58load_rc_config $name
59run_rc_command "$1"
48}
49
50load_rc_config $name
51run_rc_command "$1"