+2008-09-17 Dustin Kirkland <kirkland@canonical.com>
+ Updated release for inclusion in Ubuntu main;
+ simplified overall design, elminating the init
+ script and debconf configuration
+ Release version 1.6
+
+2008-09-15 Dustin Kirkland <kirkland@canonical.com>
+ Bugfix release
+ Release version 1.5
+
+2008-09-15 Dustin Kirkland <kirkland@canonical.com>
+ Bugfix release
+ Release version 1.4
+
+2008-09-15 Dustin Kirkland <kirkland@canonical.com>
+ Bugfix release
+ Release version 1.3
+
+2008-09-15 Dustin Kirkland <kirkland@canonical.com>
+ Bugfix release
+ Release version 1.2
+
+2008-08-22 Dustin Kirkland <kirkland@canonical.com>
+ Bugfix release
+ Release version 1.1
+
2008-08-13 Dustin Kirkland <kirkland@canonical.com>
Initial release
Release version 1.0
+update-motd (1.6) intrepid; urgency=low
+
+ * ChangeLog: fill in details of the last few releases
+ * debian/config: purge debconf configuration
+ * debian/dirs: purge usr/share/update-motd and etc/default/update-motd
+ * debian/init.d: purge init script
+ * debian/install: install cronjob directly to etc/cron.d
+ * debian/po/*: purge translation of template
+ * debian/postinst: purge debconf configuration, remove init script left by
+ older update-motd version (<1.6)
+ * debian/rules: purge po update, install the cronjob into place, purge init
+ script installation
+ * debian/templates: purge debconf questions
+ * update-motd:
+ - add usage statement
+ - add options for --disable, --enable
+ - adjust error messages
+ - do no execute if the .disabled file exists
+ - write the last-run timestamp to the .lastrun file
+ * update-motd.1: adjust manpage to match new operation
+ * update-motd.cron: adjust header comment to match new operation
+ * update-motd.default: purge etc/default file
+
+ -- Dustin Kirkland <kirkland@ubuntu.com> Wed, 17 Sep 2008 21:14:18 -0500
+
update-motd (1.5) intrepid; urgency=low
* update-motd: print error messages to stderr, rather than stdout,
+++ /dev/null
-#!/bin/sh
-
-PACKAGE=update-motd
-
-CONFIGFILE=/etc/default/$PACKAGE
-set -e
-. /usr/share/debconf/confmodule
-
-# Load config file, if it exists.
-if [ -e $CONFIGFILE ]; then
- . $CONFIGFILE || true
- FREQ_IN_MIN=`grep "^\*\/" /etc/cron.d/update-motd 2>/dev/null| sed "s/^\*\///" | sed "s/\s.*//"`
- [ -z "$FREQ_IN_MIN" ] && FREQ_IN_MIN=10
-
- # Store values from config file into
- # debconf db.
-
- db_set $PACKAGE/enable $RUN
- db_set $PACKAGE/freq-in-min $FREQ_IN_MIN
-
-fi
-
-# Ask questions.
-db_input medium $PACKAGE/enable || true
-db_go
-db_get $PACKAGE/enable
-RUN="${RET:-true}"
-if [ "$RUN" = "true" ]; then
- TRIES=5
- for i in `seq 1 $TRIES`; do
- db_input medium $PACKAGE/freq-in-min || true
- db_go
- db_get $PACKAGE/freq-in-min
- FREQ_IN_MIN="${RET:-0}"
- if [ "$FREQ_IN_MIN" -ge 1 ] && [ "$FREQ_IN_MIN" -le 59 ]; then
- break
- fi
- if [ "$i" = "$TRIES" ]; then
- # After a few tries, default to 10
- FREQ_IN_MIN=10
- fi
- done
-fi
-db_go
-usr/share/update-motd
-etc/default
+etc/cron.d
etc/update-motd.d
+var/lib/update-motd
+++ /dev/null
-#!/bin/sh
-#
-# Copyright (c) 2008 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, either version 3 of the License, or
-# (at your option) any later version.
-#
-# 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 systems, the complete text of the GNU General Public
-# License, version 3, can be found in /usr/share/common-licenses/GPL-3.
-#
-### BEGIN INIT INFO
-# Provides: update-motd
-# Required-Start: update-motd
-# Required-Stop:
-# Should-Start:
-# Should-Stop:
-# Default-Start: 2 3 4 5
-# Default-Stop: 1
-# Short-Description: Update the MOTD
-# Description: Update the MOTD
-### END INIT INFO
-
-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-
-DAEMON=/usr/sbin/update-motd
-NAME=update-motd
-DESC="Update Message-of-the-Day"
-CRON=/etc/cron.d/$NAME
-ENABLED=/var/run/$NAME.enabled
-
-test -x $DAEMON || exit 0
-
-. /lib/lsb/init-functions
-
-# Include default file if available
-if [ -f /etc/default/$NAME ] ; then
- . /etc/default/$NAME
-fi
-
-set -e
-
-case "$1" in
- start)
- if [ "$RUN" != "yes" ]; then
- log_warning_msg "$NAME is disabled (see /etc/default/$NAME)"
- exit 0
- fi
- if [ ! -f "$CRON" ]; then
- log_warning_msg "$NAME is missing its cron job"
- exit 0
- fi
- log_daemon_msg "Starting $NAME"
- # Run update-motd immediately
- touch $ENABLED
- $DAEMON && rc=0 || rc=$?
- if [ "$rc" = 0 ]; then
- log_end_msg 0
- else
- log_end_msg 1
- fi
- exit "$rc"
- ;;
- stop)
- log_daemon_msg "Stopping $NAME"
- rm -f "$ENABLED" && rc=0 || rc=$?
- if [ "$rc" = "0" ]; then
- log_end_msg 0
- else
- log_end_msg 1
- fi
- exit "$rc"
- ;;
- restart|reload|force-reload)
- $0 stop
- $0 start
- exit "$?"
- ;;
- refresh)
- # Run /usr/bin/update-motd immediately
- log_daemon_msg "Running $NAME"
- $DAEMON && rc=0 || rc=$?
- if [ "$rc" = "0" ]; then
- log_end_msg 0
- else
- log_end_msg 1
- fi
- exit "$rc"
- ;;
- status)
- # Determine if cronjob and run file exist
- if [ -f "$CRON" ] && [ -f "$ENABLED" ]; then
- log_success_msg "$NAME is running."
- exit 0
- else
- log_failure_msg "$NAME is not running."
- exit 1
- fi
- ;;
- *)
- echo "Usage: $0 {start|stop|reload|refresh|force-reload|status}" >&2
- exit "1"
- ;;
-esac
-
-exit 0
update-motd usr/sbin
-update-motd.cron usr/share/update-motd
+++ /dev/null
-[type: gettext/rfc822deb] templates
+++ /dev/null
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: update-motd@packages.debian.org\n"
-"POT-Creation-Date: 2008-09-15 16:31-0500\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=CHARSET\n"
-"Content-Transfer-Encoding: 8bit\n"
-
-#. Type: boolean
-#. Description
-#: ../templates:1001
-msgid "Do you want update-motd to automatically update the system MOTD?"
-msgstr ""
-
-#. Type: boolean
-#. Description
-#: ../templates:1001
-msgid ""
-"The update-motd utility can automatically run all executables in /etc/update-"
-"motd.d, regularly appending their results to the MOTD."
-msgstr ""
-
-#. Type: string
-#. Description
-#: ../templates:2001
-msgid "Frequency should update-motd run (every 1 to 59 minutes):"
-msgstr ""
-
-#. Type: string
-#. Description
-#: ../templates:2001
-msgid ""
-"The MOTD status is updated in a cron job, that can run as frequently as "
-"every minute, or as infrequently as desired. A higher frequency will "
-"negatively affect the overall system load."
-msgstr ""
-
-#. Type: string
-#. Description
-#: ../templates:2001
-msgid "The default is for the MOTD status to be updated every 10 minutes."
-msgstr ""
#!/bin/sh
-# postinst script for update-motd
-#
-# see: dh_installdeb(1)
-
-PACKAGE=update-motd
-
-. /usr/share/debconf/confmodule
set -e
case "$1" in
- configure)
- DEBIANCONFIG=/etc/default/$PACKAGE
-
- # Update RUN=yes|no
- [ -f $DEBIANCONFIG ] && . $DEBIANCONFIG
- db_get $PACKAGE/enable
- RUN="${RET:-true}"
-
- case $RUN in
- "true"|"yes"|"1")
- RUN='yes'
- ;;
- *)
- RUN='no'
- ;;
- esac
- sed -i "s/^\s*RUN=.*/RUN=$RUN/" $DEBIANCONFIG
-
- CRONCONFIG=/etc/cron.d/$PACKAGE
- if [ "$RUN" = "yes" ]; then
- # Update cronjob frequency
- db_get $PACKAGE/freq-in-min
- FREQ_IN_MIN="${RET:-10}"
- sed "s/FREQ_IN_MIN/$FREQ_IN_MIN/" /usr/share/$PACKAGE/$PACKAGE.cron > $CRONCONFIG
- else
- # Remove the cronjob
- rm -f $CRONCONFIG || true
+ configure|reconfigure)
+ if dpkg --compare-versions "$2" lt "1.6"; then
+ # init script from older update-motd's should be removed
+ rm -f /etc/init.d/update-motd
fi
-
- db_stop
;;
esac
-# dh_installdeb will replace this with shell code automatically
-# generated by other debhelper scripts.
-
#DEBHELPER#
-
-exit 0
dh_testroot
rm -f build-stamp configure-stamp
dh_clean
- debconf-updatepo
build:
@touch build-stamp
dh_testroot
dh_clean -k
dh_installdirs
- install -o root -g root -m 644 update-motd.default debian/update-motd/etc/default/update-motd
+ install -o root -g root -m 644 update-motd.cron debian/update-motd/etc/cron.d/update-motd
# Build architecture-independent files here.
binary-indep: install
dh_install
dh_installdebconf
# Start after bootmisc.sh
- dh_installinit -- start 81 2 3 4 5 . stop 19 1 .
dh_installcron
dh_installman update-motd.1
dh_compress
+++ /dev/null
-Template: update-motd/enable
-Type: boolean
-Default: true
-_Description: Do you want update-motd to automatically update the system MOTD?
- The update-motd utility can automatically run all executables in
- /etc/update-motd.d, regularly appending their results to the MOTD.
-
-Template: update-motd/freq-in-min
-Type: string
-Default: 10
-_Description: Frequency should update-motd run (every 1 to 59 minutes):
- The MOTD status is updated in a cron job, that can run as frequently as
- every minute, or as infrequently as desired. A higher frequency will
- negatively affect the overall system load.
- .
- The default is for the MOTD status to be updated every 10 minutes.
SKEL=/etc/motd.tail
REAL=/var/run/motd
DIR=/etc/$NAME.d
-ENABLED=/var/run/$NAME.enabled
+DISABLED=/var/lib/$NAME/disabled
+LASTRUN=/var/run/$NAME.lastrun
FORCE=0
if [ -f "$NEW" ]; then
- # If /var/run/motd.new exists, then another instance of update-motd
- # is running
+ # If /var/run/motd.new exists, another instance is running
echo "Another update-motd is running ($NEW exists)" 1>&2
exit 0
fi
+usage() {
+ echo "Usage:
+
+ update-motd [--disable|--enable|--force]
+
+ --disable - will prevent update-motd from running; useful for
+ temporarily disabling automatic updates of /etc/motd
+ by the /etc/cron.d/update-motd cronjob.
+ --enable - will allow update-motd to run; useful for enabling
+ automatic updates of /etc/motd through the
+ /etc/cron.d/update-motd cronjob.
+ --force - will override a disabled update-motd for a single
+ update of /etc/motd.
+" 1>&2
+}
+
+FORCE=0
for arg in $@; do
case $arg in
- "--force")
+ "--disable"|"-d")
+ touch "$DISABLED"
+ echo "$NAME is now disabled." 1>&2
+ exit 0
+ ;;
+ "--enable"|"-e")
+ rm -f "$DISABLED"
+ echo "$NAME is now enabled." 1>&2
+ exit 0
+ ;;
+ "--force"|"-f")
FORCE=1
;;
+ *)
+ usage
+ exit 1
+ ;;
esac
done
-if [ ! -f "$ENABLED" ] && [ "$FORCE" != "1" ]; then
- echo "$NAME is disabled. You can run:" 1>&2
- echo " * $NAME --force" 1>&2
- echo " * service update-motd start" 1>&2
- echo " * dpkg-reconfigure update-motd" 1>&2
+if [ -f "$DISABLED" ] && [ "$FORCE" != "1" ]; then
+ echo "$NAME is currently disabled.
+You might try:
+ * update-motd --enable
+ * update-motd --force" 1>&2
exit 1
fi
# Move the new motd into place
mv -f $NEW $REAL
+
+# Write out the current timestamp to the lastrun file
+echo -n "Last run completed: " > "$LASTRUN"
+date >> "$LASTRUN"
.IX Title "UPDATE-MOTD 1"
-.TH UPDATE-MOTD 1 "2008-08-13" update-motd update-motd
+.TH UPDATE-MOTD 1 "2008-09-17" update-motd update-motd
.SH "NAME"
update\-motd \- Automatically update the message-of-the-day (MOTD)
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
-update\-motd [\-\-force]
+update\-motd [\-\-disable|\-\-enable|\-\-force]
+
+.SH "OPTIONS"
+.IX Header "OPTIONS"
+.TP
+\fB\-\-disable\fP
+Prevent update-motd from running. This is useful for temporarily disabling automatic updates of \fI/etc/motd\fP by the \fI/etc/cron.d/update-motd\fP cronjob. Note that this exits immediately after disabling, and does update the MOTD.
+.TP
+\fB\-\-enable\fP
+Allow update-motd to run. This is useful for enabling automatic updates of \fI/etc/motd\fP through the \fI/etc/cron.d/update-motd\fP cronjob. Note that this exits immediately after enabling, and does update the MOTD.
+.TP
+\fB\-\-force\fP
+Override a disabled update-motd for a single, immediate update of \fI/etc/motd\fP.
+
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
-This script executes each script in \fI/etc/update-motd.d\fP in lexical order, concatenating the status with \fI/etc/motd.tail\fP, and writing the output to \fI/var/lib/motd\fP, which is usually a symbolic link to \fI/etc/motd\fP.
+This script executes each script in \fI/etc/update-motd.d/\fP in lexical order, concatenating the status with \fI/etc/motd.tail\fP, and writing the output to \fI/var/lib/motd\fP, which is usually a symbolic link to \fI/etc/motd\fP.
+
+Users and/or packages should add symlinks to \fI/etc/update-motd.d/\fP, prepended with a two-digit number to define the execution order, as obeyed by \fBrun-parts(8)\fP.
-Users and/or packages should add symlinks to \fI/etc/update-motd.d\fP, prepended with a two-digit number to define the execution order, as obeyed by \fBrun-parts(8)\fP.
+The update-motd script will not execute if the file \fI/var/lib/update-motd/disabled\fP exists. One can override this using the \fB--force\fP option. To permanently enable/disable \fBupdate-motd\fP, use:
+ $ sudo update-motd --enable
+ $ sudo update-motd --disable
-The update-motd script will only execute if the file \fI/var/run/update-motd.enabled\fP is present. One can override this using the \fB--force\fP option. To permanently enable/disable \fBupdate-motd\fP, use:
- $ sudo dpkg-reconfigure update-motd
+If enabled, timestamp of the last \fBupdate-motd\fP run will be written to \fI/var/run/update-motd.lastrun\fP.
.SH FILES
-\fI/etc/update-motd.d/\fP, \fI/etc/motd.tail\fP, \fI/var/run/motd\fP, \fI/var/run/update-motd.enabled\fP
+\fI/etc/cron.d/update-motd\fP, \fI/etc/update-motd.d/\fP, \fI/etc/motd.tail\fP, \fI/var/run/motd\fP, \fI/var/lib/update-motd/disabled\fP, \fI/var/run/update-motd.lastrun\fP
.SH "AUTHOR"
.IX Header "AUTHOR"
# /etc/cron.d/update-motd: crontab fragment for update-motd
#
-# THIS FILE IS AUTOMATICALLY GENERATED, YOU SHOULD NOT EDIT DIRECTLY.
-#
-# To change, use:
-# dpkg-reconfigure update-motd
-#
-# This updates the /etc/motd with a concatenation of output from each
-# script in /etc/update-motd.d
+# Running 'update-motd' dynamically generates the /etc/motd with
+# a concatenation of output from each script in /etc/update-motd.d.
-*/FREQ_IN_MIN * * * * root /usr/sbin/update-motd 2>/dev/null
+*/10 * * * * root /usr/sbin/update-motd 2>/dev/null
+++ /dev/null
-# update-motd Debian configuration
-#
-# You can run 'dpkg-reconfigure update-motd' to modify the values in this
-# file, if you want. You can also change the values here and changes will
-# be preserved.
-#
-# Do note that only the values are preserved; the rest of the file is
-# rewritten.
-#
-
-# RUN:
-# Should we actually run and update the MOTD?
-RUN=yes