3 # Script to install Exim binaries in BIN_DIRECTORY, which is defined in
4 # the local Makefile. It expects to be run in a build directory. It needs
5 # to be run as root in order to make exim setuid to root. If exim runs setuid
6 # to (e.g.) exim, this script should be run as that user or root.
8 # This script also installs a default configuration file in CONFIGURE_FILE
9 # if there is no configuration file there, but only if CONFIGURE_FILE specifies
10 # single file. If it specifies a list, no action is taken.
12 # If a default configuration file is installed, the existence of the system
13 # aliases file is tested. A default, containing only comments, is installed if
16 # If INFO_DIRECTORY is defined in any of the local Makefiles, and the Exim doc
17 # directory contains the Texinfo documentation, this script also installs a
18 # the info files in INFO_DIRECTORY.
20 # If DESTDIR is defined, all file paths are prefixed with ${DESTDIR}, with the
21 # sole exception of the reference to the system aliases file in the default
22 # configuration, because it is assumed that Exim is not actually going to be
23 # run from this position. For backward compatibility, if DESTDIR is not
24 # defined, ROOT is used instead.
26 # The script can be made to output what it would do, without actually doing
27 # anything, by giving it the option "-n" (cf make). Arguments are the names
28 # of things to install. No arguments installs everything.
33 while [ $# -gt 0 ] ; do
40 echo $com "*** Verification mode only: no commands will actually be obeyed"
41 echo $com "*** You can cut and paste the bits you want to a shell, etc"
61 # Get the values of BIN_DIRECTORY, CONFIGURE_FILE, INFO_DIRECTORY, NO_SYMLINK,
62 # SYSTEM_ALIASES_FILE, and EXE from the global Makefile (in the build
63 # directory). EXE is empty except in the Cygwin environment. In each case, keep
64 # the latest definition, thus respecting the Makefiles precedence. The sed
65 # sequences here are messy, but have to be very "basic" in order to work on
66 # Solaris, where the regular expressions in sed are primitive indeed. Modify at
69 BIN_DIRECTORY=`sed -n -e '/^ *BIN_DIRECTORY *=/{s/^[^=]*= *//; s/ \{1,\}#.*//;s/ *$//;h;}' -e '${g;p;}' Makefile`
70 CONFIGURE_FILE=`sed -n -e '/^ *CONFIGURE_FILE *=/{s/^[^=]*= *//; s/ \{1,\}#.*//;s/ *$//;h;}' -e '${g;p;}' Makefile`
71 INFO_DIRECTORY=`sed -n -e '/^ *INFO_DIRECTORY *=/{s/^[^=]*= *//; s/ \{1,\}#.*//;s/ *$//;h;}' -e '${g;p;}' Makefile`
72 NO_SYMLINK=`sed -n -e '/^ *NO_SYMLINK *=/{s/^[^=]*= *//; s/ \{1,\}#.*//;s/ *$//;h;}' -e '${g;p;}' Makefile`
74 CHOWN=`sed -n -e '/^ *CHOWN_COMMAND *=/{s/^[^=]*= *//; s/ \{1,\}#.*//;s/ *$//;h;}' -e '${g;p;}' Makefile`
75 MV=`sed -n -e '/^ *MV_COMMAND *=/{s/^[^=]*= *//; s/ \{1,\}#.*//;s/ *$//;h;}' -e '${g;p;}' Makefile`
77 SYSTEM_ALIASES_FILE=`sed -n -e '/^ *SYSTEM_ALIASES_FILE *=/{s/^[^=]*= *//; s/ \{1,\}#.*//;s/ *$//;h;}' -e '${g;p;}' Makefile`
78 EXE=`sed -n -e '/^ *EXE *=/{s/^[^=]*= *//; s/ \{1,\}#.*//;s/ *$//;h;}' -e '${g;p;}' Makefile`
80 # Set a default for SYSTEM_ALIASES_FILE
82 if [ "${SYSTEM_ALIASES_FILE}" = "" ] ; then
83 SYSTEM_ALIASES_FILE=/etc/aliases
86 # Allow INST_xx to over-ride xx
87 case "$INST_BIN_DIRECTORY" in ?*) BIN_DIRECTORY="$INST_BIN_DIRECTORY";; esac
88 case "$INST_CONFIGURE_FILE" in ?*) CONFIGURE_FILE="$INST_CONFIGURE_FILE";; esac
89 case "$INST_INFO_DIRECTORY" in ?*) INFO_DIRECTORY="$INST_INFO_DIRECTORY";; esac
90 case "$INST_SYSTEM_ALIASES_FILE" in ?*) SYSTEM_ALIASES_FILE="$INST_SYSTEM_ALIASES_FILE";; esac
92 case "$INST_CHOWN" in ?*) CHOWN="$INST_CHOWN";; esac
93 case "$INST_MV" in ?*) MV="$INST_MV";; esac
95 case "$INST_UID" in '') INST_UID=root;; *) INST_UID="$INST_UID";; esac
96 case "$INST_CP" in '') CP=cp;; *) CP="$INST_CP";; esac
97 case "$INST_LN" in '') LN=ln;; *) LN="$INST_LN";; esac
98 case "$INST_CHMOD" in '') CHMOD=chmod;; *) CHMOD="$INST_CHMOD";; esac
99 case "$INST_DIRNAME" in '') DIRNAME=dirname;; *) DIRNAME="$INST_DIRNAME";; esac
100 case "$INST_MKDIR" in '') MKDIR=mkdir;; *) MKDIR="$INST_MKDIR";; esac
102 # Allow the user to over-ride xx
103 case "$inst_dest" in ?*) BIN_DIRECTORY="$inst_dest";; esac
104 case "$inst_conf" in ?*) CONFIGURE_FILE="$inst_conf";; esac
105 case "$inst_info" in ?*) INFO_DIRECTORY="$inst_info";; esac
106 case "$inst_aliases" in ?*) SYSTEM_ALIASES_FILE="$inst_aliases";; esac
108 # Insert ${DESTDIR} at the start of all paths so that the whole thing can be
109 # installed under a different file root. For backwards compatibility, use
110 # ${ROOT} if ${DESTDIR} is not set. However, we need to save the value of
111 # the real system aliases file, and use that in the default configuration.
113 ACTUAL_SYSTEM_ALIASES_FILE=${SYSTEM_ALIASES_FILE}
114 DESTDIR=${DESTDIR:-${ROOT}}
116 BIN_DIRECTORY=${DESTDIR}${BIN_DIRECTORY}
117 CONFIGURE_FILE=${DESTDIR}${CONFIGURE_FILE}
118 SYSTEM_ALIASES_FILE=${DESTDIR}${SYSTEM_ALIASES_FILE}
120 if [ "${INFO_DIRECTORY}" != "" ] ; then
121 INFO_DIRECTORY=${DESTDIR}${INFO_DIRECTORY}
124 # Overrides of other things
125 case "$inst_uid" in ?*) INST_UID="$inst_uid";; esac
126 case "$inst_cp" in ?*) CP="$inst_cp";; esac
127 case "$inst_mv" in ?*) MV="$inst_mv";; esac
128 case "$inst_ln" in ?*) LN="$inst_ln";; esac
129 case "$inst_chown" in ?*) CHOWN="$inst_chown";; esac
130 case "$inst_chmod" in ?*) CHMOD="$inst_chmod";; esac
131 case "$inst_dirname" in ?*) DIRNAME="$inst_dirname";; esac
132 case "$inst_mkdir" in ?*) MKDIR="$inst_mkdir";; esac
134 # chown is a special case; in at least one OS it is in /usr/etc instead
135 # of in /usr/bin, and therefore not likely to be on the path. Another OS
136 # has it in /usr/sbin. This fudge tries to cope with these variations.
138 # Otherwise, and for other commands, we assume that the normal PATH will
139 # give access to where they are on your operating system (normally /usr/bin
142 if [ "${CHOWN}" = "chown" -a -x /usr/sbin/chown ] ; then
143 CHOWN=/usr/sbin/chown
146 if [ "${CHOWN}" = "chown" -a ! -f /usr/bin/chown -a -f /usr/etc/chown ] ; then
150 # The values of CHOWN and MV taken from the Makefile are sometimes set to
151 # "look_for_it", which causes a search of the usual suspects. This code is
152 # similar to that in exicyclog, but has to be fudged for upper/lower case
155 for cmd in CHOWN MV ; do
157 if [ "$oldcmd" != "look_for_it" ] ; then continue ; fi
158 if [ "$cmd" = "CHOWN" ] ; then cmdlc="chown" ; fi
159 if [ "$cmd" = "MV" ] ; then cmdlc="mv" ; fi
161 for dir in /bin /usr/bin /usr/sbin /usr/etc ; do
162 if [ -f $dir/$cmdlc ] ; then
170 # See if the exim monitor has been built
172 if [ -f eximon -a -f eximon.bin ]; then
173 exim_monitor="eximon eximon.bin"
176 # If bin directory doesn't exist, try to create it
178 if [ ! -d "${BIN_DIRECTORY}" ]; then
179 echo mkdir -p ${BIN_DIRECTORY}
180 ${real} mkdir -p ${BIN_DIRECTORY}
181 if [ $? -ne 0 ]; then
183 echo $com "*** Exim installation ${ver}failed ***"
186 ${real} echo $com ${BIN_DIRECTORY} created
190 # If no arguments, install everything
192 if [ $# -gt 0 ]; then
195 set exim${EXE} ${exim_monitor} exim_dumpdb${EXE} exim_fixdb${EXE} \
196 exim_tidydb${EXE} exinext exiwhat exim_dbmbuild${EXE} exicyclog \
197 exigrep eximstats exipick exiqgrep exiqsumm exim_lock${EXE} \
202 echo $com Installation directory is ${BIN_DIRECTORY}
205 while [ $# -gt 0 ]; do
209 if [ ! -s ${name} ]; then
211 echo $com "*** `pwd`/${name} does not exist or is empty"
212 echo $com "*** Have you built Exim successfully?"
213 echo $com "*** Exim installation ${ver}failed ***"
217 # The exim binary is handled specially
219 if [ $name = exim${EXE} ]; then
220 exim="./exim -bV -C /dev/null"
221 version=exim-`$exim 2>/dev/null | \
222 awk '/Exim version/ { OFS=""; print $3,"-",substr($4,2,length($4)-1) }'`${EXE}
224 if [ "${version}" = "exim-${EXE}" ]; then
226 echo $com "*** Could not run $exim to find version number ***"
227 echo $com "*** Exim installation ${ver}failed ***"
232 # Do something only if newer than existing file, or no existing file
234 if ../scripts/newer ${name} ${BIN_DIRECTORY}/${version}; then
235 echo ${CP} ${name} ${BIN_DIRECTORY}/${version}
236 ${real} ${CP} ${name} ${BIN_DIRECTORY}/${version}
237 if [ $? -ne 0 ]; then
239 echo $com "*** Exim installation ${ver}failed ***"
243 # After copy, set ownership and permissions, unless disabled
245 if [ "$do_chown" != "no" ]; then
246 echo ${CHOWN} ${INST_UID} ${BIN_DIRECTORY}/${version}
247 ${real} ${CHOWN} ${INST_UID} ${BIN_DIRECTORY}/${version}
248 if [ $? -ne 0 ]; then
250 echo $com "*** You must be ${INST_UID} to install exim ***"
253 echo ${CHMOD} a+x ${BIN_DIRECTORY}/${version}
254 ${real} ${CHMOD} a+x ${BIN_DIRECTORY}/${version}
255 if [ $? -ne 0 ]; then
257 echo $com "*** Exim installation ${ver}failed ***"
260 echo ${CHMOD} u+s ${BIN_DIRECTORY}/${version}
261 ${real} ${CHMOD} u+s ${BIN_DIRECTORY}/${version}
262 if [ $? -ne 0 ]; then
264 echo $com "*** Exim installation ${ver}failed ***"
268 echo $com "$CHOWN $INST_UID omitted: -no_chown was specified"
269 echo $com "$CHMOD u+s omitted: -no_chown was specified"
272 # Now sort out the "exim" alias, unless NO_SYMLINK is set.
274 if [ "X$NO_SYMLINK" = "X" ] && [ "$do_symlink" != "no" ] ; then
276 # First check whether "exim" exists in the directory.
277 if [ -f ${BIN_DIRECTORY}/exim ]; then
279 # If it's not a symbolic link, make a copy with the old version number
280 if [ `ls -l ${BIN_DIRECTORY}/exim | cut -c1-1` != 'l' ]; then
281 oldversion=exim-`${BIN_DIRECTORY}/exim -bV -C /dev/null | \
282 awk '/Exim version/ { OFS=""; print $3,"-",substr($4,2,length($4)-1) }'`${EXE}
283 if [ "${version}" = "${oldversion}" ] ; then
285 echo $com "*** Existing file called exim has the same version and compile number ***"
286 echo $com "*** Exim installation ${ver}failed ***"
289 echo ${CP} ${BIN_DIRECTORY}/exim ${BIN_DIRECTORY}/${oldversion}
290 ${real} ${CP} ${BIN_DIRECTORY}/exim ${BIN_DIRECTORY}/${oldversion}
291 if [ $? -ne 0 ]; then
293 echo $com "*** Exim installation ${ver}failed ***"
298 # Now we can move the name "exim" to be a symbolic link to the new
299 # version, atomically.
301 echo \(cd ${BIN_DIRECTORY}\; ${LN} -s ${version} temporary_exim\)
302 (${real} cd ${BIN_DIRECTORY}; ${real} ${LN} -s ${version} temporary_exim)
303 if [ $? -ne 0 ]; then
305 echo $com "*** Exim installation ${ver}failed ***"
309 echo ${MV} -f ${BIN_DIRECTORY}/temporary_exim ${BIN_DIRECTORY}/exim
310 ${real} ${MV} -f ${BIN_DIRECTORY}/temporary_exim ${BIN_DIRECTORY}/exim
311 if [ $? -ne 0 ]; then
313 echo $com "*** Exim installation ${ver}failed ***"
317 # If "exim" does not already exist just create a symbolic link.
320 echo \(cd ${BIN_DIRECTORY}\; ${LN} -s ${version} exim\)
321 (${real} cd ${BIN_DIRECTORY}; ${real} ${LN} -s ${version} exim)
322 if [ $? -ne 0 ]; then
324 echo $com "*** Exim installation ${ver}failed ***"
330 echo $com "creation of symlink omitted"
331 if [ "X$NO_SYMLINK" != "X" ] ; then
332 echo $com "(NO_SYMLINK is specified in Local/Makefile)"
334 echo $com "(-no_symlink was specified)"
338 # New binary is not newer than the installed file
341 echo $com ${name} is not newer than ${BIN_DIRECTORY}/${version}
344 # Handle everything other than the exim binary itself
347 if ../scripts/newer ${name} ${BIN_DIRECTORY}/${name}; then
348 if [ -f ${BIN_DIRECTORY}/${name} ]; then
349 echo ${CP} ${BIN_DIRECTORY}/${name} ${BIN_DIRECTORY}/${name}.O
350 ${real} ${CP} ${BIN_DIRECTORY}/${name} ${BIN_DIRECTORY}/${name}.O
351 if [ $? -ne 0 ]; then
353 echo $com "*** Exim installation ${ver}failed ***"
357 echo ${CP} ${name} ${BIN_DIRECTORY}
358 ${real} ${CP} ${name} ${BIN_DIRECTORY}
359 if [ $? -ne 0 ]; then
361 echo $com "*** Exim installation ${ver}failed ***"
365 echo $com ${name} is not newer than ${BIN_DIRECTORY}/${name}
373 # If there is no configuration file, install the default, modifying it to refer
374 # to the configured system aliases file. If there is no setting for
375 # SYSTEM_ALIASES_FILE, use the traditional /etc/aliases. If the file does not
376 # exist, install a default (dummy) for that too.
378 # However, if CONFIGURE_FILE specifies a list of files, skip this code.
382 if [ `expr -- "${CONFIGURE_FILE}" : ".*:"` -ne 0 ] ; then
383 echo $com Runtime configuration is specified as the following list:
384 echo $com ' ' ${CONFIGURE_FILE}
385 echo $com Therefore, skipping automatic installation.
387 elif [ ! -f ${CONFIGURE_FILE} ]; then
388 echo $com Installing default configuration in ${CONFIGURE_FILE}
389 echo $com because there is no existing configuration file.
390 if [ "${SYSTEM_ALIASES_FILE}" = "" ] ; then
391 SYSTEM_ALIASES_FILE=/etc/aliases
392 echo $com This configuration has system aliases in ${SYSTEM_ALIASES_FILE}.
395 echo ${MKDIR} -p `${DIRNAME} ${CONFIGURE_FILE}`
396 ${real} ${MKDIR} -p `${DIRNAME} ${CONFIGURE_FILE}`
399 echo " \"/SYSTEM_ALIASES_FILE/ s'SYSTEM_ALIASES_FILE'${ACTUAL_SYSTEM_ALIASES_FILE}'\"" '\\'
400 echo " ../src/configure.default > \${CONFIGURE_FILE}"
402 # I can't find a way of writing this using the ${real} feature because
403 # it seems that the output redirection always happens, even when -n was
404 # specified. So control it the hard way.
406 if [ "$real" = "" ] ; then
408 "/SYSTEM_ALIASES_FILE/ s'SYSTEM_ALIASES_FILE'${ACTUAL_SYSTEM_ALIASES_FILE}'" \
409 ../src/configure.default > ${CONFIGURE_FILE}
414 if [ $? -ne 0 ]; then
416 echo $com "*** Exim installation ${ver}failed ***"
419 if [ ! -f ${SYSTEM_ALIASES_FILE} ]; then
421 echo $com Installing a dummy ${SYSTEM_ALIASES_FILE} file because you do not have
422 echo $com one, and the default configuration requires it. You should
423 echo $com edit ${SYSTEM_ALIASES_FILE} and at least create an alias for postmaster.
425 echo ${CP} ../src/aliases.default ${SYSTEM_ALIASES_FILE}
426 ${real} ${CP} ../src/aliases.default ${SYSTEM_ALIASES_FILE}
430 echo $com Configuration file ${CONFIGURE_FILE} already exists
433 # Install info files if the directory is defined and the Texinfo
434 # source documentation is present.
436 if [ "${INFO_DIRECTORY}" != "" -a -f ../doc/spec.texinfo ] ; then
438 if [ ! -d "${INFO_DIRECTORY}" ] ; then
439 echo mkdir -p ${INFO_DIRECTORY}
440 ${real} mkdir -p ${INFO_DIRECTORY}
441 if [ $? -ne 0 ]; then
443 echo $com "*** Exim installation ${ver}failed ***"
446 echo $com ${INFO_DIRECTORY} created
450 echo $com Info installation directory is ${INFO_DIRECTORY}
453 ${real} makeinfo --no-split --output exim.info ../doc/spec.texinfo
454 echo ${CP} exim.info ${INFO_DIRECTORY}
455 ${real} ${CP} exim.info ${INFO_DIRECTORY}
456 ${real} install-info --section="Exim" \
457 --entry "* User guide: (exim). Exim manual" \
458 ${INFO_DIRECTORY}/exim.info ${INFO_DIRECTORY}/dir
459 ${real} makeinfo --no-split --output exim_filter.info ../doc/filter.texinfo
460 echo ${CP} exim_filter.info ${INFO_DIRECTORY}
461 ${real} ${CP} exim_filter.info ${INFO_DIRECTORY}
462 ${real} install-info --section="Exim" \
463 --entry "* Filtering: (exim_filter). Filtering mail with Exim" \
464 ${INFO_DIRECTORY}/exim_filter.info ${INFO_DIRECTORY}/dir
470 echo $com Exim installation ${ver}complete
472 # End of exim_install