2001-06-16 07:16:14 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2002-06-13 22:14:37 +00:00
|
|
|
# $FreeBSD$
|
2001-06-16 07:16:14 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: motd
|
2019-07-20 20:56:31 +00:00
|
|
|
# REQUIRE: mountcritremote FILESYSTEMS
|
2002-06-13 22:14:37 +00:00
|
|
|
# BEFORE: LOGIN
|
2001-06-16 07:16:14 +00:00
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
|
|
|
name="motd"
|
2019-07-20 20:56:31 +00:00
|
|
|
desc="Update /var/run/motd"
|
2001-06-16 07:16:14 +00:00
|
|
|
rcvar="update_motd"
|
|
|
|
start_cmd="motd_start"
|
|
|
|
stop_cmd=":"
|
|
|
|
|
2019-07-20 20:56:31 +00:00
|
|
|
COMPAT_MOTD="/etc/motd"
|
|
|
|
TARGET="/var/run/motd"
|
|
|
|
TEMPLATE="/etc/motd.template"
|
2003-10-13 08:44:07 +00:00
|
|
|
PERMS="644"
|
2002-06-13 22:14:37 +00:00
|
|
|
|
2001-06-16 07:16:14 +00:00
|
|
|
motd_start()
|
|
|
|
{
|
2019-07-20 20:56:31 +00:00
|
|
|
# Update kernel info in /var/run/motd
|
2001-06-16 07:16:14 +00:00
|
|
|
# Must be done *before* interactive logins are possible
|
|
|
|
# to prevent possible race conditions.
|
|
|
|
#
|
2009-10-10 22:17:03 +00:00
|
|
|
check_startmsgs && echo -n 'Updating motd:'
|
2019-07-20 20:56:31 +00:00
|
|
|
if [ ! -f "${TEMPLATE}" ]; then
|
|
|
|
# Create missing template from existing regular motd file, if
|
|
|
|
# one exists.
|
|
|
|
if [ -f "${COMPAT_MOTD}" ]; then
|
|
|
|
sed '1{/^FreeBSD.*/{d;};};' "${COMPAT_MOTD}" > "${TEMPLATE}"
|
|
|
|
chmod $PERMS "${TEMPLATE}"
|
|
|
|
rm -f "${COMPAT_MOTD}"
|
|
|
|
else
|
|
|
|
# Otherwise, create an empty template file.
|
|
|
|
install -c -o root -g wheel -m ${PERMS} /dev/null "${TEMPLATE}"
|
|
|
|
fi
|
|
|
|
# Provide compatibility symlink:
|
|
|
|
if [ ! -h "${COMPAT_MOTD}" ]; then
|
|
|
|
ln -sF "${TARGET}" "${COMPAT_MOTD}"
|
|
|
|
fi
|
2003-10-13 08:44:07 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
T=`mktemp -t motd`
|
|
|
|
uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T}
|
2019-07-20 20:56:31 +00:00
|
|
|
cat "${TEMPLATE}" >> ${T}
|
|
|
|
|
|
|
|
install -C -o root -g wheel -m "${PERMS}" "$T" "${TARGET}"
|
|
|
|
rm -f "$T"
|
2003-10-13 08:44:07 +00:00
|
|
|
|
2009-10-10 22:17:03 +00:00
|
|
|
check_startmsgs && echo '.'
|
2001-06-16 07:16:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|