author | Alan Coopersmith <Alan.Coopersmith@Oracle.COM> |
Fri, 14 Oct 2016 14:53:30 -0700 | |
changeset 7114 | 72d09e38c454 |
parent 3649 | 4006eaaa7d29 |
permissions | -rw-r--r-- |
3649
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
1 |
#!/usr/sbin/sh |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
2 |
# |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
3 |
# CDDL HEADER START |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
4 |
# |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
5 |
# The contents of this file are subject to the terms of the |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
6 |
# Common Development and Distribution License (the "License"). |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
7 |
# You may not use this file except in compliance with the License. |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
8 |
# |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
10 |
# or http://www.opensolaris.org/os/licensing. |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
11 |
# See the License for the specific language governing permissions |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
12 |
# and limitations under the License. |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
13 |
# |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
19 |
# |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
20 |
# CDDL HEADER END |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
21 |
# |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
22 |
# Copyright (c) 1991, 2013, Oracle and/or its affiliates. All rights reserved. |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
23 |
|
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
24 |
. /lib/svc/share/smf_include.sh |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
25 |
. /lib/svc/share/sendmail_include.sh |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
26 |
|
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
27 |
ERRMSG1='WARNING: /var/mail is NFS-mounted without setting actimeo=0,' |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
28 |
ERRMSG2='this can cause mailbox locking and access problems.' |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
29 |
SERVER_PID_FILE="$SMF_SYSVOL_FS/sendmail.pid" |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
30 |
ALIASES_FILE="/etc/mail/aliases" |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
31 |
SENDMAIL_CF="/etc/mail/sendmail.cf" |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
32 |
MAKEMAP="/usr/sbin/makemap" |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
33 |
|
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
34 |
case "$1" in |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
35 |
'refresh') |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
36 |
[ -f $SERVER_PID_FILE ] && kill -1 `head -1 $SERVER_PID_FILE` |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
37 |
;; |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
38 |
|
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
39 |
'start') |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
40 |
exist_or_exit $SENDMAIL |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
41 |
if [ ! -d /var/spool/mqueue ]; then |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
42 |
/usr/bin/mkdir -m 0750 /var/spool/mqueue |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
43 |
/usr/bin/chown root:bin /var/spool/mqueue |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
44 |
fi |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
45 |
if [ ! -d /var/mail/:saved ]; then |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
46 |
/usr/bin/mkdir -m 0775 /var/mail/:saved |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
47 |
/usr/bin/chown root:mail /var/mail/:saved |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
48 |
fi |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
49 |
dbvers=`/usr/bin/svcprop -c -p config/db_version $SMF_FMRI 2>/dev/null` |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
50 |
if [ $? -ne 0 -o "$dbvers" != "5" ]; then |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
51 |
# Need to upgrade Berkeley DB version |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
52 |
# Part 1: blow away aliases DB files; we will recreate them |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
53 |
# just below. |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
54 |
# Part 2: keyed maps are handled further below. |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
55 |
/usr/bin/rm -f $ALIASES_FILE.db $ALIASES_FILE.dir \ |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
56 |
$ALIASES_FILE.pag |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
57 |
db_version_upgrade_needed=true |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
58 |
fi |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
59 |
if [ ! -f $ALIASES_FILE.db ] && [ ! -f $ALIASES_FILE.dir ] \ |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
60 |
&& [ ! -f $ALIASES_FILE.pag ]; then |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
61 |
/usr/sbin/newaliases |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
62 |
fi |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
63 |
MODE="-bd" |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
64 |
[ -f $DEFAULT_FILE ] && . $DEFAULT_FILE |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
65 |
# |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
66 |
# * MODE should be "-bd" or null (MODE= or MODE="") or |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
67 |
# left alone. Anything else and you're on your own. |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
68 |
# * QUEUEOPTION should be "p" or null (as above). |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
69 |
# * QUEUEINTERVAL should be set to some legal value; |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
70 |
# sanity checks are done below. |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
71 |
# * OPTIONS are catch-alls; set with care. |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
72 |
# |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
73 |
if [ -n "$QUEUEOPTION" -a "$QUEUEOPTION" != "p" ]; then |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
74 |
QUEUEOPTION="" |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
75 |
fi |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
76 |
if [ -z "$QUEUEOPTION" -o -n "$QUEUEINTERVAL" ]; then |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
77 |
check_queue_interval_syntax $QUEUEINTERVAL |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
78 |
QUEUEINTERVAL=$answer |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
79 |
fi |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
80 |
|
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
81 |
local=`/usr/bin/svcprop -p config/local_only $SMF_FMRI 2>/dev/null` |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
82 |
if [ $? -eq 0 -a "$local" = "true" ]; then |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
83 |
MODE="-bl" |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
84 |
fi |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
85 |
sendmail_path=`svcprop -p config/path_to_sendmail_mc $SMF_FMRI \ |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
86 |
2>/dev/null` |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
87 |
if [ $? -eq 0 -a -n "$sendmail_path" ]; then |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
88 |
turn_m4_crank "$SENDMAIL_CF" "$sendmail_path" |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
89 |
fi |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
90 |
exist_or_exit "$SENDMAIL_CF" |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
91 |
if [ -n "$db_version_upgrade_needed" ]; then |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
92 |
# Find the Keyed map lines, extract the arguments, run |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
93 |
# makemap to create the maps with the upgraded DB version. |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
94 |
/usr/bin/nawk ' |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
95 |
$1 ~ /^K/ && $2 ~ /^(hash|btree|dbm)$/ { |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
96 |
print $2, $NF |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
97 |
} ' "$SENDMAIL_CF" | |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
98 |
while read dbtyp file; do |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
99 |
if [ "$dbtyp" == "dbm" ]; then |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
100 |
/usr/bin/rm -f $file.dir $file.pag |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
101 |
else |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
102 |
/usr/bin/rm -f $file.db |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
103 |
fi |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
104 |
echo "Executing \"$MAKEMAP $dbtyp $file < $file\"." |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
105 |
$MAKEMAP $dbtyp $file < $file |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
106 |
result=$? |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
107 |
if [ $result -ne 0 ]; then |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
108 |
echo "Failed to update keyed map files." |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
109 |
echo "$MAKEMAP failed with error $result." |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
110 |
echo "Run makemap manually." |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
111 |
exit $SMF_EXIT_ERR_CONFIG |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
112 |
fi |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
113 |
done |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
114 |
|
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
115 |
# Finally, update the service property. |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
116 |
/usr/sbin/svccfg -s $SMF_FMRI setprop config/db_version=5 |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
117 |
|
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
118 |
# We refresh the service to get the above property setting |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
119 |
# into the running snapshot. This will result in SMF |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
120 |
# invoking this script with $1 set to "refresh" immediately |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
121 |
# upon completion of this "start" invocation. But since |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
122 |
# sendmail sets up its SIGHUP handler before it writes |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
123 |
# its PID file, this should be OK: either the PID file |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
124 |
# will not yet exist, in which case, the "refresh" will |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
125 |
# do nothing (beyond getting the property setting into the |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
126 |
# running snapshot), or the PID file will exist, in which |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
127 |
# case the SIGHUP handler will have already been set up, |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
128 |
# and sendmail will catch the SIGHUP and re-exec itself. |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
129 |
/usr/sbin/svcadm refresh $SMF_FMRI |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
130 |
fi |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
131 |
|
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
132 |
$SENDMAIL $MODE -q$QUEUEOPTION$QUEUEINTERVAL $OPTIONS & |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
133 |
|
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
134 |
# |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
135 |
# ETRN_HOSTS should be of the form |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
136 |
# "s1:c1.1,c1.2 s2:c2.1 s3:c3.1,c3.2,c3.3" |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
137 |
# i.e., white-space separated groups of server:client where |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
138 |
# client can be one or more comma-separated names; N.B. that |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
139 |
# the :client part is optional; see etrn(1M) for details. |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
140 |
# server is the name of the server to prod; a mail queue run |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
141 |
# is requested for each client name. This is comparable to |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
142 |
# running "/usr/lib/sendmail -qRclient" on the host server. |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
143 |
# |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
144 |
# See RFC 1985 for more information. |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
145 |
# |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
146 |
for i in $ETRN_HOSTS; do |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
147 |
SERVER=`echo $i | /usr/bin/sed -e 's/:.*$//'` |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
148 |
CLIENTS=`echo $i | /usr/bin/sed -n -e 's/,/ /g' \ |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
149 |
-e '/:/s/^.*://p'` |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
150 |
/usr/sbin/etrn -b $SERVER $CLIENTS >/dev/null 2>&1 & |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
151 |
done |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
152 |
|
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
153 |
if /usr/bin/nawk 'BEGIN{s = 1} |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
154 |
$2 == "/var/mail" && $3 == "nfs" && $4 !~ /actimeo=0/ && |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
155 |
$4 !~ /noac/{s = 0} END{exit s}' /etc/mnttab; then |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
156 |
|
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
157 |
/usr/bin/logger -p mail.crit "$ERRMSG1" |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
158 |
/usr/bin/logger -p mail.crit "$ERRMSG2" |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
159 |
fi |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
160 |
;; |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
161 |
|
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
162 |
'stop') |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
163 |
[ -f $SERVER_PID_FILE ] && check_and_kill $SERVER_PID_FILE |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
164 |
# Need to kill the entire service contract to kill all sendmail related |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
165 |
# processes |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
166 |
smf_kill_contract $2 TERM 1 30 |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
167 |
ret=$? |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
168 |
[ $ret -eq 1 ] && exit 1 |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
169 |
|
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
170 |
# Since sendmail spawns user processes out of .forward files, it is |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
171 |
# possible that some of these are not responding to TERM. If the |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
172 |
# contract did not empty after TERM, move on to KILL. |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
173 |
if [ $ret -eq 2 ] ; then |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
174 |
smf_kill_contract $2 KILL 1 |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
175 |
fi |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
176 |
;; |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
177 |
|
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
178 |
*) |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
179 |
echo "Usage: $0 { start | stop | refresh }" |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
180 |
exit 1 |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
181 |
;; |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
182 |
esac |
4006eaaa7d29
20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
183 |
exit 0 |