Index: libexec/rc/rc.d/motd =================================================================== --- libexec/rc/rc.d/motd +++ libexec/rc/rc.d/motd @@ -4,17 +4,20 @@ # # PROVIDE: motd -# REQUIRE: mountcritremote +# REQUIRE: mountcritremote FILESYSTEMS # BEFORE: LOGIN . /etc/rc.subr name="motd" -desc="Update /etc/motd" +desc="Update /var/run/motd" rcvar="update_motd" start_cmd="motd_start" stop_cmd=":" +COMPAT_MOTD="/etc/motd" +TARGET="/var/run/motd" +TEMPLATE="/etc/motd.template" PERMS="644" motd_start() @@ -24,28 +27,36 @@ # to prevent possible race conditions. # check_startmsgs && echo -n 'Updating motd:' - if [ ! -f /etc/motd ]; then - install -c -o root -g wheel -m ${PERMS} /dev/null /etc/motd + if [ ! -f "${TEMPLATE}" ]; then + # Create missing template from existing regular motd file, if + # one exists. + if [ -f "${COMPAT_MOTD}" ]; then + mv -f "${COMPAT_MOTD}" ${TEMPLATE} + 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 + [ -e "${COMPAT_MOTD}" ] && rm -f "${COMPAT_MOTD}" + ln -s "${TARGET}" "${COMPAT_MOTD}" + fi + fi + if [ ! -f "${TEMPLATE}" ]; then + install -c -o root -g wheel -m ${PERMS} /dev/null "${TARGET}" fi - if [ ! -w /etc/motd ]; then - echo ' /etc/motd is not writable, update failed.' + if [ ! -w "${TARGET}" ]; then + echo " ${TARGET} is not writable, update failed." return fi T=`mktemp -t motd` uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T} - awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T} - - if ! cmp -s $T /etc/motd; then - mv -f $T /etc/.motd.tmp - fsync /etc/.motd.tmp - mv -f /etc/.motd.tmp /etc/motd - chmod ${PERMS} /etc/motd - fsync /etc - else - rm -f $T - fi + awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < "${TEMPLATE}" >> ${T} + + install -C -o root -g wheel -m "${PERMS}" "$T" "${TARGET}" + rm -f "$T" check_startmsgs && echo '.' } Index: usr.bin/login/Makefile =================================================================== --- usr.bin/login/Makefile +++ usr.bin/login/Makefile @@ -3,7 +3,7 @@ .include -CONFS= fbtab login.conf motd login.access +CONFS= fbtab login.conf motd.template login.access PROG= login SRCS= login.c login_fbtab.c CFLAGS+=-DLOGALL Index: usr.bin/login/motd =================================================================== --- /dev/null +++ usr.bin/login/motd @@ -1,21 +0,0 @@ -FreeBSD ?.?.? (UNKNOWN) - -Welcome to FreeBSD! - -Release Notes, Errata: https://www.FreeBSD.org/releases/ -Security Advisories: https://www.FreeBSD.org/security/ -FreeBSD Handbook: https://www.FreeBSD.org/handbook/ -FreeBSD FAQ: https://www.FreeBSD.org/faq/ -Questions List: https://lists.FreeBSD.org/mailman/listinfo/freebsd-questions/ -FreeBSD Forums: https://forums.FreeBSD.org/ - -Documents installed with the system are in the /usr/local/share/doc/freebsd/ -directory, or can be installed later with: pkg install en-freebsd-doc -For other languages, replace "en" with a language code like de or fr. - -Show the version of FreeBSD installed: freebsd-version ; uname -a -Please include that output and any error messages when posting questions. -Introduction to manual pages: man man -FreeBSD directory layout: man hier - -Edit /etc/motd to change this login announcement.