From 9388095059da82fb4d171718cfc74c38b3fb58f9 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Fri, 19 Sep 2008 15:59:40 -0500 Subject: [PATCH] updated to released version 1.6 --- ChangeLog | 26 +++++++++ debian/changelog | 25 +++++++++ debian/config | 44 --------------- debian/dirs | 4 +- debian/init.d | 115 ---------------------------------------- debian/install | 1 - debian/po/POTFILES.in | 1 - debian/po/templates.pot | 52 ------------------ debian/postinst | 45 ++-------------- debian/rules | 4 +- debian/templates | 16 ------ update-motd | 53 ++++++++++++++---- update-motd.1 | 30 ++++++++--- update-motd.cron | 11 ++-- update-motd.default | 13 ----- 15 files changed, 128 insertions(+), 312 deletions(-) delete mode 100644 debian/config delete mode 100755 debian/init.d delete mode 100644 debian/po/POTFILES.in delete mode 100644 debian/po/templates.pot delete mode 100644 debian/templates delete mode 100644 update-motd.default diff --git a/ChangeLog b/ChangeLog index 1b59f7c..5fdc2fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +2008-09-17 Dustin Kirkland + 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 + Bugfix release + Release version 1.5 + +2008-09-15 Dustin Kirkland + Bugfix release + Release version 1.4 + +2008-09-15 Dustin Kirkland + Bugfix release + Release version 1.3 + +2008-09-15 Dustin Kirkland + Bugfix release + Release version 1.2 + +2008-08-22 Dustin Kirkland + Bugfix release + Release version 1.1 + 2008-08-13 Dustin Kirkland Initial release Release version 1.0 diff --git a/debian/changelog b/debian/changelog index f223b82..538ce45 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,28 @@ +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 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, diff --git a/debian/config b/debian/config deleted file mode 100644 index 84fd81c..0000000 --- a/debian/config +++ /dev/null @@ -1,44 +0,0 @@ -#!/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 diff --git a/debian/dirs b/debian/dirs index d658620..2793f9b 100644 --- a/debian/dirs +++ b/debian/dirs @@ -1,3 +1,3 @@ -usr/share/update-motd -etc/default +etc/cron.d etc/update-motd.d +var/lib/update-motd diff --git a/debian/init.d b/debian/init.d deleted file mode 100755 index 49a1a8c..0000000 --- a/debian/init.d +++ /dev/null @@ -1,115 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2008 Dustin Kirkland -# -# 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 . -# -# 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 diff --git a/debian/install b/debian/install index b14f078..fb297f6 100644 --- a/debian/install +++ b/debian/install @@ -1,2 +1 @@ update-motd usr/sbin -update-motd.cron usr/share/update-motd diff --git a/debian/po/POTFILES.in b/debian/po/POTFILES.in deleted file mode 100644 index cef83a3..0000000 --- a/debian/po/POTFILES.in +++ /dev/null @@ -1 +0,0 @@ -[type: gettext/rfc822deb] templates diff --git a/debian/po/templates.pot b/debian/po/templates.pot deleted file mode 100644 index 444d09f..0000000 --- a/debian/po/templates.pot +++ /dev/null @@ -1,52 +0,0 @@ -# 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 , 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 \n" -"Language-Team: LANGUAGE \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 "" diff --git a/debian/postinst b/debian/postinst index a9bf0af..390eb42 100644 --- a/debian/postinst +++ b/debian/postinst @@ -1,51 +1,14 @@ #!/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 diff --git a/debian/rules b/debian/rules index 0af0bce..764b744 100755 --- a/debian/rules +++ b/debian/rules @@ -14,7 +14,6 @@ clean: dh_testroot rm -f build-stamp configure-stamp dh_clean - debconf-updatepo build: @touch build-stamp @@ -24,7 +23,7 @@ install: 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 @@ -36,7 +35,6 @@ 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 diff --git a/debian/templates b/debian/templates deleted file mode 100644 index 201df50..0000000 --- a/debian/templates +++ /dev/null @@ -1,16 +0,0 @@ -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. diff --git a/update-motd b/update-motd index 45c9d6f..462e679 100755 --- a/update-motd +++ b/update-motd @@ -32,29 +32,60 @@ NEW=/var/run/motd.new 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 @@ -72,3 +103,7 @@ run-parts --lsbsysinit $DIR >>$NEW 2>/dev/null # 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" diff --git a/update-motd.1 b/update-motd.1 index 90695be..f7ef35d 100644 --- a/update-motd.1 +++ b/update-motd.1 @@ -1,24 +1,40 @@ .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" diff --git a/update-motd.cron b/update-motd.cron index 4aedd14..f31f5c3 100644 --- a/update-motd.cron +++ b/update-motd.cron @@ -1,11 +1,6 @@ # /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 diff --git a/update-motd.default b/update-motd.default deleted file mode 100644 index 3c703d6..0000000 --- a/update-motd.default +++ /dev/null @@ -1,13 +0,0 @@ -# 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 -- 2.30.2