Changeset - ee406aac7d24
[Not reviewed]
0 1 0
Branko Majic (branko) - 4 years ago 2020-06-29 04:17:04
branko@majic.rs
Fixed the etckeeper command call.
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general) First comment
configuration/etckeeper_notifier.sh
Show inline comments
 
@@ -74,61 +74,61 @@ $program, version $version
 
| 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" -d "$directory"; then
 
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
 

	
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now