[Logcheck-users] Patch to add gpg support to logcheck.
Mike Mestnik
cheako at mikemestnik.net
Tue Feb 12 01:48:56 UTC 2013
This might work better...
===================================================================
RCS file: logcheck,v
retrieving revision 1.1
diff -u -r1.1 logcheck
--- logcheck 2013/02/10 04:17:53 1.1
+++ logcheck 2013/02/12 01:43:23
@@ -83,6 +83,7 @@
LOGCHECKDEBUG=0
MAILOUT=0
MAILASATTACH=0
+MAILASGPG=0
NOCLEANUP=0
REBOOT=0
FQDN=0
@@ -174,10 +175,15 @@
$(export)
EOF
- } | eval mime-construct $MIMECONSTRUCTARGS \
- --subject "'Logcheck: $HOSTNAME $DATE exiting due to errors'"
--encoding "7bit" \
- --file - --to "$SENDMAILTO"
-
+ } | if [ "$MAILASGPG" -eq 1 ]; then
+ debug "Sending error as gpg"
+ mime-construct --subpart --file - | {
+ gpg --encrypt --batch --quiet --armor -r "$SENDMAILTO" 2>&1; } |
+ eval mime-construct $MIMECONSTRUCTARGS --to "$SENDMAILTO"
--subject "'Logcheck: $HOSTNAME $DATE exiting due to errors'"
--multipart "'multipart/encrypted;
protocol=\"application/pgp-encrypted\"'" --type
"application/pgp-encrypted" --string "'Version: 1
+'" --file -
+ else
+ eval mime-construct $MIMECONSTRUCTARGS --subject "'Logcheck:
$HOSTNAME $DATE exiting due to errors'" --encoding "7bit" --file - --to
"$SENDMAILTO"
+ fi
elif [ "$MAILOUT" -eq 1 ]; then
{
echo "Error: $message."
@@ -300,12 +306,25 @@
debug "Sent report to STDOUT"
else
debug "Sending report: '$subject' to $SENDMAILTO"
- if [ "$MAILASATTACH" -eq 1 ]; then
- debug "Sending report as attachment"
- eval mime-construct $MIMECONSTRUCTARGS --subject "'$subject'"
--encoding "7bit" --string "'Report attached'" --to "$SENDMAILTO"
--attachment "logcheck_report" --encoding "7bit" --file "$TMPDIR/report"
- return $?
- fi
- eval mime-construct $MIMECONSTRUCTARGS --subject "'$subject'"
--to "$SENDMAILTO" --encoding "7bit" --file "$TMPDIR/report"
+ if [ "$MAILASGPG" -eq 1 ]; then
+ debug "Sending error as gpg"
+ if [ "$MAILASATTACH" -eq 1 ]; then
+ debug "Sending report as attachment"
+ mime-construct --subpart --encoding "7bit" --string
"'Report attached'" --attachment "logcheck_report" --encoding "7bit"
--file "$TMPDIR/report"
+ else
+ mime-construct --subpart --encoding "7bit" --file
"$TMPDIR/report"
+ fi | {
+ gpg --encrypt --batch --quiet --armor -r "$SENDMAILTO" 2>&1; } |
+ eval mime-construct --to "$SENDMAILTO" --subject
"'$subject'" --multipart "'multipart/encrypted;
protocol=\"application/pgp-encrypted\"'" --type
"application/pgp-encrypted" --string "'Version: 1
+'" --file -
+ else
+ if [ "$MAILASATTACH" -eq 1 ]; then
+ debug "Sending report as attachment"
+ eval mime-construct $MIMECONSTRUCTARGS --subject
"'$subject'" --encoding "7bit" --string "'Report attached'" --to
"$SENDMAILTO" --attachment "logcheck_report" --encoding "7bit" --file
"$TMPDIR/report"
+ else
+ eval mime-construct $MIMECONSTRUCTARGS --subject
"'$subject'" --to "$SENDMAILTO" --encoding "7bit" --file "$TMPDIR/report"
+ fi
+ fi
fi
}
More information about the Logcheck-users
mailing list