From 7667c0bdc5a25496d9226ad1da08e4cfda980464 Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Sat, 19 Apr 2008 14:12:11 +1200 Subject: [PATCH 1/1] Add a check which possibly prints out a warning message. --- checks.d/10-print-message | 28 ++++++++++++++++++++++++++++ shutdown | 8 ++++++++ 2 files changed, 36 insertions(+) create mode 100755 checks.d/10-print-message diff --git a/checks.d/10-print-message b/checks.d/10-print-message new file mode 100755 index 0000000..cb4a483 --- /dev/null +++ b/checks.d/10-print-message @@ -0,0 +1,28 @@ +#!/bin/sh +# +# print a warning message before rebooting/shutting down etc a machine. +# +# Copyright Andrew Ruthven +# Released under the terms of the Artistic Licence 2.0 +# +# Cat out either /etc/molly-guard.$CMD.message +# or /etc/molly-guard.message +# If present. +CMD=$1; shift + +FILE= +BANNER= + +if [ -f /etc/molly-guard.$CMD.message ]; then + echo "$(hostname -s) has a $CMD warning message:" + FILE=/etc/molly-guard.$CMD.message +elif [ -f /etc/molly-guard.message ]; then + FILE=/etc/molly-guard.message + echo "$(hostname -s) has a warning message:" +fi + +if [ "x$FILE" != "x" ]; then + echo $BANNER + cat $FILE + echo "" +fi diff --git a/shutdown b/shutdown index 775a93e..c8005ad 100755 --- a/shutdown +++ b/shutdown @@ -51,6 +51,14 @@ usage() ALWAYS_MOLLY is set to '1'. This variable may be set in the file /etc/default/${ME} . + - Print out a warning message with information about this host + before the action takes place. You can use: + /etc/molly-guard..message + To print out a message specific to the command you're trying to + use. Or: + /etc/molly-guard.message + For a general warning message. + Only if the user satisfies all the checks will $ME take action. Specifying --molly-guard-do-nothing as argument to the command will make $ME echo the command it would execute rather than actually executing -- 2.39.5