Import Debian changes 4.92-8+deb10u3
[hcoop/debian/exim4.git] / debian / update-exim4defaults
CommitLineData
de45f55a
AM
1#!/bin/sh
2# update-exim4defaults(8): manage entries in /etc/default/exim4
3# per script
4
5if [ -n "$EX4DEBUG" ]; then
6 echo "now debugging $0 $@"
7 set -x
8fi
9
10unset LC_ALL
11export LC_CTYPE=C
12
13defaultfile=/etc/default/exim4
14
15EX4DEF_INIT=false
16EX4DEF_FORCE=false
17
18
19if [ -r ${defaultfile} ]; then
20 . ${defaultfile}
21fi
22
23
24# initialize variables
25EX4DEF_QUEUERUNNER="${QUEUERUNNER}"
26EX4DEF_QUEUEINTERVAL="${QUEUEINTERVAL}"
27EX4DEF_COMMONOPTIONS="${COMMONOPTIONS}"
28EX4DEF_QUEUERUNNEROPTIONS="${QUEUERUNNEROPTIONS}"
29EX4DEF_QFLAGS="${QFLAGS}"
30EX4DEF_SMTPLISTENEROPTIONS="${SMTPLISTENEROPTIONS}"
31
32EX4DEF_FLAGOPTIONS=false
33EX4DEF_FLAGREMOVE=false
34
35ex4def_usage ()
36{
37 echo "update-exim4defaults: manage entries in /etc/default/exim4"
38 echo " usage: update-exim4defaults [[--queuerunner combined|separate|queueonly|ppp|no|nodaemon]"
39 echo " [--qflags flags ] [--queuetime time] [--commonoptions options]"
40 echo " [--queuerunneroptions options] [--smtplisteneroptions options]]"
41 echo " [--remove-common options] [--remove-queue options]"
42 echo " [--remove-smtp options]"
43 echo " [--force|-f] [--help|-h]"
44 echo " [--init]"
45}
46
47
48# used for initialzing and with --force.
49ex4def_write(){
50 EX4DEF_TMP="$(tempfile -m 600 -p ex4)"
51 cat << EOF > "${EX4DEF_TMP}"
52# /etc/default/exim4
53EX4DEF_VERSION='${EX4DEF_VERSION}'
54
55# 'combined' - one daemon running queue and listening on SMTP port
56# 'no' - no daemon running the queue
57# 'separate' - two separate daemons
58# 'ppp' - only run queue with /etc/ppp/ip-up.d/exim4.
59# 'nodaemon' - no daemon is started at all.
60# 'queueonly' - only a queue running daemon is started, no SMTP listener.
61# setting this to 'no' will also disable queueruns from /etc/ppp/ip-up.d/exim4
62QUEUERUNNER='${EX4DEF_QUEUERUNNER}'
63# how often should we run the queue
64QUEUEINTERVAL='${EX4DEF_QUEUEINTERVAL}'
65# options common to quez-runner and listening daemon
66COMMONOPTIONS='${EX4DEF_COMMONOPTIONS}'
67# more options for the daemon/process running the queue (applies to the one
68# started in /etc/ppp/ip-up.d/exim4, too.
69QUEUERUNNEROPTIONS='${EX4DEF_QUEUERUNNEROPTIONS}'
70# special flags given to exim directly after the -q. See exim(8)
71QFLAGS='${EX4DEF_QFLAGS}'
72# Options for the SMTP listener daemon. By default, it is listening on
73# port 25 only. To listen on more ports, it is recommended to use
0baa7b9d 74# -oX 25:587:10025 -oP /run/exim4/exim.pid
de45f55a
AM
75SMTPLISTENEROPTIONS='${EX4DEF_SMTPLISTENEROPTIONS}'
76EOF
77 cat "${EX4DEF_TMP}" > "${defaultfile}"
78 rm -f "${EX4DEF_TMP}"
79}
80
81## Parse commandline
82TEMP=$(getopt -n update-exim4defaults \
83 -l qflags:,queuerunner:,queuetime:,commonoptions:,queuerunneroptions:,smtplisteneroptions:,remove-common:,remove-queue:,remove-smtp:,force,help,init -- \
84 +fh "$@")
85
86if test "$?" != 0; then
87 echo "Terminating..." >&2
88 exit 1
89fi
90
91eval set -- ${TEMP}
92while test "$1" != "--"; do
93 case $1 in
94 -f|--force)
95 EX4DEF_FORCE=true
96 ;;
97 -h|--help)
98 ex4def_usage
99 exit 0
100 ;;
101 --qflags)
102 shift
103 EX4DEF_QFLAGS="$1"
104 ;;
105 --queuerunner)
106 shift
107 EX4DEF_QUEUERUNNER="$1"
108 if ! expr match "${EX4DEF_QUEUERUNNER}" '\(ppp\|no\|combined\|nodaemon\|queueonly\|separate\)$' >/dev/null ; then
109 echo "invalid argument ${EX4DEF_QUEUERUNNER} for --queuerunner" 1>&2
110 exit 1
111 fi
112 ;;
113 --queuetime)
114 shift
115 EX4DEF_QUEUEINTERVAL="$1"
116 ;;
117 --commonoptions)
118 shift
119 EX4DEF_COMMONOPTIONS="$1"
120 EX4DEF_FLAGOPTIONS=true
121 ;;
122 --queuerunneroptions)
123 shift
124 EX4DEF_QUEUERUNNEROPTIONS="$1"
125 EX4DEF_FLAGOPTIONS=true
126 ;;
127 --smtplisteneroptions)
128 shift
129 EX4DEF_SMTPLISTENEROPTIONS="$1"
130 EX4DEF_FLAGOPTIONS=true
131 ;;
132 --remove-common)
133 shift
134 EX4DEF_REMOVECOMMON="$1"
135 EX4DEF_FLAGREMOVE=true
136 ;;
137 --remove-queue)
138 shift
139 EX4DEF_REMOVEQUEUE="$1"
140 EX4DEF_FLAGREMOVE=true
141 ;;
142 --remove-smtp)
143 shift
144 EX4DEF_REMOVESMTP="$1"
145 EX4DEF_FLAGREMOVE=true
146 ;;
147 --init)
148 EX4DEF_INIT=true
149 ;;
150 esac
151 shift
152done
153shift
154
155# No non-option arguments allowed.
156if [ "$#" -ne 0 ]; then
157 echo "No non option arguments allowed" >&2
158 ex4def_usage >&2
159 exit 1
160fi
161
162if [ "${EX4DEF_FLAGREMOVE}" = "true" ] && [ "${EX4DEF_FLAGOPTIONS}" = "true" ] ; then
163 echo "Cannot use --remove-something together with --somethingoptions" >&2
164 ex4def_usage >&2
165 exit 1
166fi
167
168#if [ ! -r ${defaultfile} ]; then
169# echo "Cannot read ${defaultfile}, terminating" >&2
170# exit 1
171#fi
172
173if "${EX4DEF_INIT}" = "true" ] ; then
174 [ -e "${defaultfile}" ] && [ "${EX4DEF_FORCE}" != "true" ] && exit 0
175 # Reset to default values
176 EX4DEF_QUEUERUNNER='combined'
177 EX4DEF_QUEUEINTERVAL='30m'
178 EX4DEF_COMMONOPTIONS=''
179 EX4DEF_QUEUERUNNEROPTIONS=''
180 EX4DEF_QFLAGS=''
181 EX4DEF_SMTPLISTENEROPTIONS=''
182
183 ex4def_write
184 exit 0
185fi
186
187#Try removing
188if [ "${EX4DEF_FLAGREMOVE}" = "true" ] ; then
189 EX4DEF_REMOVEERROR="false"
190 if [ ! -z "${EX4DEF_REMOVECOMMON}" ] ; then
191 EX4DEF_COMMONOPTIONS=$(echo "${COMMONOPTIONS}" | \
192