|
1 #!/usr/sbin/sh |
|
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 (the "License"). |
|
7 # You may not use this file except in compliance with the License. |
|
8 # |
|
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
10 # or http://www.opensolaris.org/os/licensing. |
|
11 # See the License for the specific language governing permissions |
|
12 # and limitations under the License. |
|
13 # |
|
14 # When distributing Covered Code, include this CDDL HEADER in each |
|
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
16 # If applicable, add the following below this CDDL HEADER, with the |
|
17 # fields enclosed by brackets "[]" replaced with your own identifying |
|
18 # information: Portions Copyright [yyyy] [name of copyright owner] |
|
19 # |
|
20 # CDDL HEADER END |
|
21 # |
|
22 # Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. |
|
23 |
|
24 DEFAULT_FILE="/etc/default/sendmail" |
|
25 SENDMAIL="/usr/lib/sendmail" |
|
26 PATH="/usr/bin:/usr/sbin" |
|
27 export PATH |
|
28 |
|
29 check_queue_interval_syntax() |
|
30 { |
|
31 default="15m" |
|
32 if [ $# -lt 1 ]; then |
|
33 answer=$default |
|
34 return |
|
35 fi |
|
36 if echo $1 | egrep '^([0-9]*[1-9][0-9]*[smhdw])+$' >/dev/null 2>&1; then |
|
37 answer=$1 |
|
38 else |
|
39 answer=$default |
|
40 fi |
|
41 } |
|
42 |
|
43 check_and_kill() |
|
44 { |
|
45 PID=`head -1 $1` |
|
46 kill -0 $PID > /dev/null 2>&1 |
|
47 [ $? -eq 0 ] && kill $PID |
|
48 } |
|
49 |
|
50 exist_or_exit() |
|
51 { |
|
52 if [ ! -f $1 ]; then |
|
53 echo "$1 does not exist" >&2 |
|
54 exit $SMF_EXIT_ERR_CONFIG |
|
55 fi |
|
56 } |
|
57 |
|
58 turn_m4_crank() |
|
59 { |
|
60 # expected to be called with two arguments: .cf path & path to m4 file |
|
61 [ $# -lt 2 ] && return |
|
62 cf_path=$1 |
|
63 m4_path=$2 |
|
64 if [ "$m4_path" = "_DONT_TOUCH_THIS" ]; then |
|
65 if [ -f "${cf_path}.old" ]; then |
|
66 mv "$cf_path" "${cf_path}.new" |
|
67 [ $? -ne 0 ] && exit $SMF_EXIT_ERR_CONFIG |
|
68 mv "${cf_path}.old" "$cf_path" |
|
69 [ $? -ne 0 ] && exit $SMF_EXIT_ERR_CONFIG |
|
70 fi |
|
71 # |
|
72 # If ${cf_path}.old does not exist, assume it was taken care |
|
73 # of on a previous run. |
|
74 # |
|
75 else |
|
76 case "$m4_path" in |
|
77 /*) ;; # absolute path |
|
78 *) return;; |
|
79 esac |
|
80 exist_or_exit "$m4_path" |
|
81 cd `dirname "$m4_path"` |
|
82 base=`basename "$m4_path"` |
|
83 name=`basename "$m4_path" .mc` |
|
84 m4flags="-D_CF_DIR_=/etc/mail/cf/" |
|
85 info=`svcprop -p config/include_info $SMF_FMRI 2>/dev/null` |
|
86 if [ "$info" != "true" ]; then |
|
87 m4flags="$m4flags -DSUN_HIDE_INTERNAL_DETAILS" |
|
88 fi |
|
89 m4 $m4flags /etc/mail/cf/m4/cf.m4 "$base" > "${name}.cf" |
|
90 [ $? -ne 0 ] && exit $SMF_EXIT_ERR_CONFIG |
|
91 cmp -s "${name}.cf" "$cf_path" || ( |
|
92 cp "${name}.cf" "${cf_path}.tmp" && |
|
93 chown root:bin "${cf_path}.tmp" && |
|
94 chmod 444 "${cf_path}.tmp" && |
|
95 mv "${cf_path}.tmp" "$cf_path" |
|
96 ) |
|
97 [ $? -ne 0 ] && exit $SMF_EXIT_ERR_CONFIG |
|
98 fi |
|
99 } |