Add compile-time guard against BDB library version 6
[exim.git] / src / src / exiwhat.src
CommitLineData
059ec3d9 1#! /bin/sh
059ec3d9 2
0a49a7a4 3# Copyright (c) University of Cambridge, 1995 - 2007
059ec3d9
PH
4# See the file NOTICE for conditions of use and distribution.
5
6# Except when they appear in comments, the following placeholders in this
7# source are replaced when it is turned into a runnable script:
8#
9# CONFIGURE_FILE_USE_NODE
10# CONFIGURE_FILE
11# BIN_DIRECTORY
12# EXIWHAT_PS_CMD
13# EXIWHAT_PS_ARG
14# EXIWHAT_KILL_SIGNAL
15# EXIWHAT_EGREP_ARG
16# EXIWHAT_MULTIKILL_CMD
17# EXIWHAT_MULTIKILL_ARG
18
19# PROCESSED_FLAG
20
21# Shell script for seeing what the exim processes are doing. It gets rid
22# of the old process log, then sends SIGUSR1 to all exim processes to get
23# them to write their state to the log. Then it displays the contents of
24# the log.
25
26# The following lines are generated from Exim's configuration file when
27# this source is built into a script, but you can subsequently edit them
28# without rebuilding things, as long are you are careful not to overwrite
29# the script in the next Exim rebuild/install. However, it's best to
30# arrange your build-time configuration file to get the correct values.
31
32# Some operating systems have a command that finds processes that match
33# certain conditions (by default usually those running specific commands)
34# and sends them signals. If such a command is defined for your OS, the
35# following variables are set and used.
36
37multikill_cmd=EXIWHAT_MULTIKILL_CMD
38multikill_arg=EXIWHAT_MULTIKILL_ARG
39
40# In other operating systems, Exim has to use "ps" and "egrep" to find the
41# processes itself. In those cases, the next three variables are used:
42
43ps_cmd=EXIWHAT_PS_CMD
44ps_arg=EXIWHAT_PS_ARG
45egrep_arg=EXIWHAT_EGREP_ARG
46
47# In both cases, kill_arg is the argument for the (multi)kill command to send
48# SIGUSR1 (at least one OS requires a numeric value).
49
50signal=EXIWHAT_KILL_SIGNAL
51
52# See if this installation is using the esoteric "USE_NODE" feature of Exim,
53# in which it uses the host's name as a suffix for the configuration file name.
54
983da878
HSHR
55if test "x$1" = x--version
56then
57 echo "`basename $0`: $0"
58 echo "build: EXIM_RELEASE_VERSIONEXIM_VARIANT_VERSION"
59 exit 0
60fi
61
059ec3d9
PH
62if [ "CONFIGURE_FILE_USE_NODE" = "yes" ]; then
63 hostsuffix=.`uname -n`
64fi
65
66# Now find the configuration file name. This has got complicated because
67# CONFIGURE_FILE may now be a list of files. The one that is used is the first
68# one that exists. Mimic the code in readconf.c by testing first for the
69# suffixed file in each case.
70
71set `awk -F: '{ for (i = 1; i <= NF; i++) print $i }' <<End
72CONFIGURE_FILE
73End
74`
75while [ "$config" = "" -a $# -gt 0 ] ; do
76 if [ -f "$1$hostsuffix" ] ; then
77 config="$1$hostsuffix"
78 elif [ -f "$1" ] ; then
79 config="$1"
80 fi
81 shift
82done
83
447de4b0
NM
84# check we have a config file
85if [ "$config" = "" -o ! -f "$config" ]; then
86 echo Config file not found.
87 exit 1
88fi
89
059ec3d9
PH
90# Determine where the spool directory is. Search for an exim_path setting
91# in the configure file; otherwise use the bin directory. Call that version of
92# Exim to find the spool directory. BEWARE: a tab character is needed in the
93# first command below. It has had a nasty tendency to get lost in the past. Use
94# a variable to hold a space and a tab. This is less likely to be touched.
95
96st=' '
97exim_path=`grep "^[$st]*exim_path" $config | sed "s/.*=[$st]*//"`
98if test "$exim_path" = ""; then exim_path=BIN_DIRECTORY/exim; fi
99spool_directory=`$exim_path -C $config -bP spool_directory | sed "s/.*=[ ]*//"`
100process_log_path=`$exim_path -C $config -bP process_log_path | sed "s/.*=[ ]*//"`
101
102# The file that Exim writes when sent the SIGUSR1 signal is specified by
103# the process_log_path option. If that is not defined, Exim uses the file
104# called "exim-process.info" in the spool directory.
105
106log=$process_log_path
107if [ "$log" = "" ] ; then
108 log=$spool_directory/exim-process.info
109fi
110
111# Now do the job.
112
113/bin/rm -f ${log}
114if [ -f ${log} ]; then
115 echo "** Failed to remove ${log}"
116 exit 1
117fi
118
119# If there is a multikill command, use it. On some OS this command is called
120# "killall" (Linux, FreeBSD). On Solaris it is called "pkill". Note that on
121# Solaris, "killall" kills ALL processes - this is the System V version of this
122# command, and not what we want!
123
079cc20f 124if [ "$multikill_cmd" != "" ] && type "$multikill_cmd" >/dev/null 2>&1; then
059ec3d9
PH
125 $multikill_cmd $signal "$multikill_arg"
126
127# No multikill command; do it the hard way
128
129else
130 $ps_cmd $ps_arg | \
131 egrep "$egrep_arg" | \
132 awk "{print \"kill $signal \"\$1}" | \
133 uniq | sh
134fi
135
136sleep 1
137
138if [ ! -s ${log} ] ; then echo "No exim process data" ;
921b12ca 139 else sort -nu ${log} ; fi
059ec3d9
PH
140
141
142# End of exiwhat