#!/bin/sh -e

###########################################################################
# /usr/bin/update-motd
#
# A convenient wrapper for dynamically generating a message-of-the-day by
# running each script in /etc/update-motd.d, concatenating their output,
# and printing on interactive login
#
# Copyright (C) 2009 Canonical Ltd.
#  * Original: Aug 2008 - Dustin Kirkland <kirkland@canonical.com>
#  * Rewritten: Jul 2009 - Dustin Kirkland <kirkland@canonical.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# On Debian GNU/Linux systems, the complete text of the GNU General
# Public License can be found in `/usr/share/common-licenses/GPL'.
###########################################################################

FLAG="$HOME/.cache/motd.legal-displayed"
if [ ! -e "$FLAG" ] && [ -r /etc/legal ]; then
        cat /etc/legal
	install -D /dev/null -m 644 "$FLAG"
fi
# Run the system-defined update-motd dynamic scripts
run-parts --lsbsysinit /etc/update-motd.d 2>/dev/null
