Author: glen
Date: Tue Jan 22 15:49:18 2008
New Revision: 9189

Modified:
   nagios-notify/trunk/nagios-notify
Log:
- parse $(base64:FILEPATH) macro from templates

Modified: nagios-notify/trunk/nagios-notify
==============================================================================
--- nagios-notify/trunk/nagios-notify   (original)
+++ nagios-notify/trunk/nagios-notify   Tue Jan 22 15:49:18 2008
@@ -10,6 +10,7 @@
 #
 
 templatedir='/etc/nagios/templates'
+export NAGIOS_DATADIR='/usr/share/nagios'
 prog="${0##*/}"
 
 # Substutute Nagios $VAR$-s (which are exported to environment by Nagios) from 
template.
@@ -25,7 +26,27 @@
                        }
                }
                exit;
-       }' | sed -f - $tmpl
+       }' | sed -f - $tmpl | perl -e '
+               use strict;
+               use MIME::Base64;
+
+               sub cat {
+                       open(FH, shift) or die;
+                       local $/ = undef;
+                       local $_ = <FH>;
+                       close FH;
+                       return $_;
+               }
+
+               sub base64_subst {
+                       encode_base64(cat(shift));
+               }
+
+               while (<>) {
+                       s/\$\(base64:(\S+)\)/base64_subst($1)/eg;
+                       print;
+               }
+       '
 }
 
 if [ -z "$NAGIOS_STATUSDATAFILE" ]; then
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to