--removecomments - Remove comment lines
-o|--output file - write output to file instead of ${UPEX4C_outputfile}
-d|--confdir directory - read input from given directory instead of ${UPEX4C_confdir}
+ --check - Test generated file for validity and remove it again.
EOF
}
## Parse commandline
TEMP=$(getopt -n update-exim4.conf \
- -l keepcomments,removecomments,output:,confdir:,help,verbose -- \
+ -l check,keepcomments,removecomments,output:,confdir:,help,verbose -- \
+o:d:vh "$@")
if test "$?" != 0; then
--removecomments)
UPEX4C_comments=no
;;
+ --check)
+ UPEX4C_check=yes
+ ;;
-o|--output)
shift
UPEX4C_outputfile="$1"
exit 1
fi
+
+UPEX4C_autoconfigfile=/var/lib/exim4/config.autogenerated
+if [ "$(dirname ${UPEX4C_outputfile})" = "/var/lib/exim4" ] ; then
+ UPEX4C_tmp="${UPEX4C_outputfile}.tmp"
+else
+ UPEX4C_tmp="$(tempfile -m600 -p ex4)"
+fi
+
lowerpipe() {
tr 'A-Z' 'a-z'
}
local_domains="$(echo @:localhost:"${dc_other_hostnames}" | \
sed -e 's/[;: ]*$//' -e 's/ *//' -e 's/;/:/g')"
-UPEX4C_internal_tmp="$(tempfile -m600 -p ex4)"
-
-trap "rm -f ${UPEX4C_internal_tmp}" EXIT INT TERM
# run-parts emulation, stolen from Branden's /etc/X11/Xsession
# Addition: Use file.rul instead if file if it exists.
}
gentmpconf() {
- rm -f "${UPEX4C_outputfile}.tmp"
- touch "${UPEX4C_outputfile}.tmp"
+ rm -f "${UPEX4C_tmp}"
+ touch "${UPEX4C_tmp}"
# this can be removed by the end of 2007
#chown --reference=${TEMPLATEFILE} \
- # ${UPEX4C_outputfile}.tmp ${UPEX4C_outputfile}
+ # ${UPEX4C_tmp} ${UPEX4C_outputfile}
#chmod --reference=${TEMPLATEFILE} \
- # ${UPEX4C_outputfile}.tmp ${UPEX4C_outputfile}
+ # ${UPEX4C_tmp} ${UPEX4C_outputfile}
if [ "$(id -u)" = "0" ]; then
- chown root:Debian-exim "${UPEX4C_outputfile}.tmp"
+ chown root:Debian-exim "${UPEX4C_tmp}"
[ -e "${UPEX4C_outputfile}" ] && \
chown root:Debian-exim "${UPEX4C_outputfile}"
fi
- chmod 640 "${UPEX4C_outputfile}.tmp"
+ chmod 640 "${UPEX4C_tmp}"
if [ -e "${UPEX4C_outputfile}" ]; then
chmod 640 "${UPEX4C_outputfile}"
fi
gentmpconf
-cat << EOF >> "${UPEX4C_outputfile}.tmp"
+cat << EOF >> "${UPEX4C_tmp}"
#########
# WARNING WARNING WARNING
# WARNING WARNING WARNING
EOF
if [ "${dc_use_split_config}" = "true" ] ; then
-cat << EOF >> "${UPEX4C_outputfile}.tmp"
+cat << EOF >> "${UPEX4C_tmp}"
# split config files in the $UPEX4C_confd/ directory.
EOF
else
-cat << EOF >> "${UPEX4C_outputfile}.tmp"
+cat << EOF >> "${UPEX4C_tmp}"
# non-split config ($UPEX4C_confdir/exim4.conf.localmacros
# and $UPEX4C_confdir/exim4.conf.template).
EOF
fi
-cat << EOF >> "${UPEX4C_outputfile}.tmp"
+cat << EOF >> "${UPEX4C_tmp}"
# The config files are supplemented with package installation/configuration
# settings managed by debconf. This data is stored in
# $UPEX4C_confdir/update-exim4.conf.conf
cat_parts "${UPEX4C_confd}/$i"
done | \
removecomments \
- >> "${UPEX4C_outputfile}.tmp"
+ >> "${UPEX4C_tmp}"
else
LOCALMACROS=""
if [ -e "/etc/exim4/exim4.conf.localmacros" ]; then
fi
cat "${LOCALMACROS:-/dev/null}" "${TEMPLATEFILE:-/dev/null}" | \
removecomments \
- >> "${UPEX4C_outputfile}.tmp"
+ >> "${UPEX4C_tmp}"
fi
- mv -f "${UPEX4C_outputfile}.tmp" "${UPEX4C_outputfile}"
+ mv -f "${UPEX4C_tmp}" "${UPEX4C_outputfile}"
chmod "${CFILEMODE}" "${UPEX4C_outputfile}"
[ "${UPEX4C_verbose}" = "yes" ] && \
echo "Not substituting variables since conftype is none (or other)"
done \
| removecomments \
| sed "s|^\(UPEX4CmacrosUPEX4C.*\)$|\1\n$UPEX4C_macros|" \
- >> "${UPEX4C_outputfile}.tmp"
+ >> "${UPEX4C_tmp}"
RELEVANTTEMPLATE="$UPEX4C_confd"
;;
false)
cat "${LOCALMACROS:-/dev/null}" "${TEMPLATEFILE:-/dev/null}" \
| removecomments \
| sed "s|^\(UPEX4CmacrosUPEX4C.*\)$|\1\n$UPEX4C_macros|" \
- >> "${UPEX4C_outputfile}.tmp"
+ >> "${UPEX4C_tmp}"
RELEVANTTEMPLATE="$TEMPLATEFILE"
;;
*)
errormessage "Invalid value for dc_use_split_config: \"${dc_use_split_config}\", exiting."
- rm -f "${UPEX4C_outputfile}.tmp"
+ rm -f "${UPEX4C_tmp}"
exit 1
;;
esac
fi
-# test validity if called without -o
-if [ "${UPEX4C_outputfile}" = "${UPEX4C_autoconfigfile}" ] && \
- [ -x "${EXIM}" ] ; then
- if ! "${EXIM}" -C "${UPEX4C_outputfile}.tmp" -bV > /dev/null ; then
- # we have an error in the configuration file. Do not install
- # and activate. However, errors in string expansions inside
- # the configuration file are not detected by this check!
- errormessage "Invalid new configfile ${UPEX4C_outputfile}.tmp, not installing ${UPEX4C_outputfile}.tmp to ${UPEX4C_outputfile}"
- exit 1
+# test validity if called without -o or if --check was supplied
+if [ "${UPEX4C_outputfile}" = "${UPEX4C_autoconfigfile}" ] || \
+ [ "x${UPEX4C_check}" = "xyes" ]; then
+ if [ -x "${EXIM}" ] ; then
+ if ! "${EXIM}" -C "${UPEX4C_tmp}" -bV > /dev/null ; then
+ # we have an error in the configuration file. Do not install
+ # and activate. However, errors in string expansions inside
+ # the configuration file are not detected by this check!
+ errormessage "Invalid new configfile ${UPEX4C_tmp}, not installing ${UPEX4C_tmp} to ${UPEX4C_outputfile}"
+ exit 1
+ fi
fi
fi
+if [ "x${UPEX4C_check}" = "xyes" ]; then
+ rm -f "${UPEX4C_tmp}"
+ exit 0
+fi
-mv -f "${UPEX4C_outputfile}.tmp" "${UPEX4C_outputfile}"
+mv -f "${UPEX4C_tmp}" "${UPEX4C_outputfile}"
chmod "${CFILEMODE}" "${UPEX4C_outputfile}"
# end of file