xref: /illumos-gate/usr/src/cmd/lp/model/alert.proto (revision a28480febf31f0e61debac062a55216a98a05a92)
1#ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.5	*/
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License, Version 1.0 only
7# (the "License").  You may not use this file except in compliance
8# with the License.
9#
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.
14#
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]
20#
21# CDDL HEADER END
22#
23#
24#	Pardon the bizarre variable names, but we must not
25#	conflict with any variables that the user gives us.
26#
27
28-ENVIRONMENT-
29
30cd -PWD-
31
32if [ "`ulimit`" -gt -ULIMIT- ]
33then
34	ulimit -ULIMIT-
35fi
36
37umask -UMASK-
38
39AlErT () {
40	2>&1 (
41-CMD-
42	) <$1 1>${TmPsTdErR} || return 1
43	return 0
44}
45
46TmPsTdErR=${TMPDIR:-/usr/tmp}/`/bin/uname -n`$$
47trap 'rm -f ${TmPsTdErR}; exit 0' 0 1 2 15
48
49while AlErT $1
50do
51	if [ -INTERVAL- -le 0 ]
52	then
53		exit 0
54	else
55		TiCk=0
56		while [ "${TiCk}" -lt -INTERVAL- ]
57		do
58			TiCk=`expr "${TiCk}" + 1`
59			sleep 60
60		done
61	fi
62done
63
64ec=$?
65if [ "${ec}" -ne 0 ]
66then
67	{
68
69		echo "
70One of your print service alerts failed with exit code ${ec}.
71The standard output and standard error were:
72	"
73		cat ${TmPsTdErR}
74		echo '
75
76The alert message is:
77'
78		cat $1
79
80	} | mailx -s 'Failed print service alert' -USER-
81fi
82