6 # The contents of this file are subject to the terms of the
7 # Common Development and Distribution License (the "License").
8 # You may not use this file except in compliance with the License.
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 # or http://www.opensolaris.org/os/licensing.
12 # See the License for the specific language governing permissions
13 # and limitations under the License.
15 # When distributing Covered Code, include this CDDL HEADER in each
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 # If applicable, add the following below this CDDL HEADER, with the
18 # fields enclosed by brackets "[]" replaced with your own identifying
19 # information: Portions Copyright [yyyy] [name of copyright owner]
25 # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
29 # This is a simple helper script for smtp-notify which looks for certain
30 # expansion macros, which we've committed and converts them to valid
31 # libfmd_msg macros which directly reference event payload members.
33 # This allows us to change event payload names or alter the libfmd_msg
34 # expansion macro syntax without breaking user-supplied message body
37 # We use all-caps for the committed macro names to avoid colliding
38 # with an actual event payload member name.
40 # Usage: process_msg_template.sh <infile> <outfile> <code> <severity>
44 # Verify template exists, is readable and is an ascii text file
46 if [ ! -e $1 ] ||
[ ! -r $1 ]; then
50 /usr
/bin
/file $1 |
grep "ascii text" > /dev
/null
56 tmpfile2
=`/usr/bin/mktemp -p /var/tmp`
58 cat $1 |
sed s
/\
%\
<CODE\
>/$3/g
> $tmpfile1
59 cat $tmpfile1 |
sed s
/\
%\
<UUID\
>/\
%\
<uuid\
>/g
> $tmpfile2
60 cat $tmpfile2 |
sed s
/\
%\
<CLASS\
>/\
%\
<class\
>/g
> $tmpfile1
61 cat $tmpfile1 |
sed s
/\
%\
<SEVERITY\
>/$4/g
> $tmpfile2
62 cat $tmpfile2 |
sed s
/\
%\
<FMRI\
>/svc\
:\\/\
%\
<attr.svc.svc-name\
>\
:\
%\
<attr.svc.svc-instance\
>/g
> $tmpfile1
63 cat $tmpfile1 |
sed s
/\
%\
<FROM-STATE\
>/\
%\
<attr.from-state\
>/g
> $tmpfile2
64 cat $tmpfile2 |
sed s
/\
%\
<TO-STATE\
>/\
%\
<attr.to-state\
>/g
> $tmpfile1
65 cat $tmpfile1 |
sed s
/\
%\
<HOSTNAME\
>/\
%h
/g
> $tmpfile2
66 cat $tmpfile2 |
sed s
/\
%\
<URL\
>/\
%s
/g
> $tmpfile1