2 # $Cambridge: exim/src/scripts/exim_install,v 1.2 2005/09/06 13:18:13 ph10 Exp $
4 # Script to install Exim binaries in BIN_DIRECTORY, which is defined in
5 # the local Makefile. It expects to be run in a build directory. It needs
6 # to be run as root in order to make exim setuid to root. If exim runs setuid
7 # to (e.g.) exim, this script should be run as that user or root.
9 # This script also installs a default configuration file in CONFIGURE_FILE
10 # if there is no configuration file there, but only if CONFIGURE_FILE specifies
11 # single file. If it specifies a list, no action is taken.
13 # If a default configuration file is installed, the existence of the system
14 # aliases file is tested. A default, containing only comments, is installed if
17 # If INFO_DIRECTORY is defined in any of the local Makefiles, and the Exim doc
18 # directory contains the Texinfo documentation, this script also installs a
19 # the info files in INFO_DIRECTORY.
21 # If DESTDIR is defined, all file paths are prefixed with ${DESTDIR}, with the
22 # sole exception of the reference to the system aliases file in the default
23 # configuration, because it is assumed that Exim is not actually going to be
24 # run from this position. For backward compatibility, if DESTDIR is not
25 # defined, ROOT is used instead.
27 # The script can be made to output what it would do, without actually doing
28 # anything, by giving it the option "-n" (cf make). Arguments are the names
29 # of things to install. No arguments installs everything.
34 while [ $# -gt 0 ] ; do
41 echo $com "*** Verification mode only: no commands will actually be obeyed"
42 echo $com "*** You can cut and paste the bits you want to a shell, etc"
62 # Get the values of BIN_DIRECTORY, CONFIGURE_FILE, INFO_DIRECTORY, NO_SYMLINK,
63 # SYSTEM_ALIASES_FILE, and EXE from the global Makefile (in the build
64 # directory). EXE is empty except in the Cygwin environment. In each case, keep
65 # the latest definition, thus respecting the Makefiles precedence. The sed
66 # sequences here are messy, but have to be very "basic" in order to work on
67 # Solaris, where the regular expressions in sed are primitive indeed. Modify at
70 BIN_DIRECTORY
=`sed -n -e '/^ *BIN_DIRECTORY *=/{s/^[^=]*= *//; s/ \{1,\}#.*//;s/ *$//;h;}' -e '${g;p;}' Makefile`
71 CONFIGURE_FILE
=`sed -n -e '/^ *CONFIGURE_FILE *=/{s/^[^=]*= *//; s/ \{1,\}#.*//;s/ *$//;h;}' -e '${g;p;}' Makefile`
72 INFO_DIRECTORY
=`sed -n -e '/^ *INFO_DIRECTORY *=/{s/^[^=]*= *//; s/ \{1,\}#.*//;s/ *$//;h;}' -e '${g;p;}' Makefile`
73 NO_SYMLINK
=`sed -n -e '/^ *NO_SYMLINK *=/{s/^[^=]*= *//; s/ \{1,\}#.*//;s/ *$//;h;}' -e '${g;p;}' Makefile`
75 CHOWN
=`sed -n -e '/^ *CHOWN_COMMAND *=/{s/^[^=]*= *//; s/ \{1,\}#.*//;s/ *$//;h;}' -e '${g;p;}' Makefile`
76 MV
=`sed -n -e '/^ *MV_COMMAND *=/{s/^[^=]*= *//; s/ \{1,\}#.*//;s/ *$//;h;}' -e '${g;p;}' Makefile`
78 SYSTEM_ALIASES_FILE
=`sed -n -e '/^ *SYSTEM_ALIASES_FILE *=/{s/^[^=]*= *//; s/ \{1,\}#.*//;s/ *$//;h;}' -e '${g;p;}' Makefile`
79 EXE
=`sed -n -e '/^ *EXE *=/{s/^[^=]*= *//; s/ \{1,\}#.*//;s/ *$//;h;}' -e '${g;p;}' Makefile`
81 # Set a default for SYSTEM_ALIASES_FILE
83 if [ "${SYSTEM_ALIASES_FILE}" = "" ] ; then
84 SYSTEM_ALIASES_FILE
=/etc
/aliases
87 # Allow INST_xx to over-ride xx
88 case "$INST_BIN_DIRECTORY" in ?
*) BIN_DIRECTORY
="$INST_BIN_DIRECTORY";; esac
89 case "$INST_CONFIGURE_FILE" in ?
*) CONFIGURE_FILE
="$INST_CONFIGURE_FILE";; esac
90 case "$INST_INFO_DIRECTORY" in ?
*) INFO_DIRECTORY
="$INST_INFO_DIRECTORY";; esac
91 case "$INST_SYSTEM_ALIASES_FILE" in ?
*) SYSTEM_ALIASES_FILE
="$INST_SYSTEM_ALIASES_FILE";; esac
93 case "$INST_CHOWN" in ?
*) CHOWN
="$INST_CHOWN";; esac
94 case "$INST_MV" in ?
*) MV
="$INST_MV";; esac
96 case "$INST_UID" in '') INST_UID
=root
;; *) INST_UID
="$INST_UID";; esac
97 case "$INST_CP" in '') CP
=cp;; *) CP
="$INST_CP";; esac
98 case "$INST_LN" in '') LN
=ln;; *) LN
="$INST_LN";; esac
99 case "$INST_CHMOD" in '') CHMOD
=chmod;; *) CHMOD
="$INST_CHMOD";; esac
100 case "$INST_DIRNAME" in '') DIRNAME
=dirname;; *) DIRNAME
="$INST_DIRNAME";; esac
101 case "$INST_MKDIR" in '') MKDIR
=mkdir
;; *) MKDIR
="$INST_MKDIR";; esac
103 # Allow the user to over-ride xx
104 case "$inst_dest" in ?
*) BIN_DIRECTORY
="$inst_dest";; esac
105 case "$inst_conf" in ?
*) CONFIGURE_FILE
="$inst_conf";; esac
106 case "$inst_info" in ?
*) INFO_DIRECTORY
="$inst_info";; esac
107 case "$inst_aliases" in ?
*) SYSTEM_ALIASES_FILE
="$inst_aliases";; esac
109 # Insert ${DESTDIR} at the start of all paths so that the whole thing can be
110 # installed under a different file root. For backwards compatibility, use
111 # ${ROOT} if ${DESTDIR} is not set. However, we need to save the value of
112 # the real system aliases file, and use that in the default configuration.
114 ACTUAL_SYSTEM_ALIASES_FILE
=${SYSTEM_ALIASES_FILE}
115 DESTDIR
=${DESTDIR:-${ROOT}}
117 BIN_DIRECTORY
=${DESTDIR}${BIN_DIRECTORY}
118 CONFIGURE_FILE
=${DESTDIR}${CONFIGURE_FILE}
119 SYSTEM_ALIASES_FILE
=${DESTDIR}${SYSTEM_ALIASES_FILE}
121 if [ "${INFO_DIRECTORY}" != "" ] ; then
122 INFO_DIRECTORY
=${DESTDIR}${INFO_DIRECTORY}
125 # Overrides of other things
126 case "$inst_uid" in ?
*) INST_UID
="$inst_uid";; esac
127 case "$inst_cp" in ?
*) CP
="$inst_cp";; esac
128 case "$inst_mv" in ?
*) MV
="$inst_mv";; esac
129 case "$inst_ln" in ?
*) LN
="$inst_ln";; esac
130 case "$inst_chown" in ?
*) CHOWN
="$inst_chown";; esac
131 case "$inst_chmod" in ?
*) CHMOD
="$inst_chmod";; esac
132 case "$inst_dirname" in ?
*) DIRNAME
="$inst_dirname";; esac
133 case "$inst_mkdir" in ?
*) MKDIR
="$inst_mkdir";; esac
135 # chown is a special case; in at least one OS it is in /usr/etc instead
136 # of in /usr/bin, and therefore not likely to be on the path. Another OS
137 # has it in /usr/sbin. This fudge tries to cope with these variations.
139 # Otherwise, and for other commands, we assume that the normal PATH will
140 # give access to where they are on your operating system (normally /usr/bin
143 if [ "${CHOWN}" = "chown" -a -x /usr
/sbin
/chown
] ; then
144 CHOWN
=/usr
/sbin
/chown
147 if [ "${CHOWN}" = "chown" -a ! -f /usr
/bin
/chown
-a -f /usr
/etc
/chown
] ; then
151 # The values of CHOWN and MV taken from the Makefile are sometimes set to
152 # "look_for_it", which causes a search of the usual suspects. This code is
153 # similar to that in exicyclog, but has to be fudged for upper/lower case
156 for cmd
in CHOWN MV
; do
158 if [ "$oldcmd" != "look_for_it" ] ; then continue ; fi
159 if [ "$cmd" = "CHOWN" ] ; then cmdlc
="chown" ; fi
160 if [ "$cmd" = "MV" ] ; then cmdlc
="mv" ; fi
162 for dir
in /bin
/usr
/bin
/usr
/sbin
/usr
/etc
; do
163 if [ -f $dir/$cmdlc ] ; then
171 # See if the exim monitor has been built
173 if [ -f eximon
-a -f eximon.bin
]; then
174 exim_monitor
="eximon eximon.bin"
177 # If bin directory doesn't exist, try to create it
179 if [ ! -d "${BIN_DIRECTORY}" ]; then
180 echo mkdir
-p ${BIN_DIRECTORY}
181 ${real} mkdir
-p ${BIN_DIRECTORY}
182 if [ $?
-ne 0 ]; then
184 echo $com "*** Exim installation ${ver}failed ***"
187 ${real} echo $com ${BIN_DIRECTORY} created
191 # If no arguments, install everything
193 if [ $# -gt 0 ]; then
196 set exim
${EXE} ${exim_monitor} exim_dumpdb${EXE} exim_fixdb${EXE} \
197 exim_tidydb
${EXE} exinext exiwhat exim_dbmbuild
${EXE} exicyclog \
198 exigrep eximstats exipick exiqgrep exiqsumm exim_lock
${EXE} \
203 echo $com Installation directory is
${BIN_DIRECTORY}
206 while [ $# -gt 0 ]; do
210 if [ ! -s ${name} ]; then
212 echo $com "*** `pwd`/${name} does not exist or is empty"
213 echo $com "*** Have you built Exim successfully?"
214 echo $com "*** Exim installation ${ver}failed ***"
218 # The exim binary is handled specially
220 if [ $name = exim
${EXE} ]; then
221 version
=exim-
`./exim -bV -C /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 ***"
231 # Do something only if newer than existing file, or no existing file
233 if ..
/scripts
/newer
${name} ${BIN_DIRECTORY}/${version}; then
234 echo ${CP} ${name} ${BIN_DIRECTORY}/${version}
235 ${real} ${CP} ${name} ${BIN_DIRECTORY}/${version}
236 if [ $?
-ne 0 ]; then
238 echo $com "*** Exim installation ${ver}failed ***"
242 # After copy, set ownership and permissions, unless disabled
244 if [ "$do_chown" != "no" ]; then
245 echo ${CHOWN} ${INST_UID} ${BIN_DIRECTORY}/${version}
246 ${real} ${CHOWN} ${INST_UID} ${BIN_DIRECTORY}/${version}
247 if [ $?
-ne 0 ]; then
249 echo $com "*** You must be ${INST_UID} to install exim ***"
252 echo ${CHMOD} a+x ${BIN_DIRECTORY}/${version}
253 ${real} ${CHMOD} a+x ${BIN_DIRECTORY}/${version}
254 if [ $?
-ne 0 ]; then
256 echo $com "*** Exim installation ${ver}failed ***"
259 echo ${CHMOD} u+s ${BIN_DIRECTORY}/${version}
260 ${real} ${CHMOD} u+s ${BIN_DIRECTORY}/${version}
261 if [ $?
-ne 0 ]; then
263 echo $com "*** Exim installation ${ver}failed ***"
267 echo $com "$CHOWN $INST_UID omitted: -no_chown was specified"
268 echo $com "$CHMOD u+s omitted: -no_chown was specified"
271 # Now sort out the "exim" alias, unless NO_SYMLINK is set.
273 if [ "X$NO_SYMLINK" = "X" ] && [ "$do_symlink" != "no" ] ; then
275 # First check whether "exim" exists in the directory.
276 if [ -f ${BIN_DIRECTORY}/exim
]; then
278 # If it's not a symbolic link, make a copy with the old version number
279 if [ `ls -l ${BIN_DIRECTORY}/exim | cut -c1-1` != 'l' ]; then
280 oldversion
=exim-
`${BIN_DIRECTORY}/exim -bV -C /dev/null | \
281 awk '/Exim version/ { OFS=""; print $3,"-",substr($4,2,length($4)-1) }'`${EXE}
282 if [ "${version}" = "${oldversion}" ] ; then
284 echo $com "*** Existing file called exim has the same version and compile number ***"
285 echo $com "*** Exim installation ${ver}failed ***"
288 echo ${CP} ${BIN_DIRECTORY}/exim ${BIN_DIRECTORY}/${oldversion}
289 ${real} ${CP} ${BIN_DIRECTORY}/exim ${BIN_DIRECTORY}/${oldversion}
290 if [ $?
-ne 0 ]; then
292 echo $com "*** Exim installation ${ver}failed ***"
297 # Now we can move the name "exim" to be a symbolic link to the new
298 # version, atomically.
300 echo \
(cd ${BIN_DIRECTORY}\; ${LN} -s ${version} temporary_exim\
)
301 (${real} cd ${BIN_DIRECTORY}; ${real} ${LN} -s ${version} temporary_exim
)
302 if [ $?
-ne 0 ]; then
304 echo $com "*** Exim installation ${ver}failed ***"
308 echo ${MV} -f ${BIN_DIRECTORY}/temporary_exim ${BIN_DIRECTORY}/exim
309 ${real} ${MV} -f ${BIN_DIRECTORY}/temporary_exim ${BIN_DIRECTORY}/exim
310 if [ $?
-ne 0 ]; then
312 echo $com "*** Exim installation ${ver}failed ***"
316 # If "exim" does not already exist just create a symbolic link.
319 echo \
(cd ${BIN_DIRECTORY}\; ${LN} -s ${version} exim\
)
320 (${real} cd ${BIN_DIRECTORY}; ${real} ${LN} -s ${version} exim
)
321 if [ $?
-ne 0 ]; then
323 echo $com "*** Exim installation ${ver}failed ***"
329 echo $com "creation of symlink omitted"
330 if [ "X$NO_SYMLINK" != "X" ] ; then
331 echo $com "(NO_SYMLINK is specified in Local/Makefile)"
333 echo $com "(-no_symlink was specified)"
337 # New binary is not newer than the installed file
340 echo $com ${name} is not newer than ${BIN_DIRECTORY}/${version}
343 # Handle everything other than the exim binary itself
346 if ..
/scripts
/newer
${name} ${BIN_DIRECTORY}/${name}; then
347 if [ -f ${BIN_DIRECTORY}/${name} ]; then
348 echo ${CP} ${BIN_DIRECTORY}/${name} ${BIN_DIRECTORY}/${name}.O
349 ${real} ${CP} ${BIN_DIRECTORY}/${name} ${BIN_DIRECTORY}/${name}.O
350 if [ $?
-ne 0 ]; then
352 echo $com "*** Exim installation ${ver}failed ***"
356 echo ${CP} ${name} ${BIN_DIRECTORY}
357 ${real} ${CP} ${name} ${BIN_DIRECTORY}
358 if [ $?
-ne 0 ]; then
360 echo $com "*** Exim installation ${ver}failed ***"
364 echo $com ${name} is not newer than ${BIN_DIRECTORY}/${name}
372 # If there is no configuration file, install the default, modifying it to refer
373 # to the configured system aliases file. If there is no setting for
374 # SYSTEM_ALIASES_FILE, use the traditional /etc/aliases. If the file does not
375 # exist, install a default (dummy) for that too.
377 # However, if CONFIGURE_FILE specifies a list of files, skip this code.
381 if [ `expr "${CONFIGURE_FILE}" : ".*:"` -ne 0 ] ; then
382 echo $com Runtime configuration is specified as the following list
:
383 echo $com ' ' ${CONFIGURE_FILE}
384 echo $com Therefore
, skipping automatic installation.
386 elif [ ! -f ${CONFIGURE_FILE} ]; then
387 echo $com Installing default configuration
in ${CONFIGURE_FILE}
388 echo $com because there is no existing configuration
file.
389 if [ "${SYSTEM_ALIASES_FILE}" = "" ] ; then
390 SYSTEM_ALIASES_FILE
=/etc
/aliases
391 echo $com This configuration has system aliases
in ${SYSTEM_ALIASES_FILE}.
394 echo ${MKDIR} -p `${DIRNAME} ${CONFIGURE_FILE}`
395 ${real} ${MKDIR} -p `${DIRNAME} ${CONFIGURE_FILE}`
398 echo " \"/SYSTEM_ALIASES_FILE/ s'SYSTEM_ALIASES_FILE'${ACTUAL_SYSTEM_ALIASES_FILE}'\"" '\\'
399 echo " ../src/configure.default > \${CONFIGURE_FILE}"
401 # I can't find a way of writing this using the ${real} feature because
402 # it seems that the output redirection always happens, even when -n was
403 # specified. So control it the hard way.
405 if [ "$real" = "" ] ; then
407 "/SYSTEM_ALIASES_FILE/ s'SYSTEM_ALIASES_FILE'${ACTUAL_SYSTEM_ALIASES_FILE}'" \
408 ..
/src
/configure.default
> ${CONFIGURE_FILE}
413 if [ $?
-ne 0 ]; then
415 echo $com "*** Exim installation ${ver}failed ***"
418 if [ ! -f ${SYSTEM_ALIASES_FILE} ]; then
420 echo $com Installing a dummy
${SYSTEM_ALIASES_FILE} file because you
do not have
421 echo $com one
, and the default configuration requires it. You should
422 echo $com edit
${SYSTEM_ALIASES_FILE} and
at least create an
alias for postmaster.
424 echo ${CP} ..
/src
/aliases.default
${SYSTEM_ALIASES_FILE}
425 ${real} ${CP} ../src/aliases.default ${SYSTEM_ALIASES_FILE}
429 echo $com Configuration
file ${CONFIGURE_FILE} already exists
432 # Install info files if the directory is defined and the Texinfo
433 # source documentation is present.
435 if [ "${INFO_DIRECTORY}" != "" -a -f ..
/doc
/spec.texinfo
] ; then
437 if [ ! -d "${INFO_DIRECTORY}" ] ; then
438 echo mkdir
-p ${INFO_DIRECTORY}
439 ${real} mkdir
-p ${INFO_DIRECTORY}
440 if [ $?
-ne 0 ]; then
442 echo $com "*** Exim installation ${ver}failed ***"
445 echo $com ${INFO_DIRECTORY} created
449 echo $com Info installation directory is
${INFO_DIRECTORY}
452 ${real} makeinfo
--no-split --output exim.info ..
/doc
/spec.texinfo
453 echo ${CP} exim.info
${INFO_DIRECTORY}
454 ${real} ${CP} exim.info ${INFO_DIRECTORY}
455 ${real} install-info
--section="Exim" \
456 --entry "* User guide: (exim). Exim manual" \
457 ${INFO_DIRECTORY}/exim.info
${INFO_DIRECTORY}/dir
458 ${real} makeinfo
--no-split --output exim_filter.info ..
/doc
/filter.texinfo
459 echo ${CP} exim_filter.info
${INFO_DIRECTORY}
460 ${real} ${CP} exim_filter.info ${INFO_DIRECTORY}
461 ${real} install-info
--section="Exim" \
462 --entry "* Filtering: (exim_filter). Filtering mail with Exim" \
463 ${INFO_DIRECTORY}/exim_filter.info
${INFO_DIRECTORY}/dir
469 echo $com Exim installation
${ver}complete
471 # End of exim_install