1#!/bin/sh 2# 3# 4 5# PROVIDE: motd 6# REQUIRE: mountcritremote FILESYSTEMS 7# BEFORE: LOGIN 8 9. /etc/rc.subr 10 11name="motd" 12desc="Update /var/run/motd" 13rcvar="update_motd" 14start_cmd="motd_start" 15stop_cmd=":" 16 17COMPAT_MOTD="/etc/motd" 18TARGET="/var/run/motd" 19TEMPLATE="/etc/motd.template" 20PERMS="644" 21 22motd_start() 23{ 24 # Update kernel info in /var/run/motd 25 # Must be done *before* interactive logins are possible 26 # to prevent possible race conditions. 27 # 28 startmsg -n 'Updating motd:' 29 if [ ! -f "${TEMPLATE}" ]; then 30 # Create missing template from existing regular motd file, if 31 # one exists. 32 if [ -f "${COMPAT_MOTD}" ]; then 33 sed '1{/^FreeBSD.*/{d;};};' "${COMPAT_MOTD}" > "${TEMPLATE}" 34 chmod $PERMS "${TEMPLATE}" 35 rm -f "${COMPAT_MOTD}" 36 else 37 # Otherwise, create an empty template file. 38 install -c -o root -g wheel -m ${PERMS} /dev/null "${TEMPLATE}" 39 fi 40 fi 41 # Provide compatibility symlink: 42 if [ ! -h "${COMPAT_MOTD}" ]; then 43 ln -sF "${TARGET}" "${COMPAT_MOTD}" 44 fi 45 46 T=`mktemp -t motd` 47 uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\)$,\1 (\3) #\2,' \ 48 -e 's,^\([^ ]*\) \([^ ]*\) \([^ ]*\) \([^ ]*\)$,\1 \2 (\4) \3,' > ${T} 49 cat "${TEMPLATE}" >> ${T} 50 51 install -C -o root -g wheel -m "${PERMS}" "$T" "${TARGET}" 52 rm -f "$T" 53 54 startmsg '.' 55} 56 57load_rc_config $name 58run_rc_command "$1" 59