Compiler quietening
[exim.git] / src / src / eximon.src
CommitLineData
059ec3d9
PH
1# Base source of start-up shell script for the Exim Monitor. Used to set the
2# required environment variables before running the program. Using script
3# rather than a configuration file means that computation can be done.
4# The build process concatenates on the front of this various settings from
5# os-specific files and from the user's configuration file.
6
3386088d 7# Copyright (c) 2004 - 2015 University of Cambridge.
059ec3d9
PH
8# See the file NOTICE for conditions of use and distribution.
9
10# Except when they appear in comments, the following placeholders in this
11# source are replaced when it is turned into a runnable script:
12#
13# CONFIGURE_FILE_USE_NODE
14# CONFIGURE_FILE
15# BIN_DIRECTORY
16# BASENAME_COMMAND
17# HOSTNAME_COMMAND
18# X11_LD_LIBRARY
19
20# PROCESSED_FLAG
983da878
HSHR
21#
22if test "x$1" = x--version
23then
24 echo "`basename $0`: $0"
25 echo "build: EXIM_RELEASE_VERSIONEXIM_VARIANT_VERSION"
26 exit 0
27fi
059ec3d9 28
c6e95d22
PP
29# See if caller wants to invoke gdb
30
31use_gdb=''
32
33case ${1:-foo} in
34 gdb*) use_gdb="$1"; shift ;;
35esac
36
059ec3d9
PH
37# Save arguments (can be the usual X parameters)
38
39cmd_args="$@"
40
41# See if this installation is using the esoteric "USE_NODE" feature of Exim,
42# in which it uses the host's name as a suffix for the configuration file name.
43
44if [ "CONFIGURE_FILE_USE_NODE" = "yes" ]; then
45 hostsuffix=.`uname -n`
46fi
47
48# Now find the configuration file name. This has got complicated because
49# CONFIGURE_FILE may now be a list of files. The one that is used is the first
50# one that exists. Mimic the code in readconf.c by testing first for the
51# suffixed file in each case.
52
53set `awk -F: '{ for (i = 1; i <= NF; i++) print $i }' <<End
54CONFIGURE_FILE
55End
56`
57while [ "$config" = "" -a $# -gt 0 ] ; do
58 if [ -f "$1$hostsuffix" ] ; then
59 config="$1$hostsuffix"
60 elif [ -f "$1" ] ; then
61 config="$1"
62 fi
63 shift
64done
65
66# Determine where the spool directory is and whether there is any setting of
67# log_file_path. Search for an exim_path setting in the configure file;
68# otherwise use the bin directory. Call that version of Exim to find the spool
69# directory and the setting of log_file_path.
70
71config=${EXIMON_EXIM_CONFIG-$config}
72
73# Add code here to redefine "config" if an alternative configuration file
74# should be used in some circumstances. If you do that, you should also arrange
75# for the value to be set in EXIMON_EXIM_CONFIG, and to export that variable
76# into the environment. BEWARE: a tab character is needed in the command below.
77# It has had a nasty tendency to get lost in the past. Use a variable to hold a
78# space and a tab to keep the tab in one place.
79
80st=' '
81EXIM_PATH=`grep "^[$st]*exim_path" $config | sed "s/.*=[$st]*//"`
82if test "$EXIM_PATH" = ""; then EXIM_PATH=BIN_DIRECTORY/exim; fi
83
84SPOOL_DIRECTORY=`$EXIM_PATH -C $config -bP spool_directory | sed 's/.*=[ ]*//'`
85LOG_FILE_PATH=`$EXIM_PATH -C $config -bP log_file_path | sed 's/.*=[ ]*//'`
86
87# If log_file_path is "syslog" then logging is only to syslog, and the monitor
88# is unable to display a log tail unless EXIMON_LOG_FILE_PATH is set to tell
488e8946
AM
89# it where the log data is. If log_file_path is unset (i.e. empty) the default
90# is "mainlog" in the "log" directory in the spool directory. Otherwise,
91# remove any occurrences of "syslog:" or ":syslog" (spaces allowed in various
92# places) and look at the remainder of the entry. If it's null, check whether
93# LOG_FILE_NAME was set a compile time and contains a path. Otherwise fall
94# back to the default path.
059ec3d9
PH
95
96if [ "$EXIMON_LOG_FILE_PATH" != "" ] ; then
97 LOG_FILE_NAME="$EXIMON_LOG_FILE_PATH"
98elif [ "$LOG_FILE_PATH" = "syslog" ] ; then
99 LOG_FILE_NAME=""
100 echo \*\*\*
101 echo Exim is using the syslog interface for its log data. If you redirect all
102 echo MAIL.INFO syslog messages into a separate file, you can point eximon at
103 echo that file with the EXIMON_LOG_FILE_PATH environment variable.
104 echo \*\*\*
488e8946
AM
105elif [ "$LOG_FILE_PATH" = "" ] ; then
106 LOG_FILE_NAME=$SPOOL_DIRECTORY/log/mainlog
059ec3d9
PH
107else
108 LOG_FILE_NAME=`echo $LOG_FILE_PATH | \
109 sed -e 's/ *: *syslog *: */:/' \
110 -e 's/ *: *syslog *$//' \
111 -e 's/^ *syslog *: *//' \
112 -e 's/%s/main/'`
113 if [ "$LOG_FILE_NAME" = "" ] ; then
488e8946
AM
114 COMPILETIMEDEFAULT=`$EXIM_PATH -C /dev/null -bP log_file_path | \
115 sed -e 's/.*=[ ]*//' \
116 -e 's/ *: *syslog *: */:/' \
117 -e 's/ *: *syslog *$//' \
118 -e 's/^ *syslog *: *//' \
119 -e 's/%s/main/'`
120 if [ "$COMPILETIMEDEFAULT" != "" ] ; then
121 LOG_FILE_NAME="$COMPILETIMEDEFAULT"
122 else
123 LOG_FILE_NAME=$SPOOL_DIRECTORY/log/mainlog
124 fi
059ec3d9
PH
125 fi
126fi
127
128# The basename and hostname commands vary from system to system
129
130basename=BASENAME_COMMAND
131hostname=HOSTNAME_COMMAND
132
133# SunOS5 is a pain in that they may be in one of two places. So is Linux
134# in the case of basename. Set up a general mechanism for searching for
135# them in several places.
136
137if [ "${basename}" = "look_for_it" ] ; then
138 if [ -f /usr/bin/basename ] ; then
139 basename=/usr/bin/basename
140 else
141 if [ -f /bin/basename ] ; then
142 basename=/bin/basename
143 else
144 basename=/usr/ucb/basename
145 fi
146 fi
147fi
148
149if [ "${hostname}" = "look_for_it" ] ; then
150 if [ -f /usr/bin/hostname ] ; then
151 hostname=/usr/bin/hostname
152 else
153 if [ -f /bin/hostname ] ; then
154 hostname=/bin/hostname
155 else
156 hostname=/usr/ucb/hostname
157 fi
158 fi
159fi
160
161# Set hostname to the full hostname with the specified domain
162# stripped off its end. On Solaris 2, the default basename
163# command treats its suffix argument as a pattern. Consequently,
164# if fullhostname contains no dots but ends with what looks like
165# the domain, straightforward use of basename screws things up.
166# Use a general test for this case, just in case any other OS
167# do the same.
168
169fullhostname=`${hostname}`
170case `${basename} abc .c` in
171 a) hostname=`${basename} ${fullhostname} '\.'${DOMAIN}` ;;
172 *) hostname=`${basename} ${fullhostname} .${DOMAIN}` ;;
173esac
174
175
176# Arrange for the window title field to be substituted by the shell
177# so that it can contain either the full or the short host name. This
178# is a tedious little bit of magic, but I don't know how to do it
179# in a less tortuous way.
180
181WINDOW_TITLE=`fullhostname=${fullhostname} hostname=${hostname} /bin/sh <<xx
182echo ${WINDOW_TITLE}
183xx
184`
185
186# Add the X11 library to the library path, and then export the
187# environment variables used by eximon. The string X11-LD-LIBRARY
188# (with underscores, not hyphens) below is replaced by the configured
189# library name when the script is built. (Hyphens are used in the description
190# to stop it getting changed there too.)
191
192X11LIB=X11_LD_LIBRARY
193
194if [ "${LD_LIBRARY_PATH}" = "" ] ; then
195 LD_LIBRARY_PATH=${X11LIB}
196else
197 LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${X11LIB}
198fi
199
200export EXIM_PATH LD_LIBRARY_PATH \
201 LOG_BUFFER LOG_DEPTH LOG_FILE_NAME LOG_FONT LOG_WIDTH \
202 ACTION_OUTPUT ACTION_QUEUE_UPDATE\
203 MENU_EVENT MIN_HEIGHT MIN_WIDTH \
204 QUALIFY_DOMAIN QUEUE_DEPTH QUEUE_FONT QUEUE_INTERVAL QUEUE_MAX_ADDRESSES \
205 QUEUE_STRIPCHART_NAME QUEUE_TOTAL QUEUE_WIDTH SPOOL_DIRECTORY \
206 START_DEPTH LOG_STRIPCHARTS SIZE_STRIPCHART SIZE_STRIPCHART_NAME \
207 START_SMALL STRIPCHART_INTERVAL \
208 TEXT_DEPTH WINDOW_TITLE
209
210# Exec to the program we really want to run, thereby continuing in
211# just the one process, and let it run in parallel with whatever
c6e95d22 212# called this script (unless gdb was requested in original $1).
059ec3d9 213
c6e95d22
PP
214if [ "${use_gdb:-}" = "" ] ; then
215 exec "${EXIMON_BINARY}" $cmd_args &
216else
217 exec "$use_gdb" "${EXIMON_BINARY}" $cmd_args
218 # not backgrounded
219fi
059ec3d9
PH
220
221# End