5 CONFDIR
="${CONFDIR:-/etc/exim4}"
8 UPEX4CT_outputfile
="${CONFDIR}/exim4.conf.template"
12 $0 - Generate exim4 configuration file template
14 -n|--nobackup - Overwrite old template, do not take backup.
15 -o|--output file - write output to file instead of ${UPEX4CT_outputfile}
16 -h|--help - This message.
17 -r|--run - Actually do something
22 TEMP
=$
(getopt
-n update-exim4.conf.template \
23 -l nobackup
,output
:,help,run
-- \
26 if test "$?" != 0; then
27 echo "Terminating..." >&2
32 while test "$1" != "--"; do
40 UPEX4CT_outputfile
="$1"
53 # No non-option arguments allowed.
54 if [ "$#" -ne 0 ]; then
55 echo "No non option arguments ($@) allowed" >&2
60 # run-parts emulation, stolen from Branden's /etc/X11/Xsession
61 # Addition: Use file.rul instead if file if it exists.
64 unset LANG LC_COLLATE LC_ALL
67 errormessage
"$0: internal run_parts called without an argument"
69 if [ ! -d "$1" ]; then
70 errormessage
"$0: internal run_parts called, but $1 does not exist or is not a directory."
72 for F
in $
(ls $1 |
grep -v /.svn
); do
73 if expr "$F" : '[[:alnum:]_-]\+$' > /dev
/null
2>&1; then
74 if [ -f "$1/$F" ] ; then
75 if [ -f "$1/${F}.rul" ] ; then
86 # pretty-print messages of arbitrary length (no trailing newline)
87 echo "$*" |
fold -s -w ${COLUMNS:-80} >&2;
92 errormessage
"$0: internal cat_parts called without an argument"
94 if [ ! -d "$1" ]; then
95 errormessage
"$0: internal cat_parts called, but $1 does not exist or is not a directory."
97 for file in $
(run_parts
$1); do
98 echo "#####################################################"
100 echo "#####################################################"
102 echo "#####################################################"
104 echo "#####################################################"
108 if [ "$DONOTRUN" = "true" ]; then
109 errormessage
"This program overwrites conffiles. Do not run unless you have consulted the manpage." >&2
110 echo "Terminating..." >&2
115 if [ -e "${UPEX4CT_outputfile}" ] && [ -z "$NOBACKUP" ]; then
116 if [ -e "${UPEX4CT_outputfile}.bak.$$" ]; then
117 echo >&2 "ERR: ${UPEX4CT_outputfile}.bak.$$ already exists, aborting"
122 NEWTEMPLATE
=$
(tempfile
-m644 -p ex4
)
123 if [ -f "${UPEX4CT_outputfile}" ] ; then
124 chmod --reference="${UPEX4CT_outputfile}" "$NEWTEMPLATE"
127 # generate .template. Ugly - better alternative?
130 for i
in main acl router transport retry rewrite auth
; do
132 done > "$NEWTEMPLATE"
135 if [ -e "${UPEX4CT_outputfile}" ] && [ -z "$NOBACKUP" ] ; then
136 mv "${UPEX4CT_outputfile}" \
137 "${UPEX4CT_outputfile}.bak.$$"
139 mv "$NEWTEMPLATE" "${UPEX4CT_outputfile}"