Files
@ 12917a1e11ff
Branch filter:
Location: majic-scripts/configuration/etckeeper_notifier.sh - annotation
12917a1e11ff
4.4 KiB
text/x-sh
[TEMPLATE.sh.tpl] Fix the accidental use of tabs instead of spaces for indentation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 ee406aac7d24 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 61750d5ab4b2 | #!/bin/bash
#
# etckeeper_notifier.sh
#
# Copyright (C) 2012, Branko Majic <branko@majic.rs>
#
# 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/>.
#
program="etckeeper_notifier.sh"
version="0.1"
function usage() {
cat <<EOF
$program $version, a non-interactive utility for sending-out notifications about
uncommitted changes in etckeeper-controlled directories.
Usage: $program [OPTIONS] directory
$program is a non-interactive utility for sending-out notifications about
uncommitted changes in etckeeper-controlled directories. The script acts as a
small wrapper around the "etckeeper unclean" and "mail" commands. Main use for
the script is for cases where automatic daily commits by etckeeper are disabled,
but the administrator still desires to be notified of uncommitted changes in the
directory (commonly /etc/). The script should be used through a cron job.
The script accepts a single argument which is path to the directory controlled
by etckeeper that should be checked for uncommitted changes.
$program accepts the following options:
-m mails Space-separated list of e-mails to send out the mail notification
to. Default is root@localhost.
-e etckeeper_path Path to the etckeeper binary.
-v show script version and licensing information
-h show usage help
Please report bugs and send feature requests to <branko@majic.rs>.
EOF
}
function version() {
cat <<EOF
$program, version $version
+-----------------------------------------------------------------------+
| Copyright (C) 2012, Branko Majic <branko@majic.rs> |
| |
| 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/>. |
+-----------------------------------------------------------------------+
EOF
}
# If no arguments were given, just show usage help.
if [[ -z $1 ]]; then
usage
exit 0
fi
# Set-up some default values.
notificationRecipients="root@localhost"
# Location of the etckeeper binary.
etckeeper="/usr/bin/etckeeper"
# Parse the arguments
while getopts "e:m:vh" opt; do
case "$opt" in
e) etckeeper="$OPTARG";;
m) notificationRecipients="$OPTARG";;
v) version
exit 0;;
h) usage
exit 0;;
*) usage
exit 1;;
esac
done
i=$OPTIND
shift $(($i-1))
# Read the positional arguments
directory="$1"
# Verify arguments
if [[ ! -d "$directory" ]]; then
echo "No such directory: '$directory'" >&2
exit 2
fi
# Verify that etckeeper is available.
if [[ ! -f $etckeeper ]]; then
echo "The etckeeper was not found in location: '$etckeeper'." >&2
exit 2
fi
if "$etckeeper" unclean -d "$directory"; then
mail -s "Uncommited changes on '$(hostname -f)' in '$directory'" $notificationRecipients <<EOF
Uncommitted changes have been detected on server $(hostname -f) in directory:
$directory
Please log-in onto the server, and either undo the changes, or commit the
changes using a descriptive comment.
Do not reply to this mail. This is an automated message.
EOF
fi
|