-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexim4-config-check-which.sh
executable file
·124 lines (111 loc) · 4.33 KB
/
exim4-config-check-which.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/bash
# File: exim4-config-which.sh
# Title: Tells you which set of Exim4 config files are being used
#
echo "Determine which configs file that Exim4 is using."
echo
EXIM_BIN_FILESPEC="$(which exim4)"
EXIM_CONF_DIRSPEC="/etc/exim4"
EXIM_CONF_FILESPEC="${EXIM_CONF_DIRSPEC}/exim4.conf"
EXIM_CONF_TEMPLATE_FILESPEC="${EXIM_CONF_DIRSPEC}/exim4.conf.template"
EXIM_CONF_LOCALMACROS_FILESPEC="${EXIM_CONF_DIRSPEC}/exim4.conf.localmacros"
EXIM_UPDATE_CONF_FILESPEC="${EXIM_CONF_DIRSPEC}/update-exim4.conf.conf"
EXIM_CONF_NONDEBIAN_FILESPEC="${EXIM_CONF_FILESPEC}"
EXIM_CONF_NONSPLIT_FILESPEC="${EXIM_CONF_TEMPLATE_FILESPEC}"
EXIM_CONF_SPLIT_FILESPEC="${EXIM_CONF_DIRSPEC}/conf.d/main/01_exim4-config_listmacrosdefs"
VARLIB_EXIM_CONF_DIRSPEC="/var/lib/exim4"
VARLIB_EXIM_CONF_FILESPEC="${VARLIB_EXIM_CONF_DIRSPEC}/config.autogenerated"
if [ ! -f /etc/os-release ]; then
echo "Probably not a Debian/Devuan OS distro; aborted."
exit 1
fi
source /etc/os-release
if [ "$ID" != 'debian' ] && [ "$ID" != 'devuan' ]; then
echo "Not a Debian/Devuan OS distro; aborted."
exit 1
fi
FOUND_BIN="$(which exim4)"
if [ -z "$FOUND_BIN" ]; then
echo "Exim4 binary is not found; aborted."
exit 1
fi
echo "Compiled-in config lookup sequence by ${EXIM_BIN_FILESPEC}:"
exim4 -bV | grep "Configuration file"
echo "$EXIM_BIN_FILESPEC is now using this config file:"
if [ -f "$EXIM_CONF_FILESPEC" ]; then
echo " $EXIM_CONF_FILESPEC"
elif [ -f "$VARLIB_EXIM_CONF_FILESPEC" ]; then
echo " $VARLIB_EXIM_CONF_FILESPEC"
else
echo "WARNING: No configuration files given."
echo "WARNING: exim4 daemon MUST use '-c' CLI runtime option"
fi
echo
if [ -f "$EXIM_CONF_FILESPEC" ]; then
echo "Exim4 daemon will:"
echo " Ignores : $EXIM_UPDATE_CONF_FILESPEC"
echo " Ignores : $EXIM_CONF_TEMPLATE_FILESPEC"
echo " Ignores : $EXIM_CONF_LOCALMACROS_FILESPEC"
echo "(update-exim4.conf writes nothing)"
echo
echo " Configs goes into: $EXIM_CONF_NONDEBIAN_FILESPEC"
echo " daemon reads from: $EXIM_CONF_FILESPEC"
echo
if [ -f "$VARLIB_EXIM_CONF_FILESPEC" ]; then
echo "WARNING: there is a lingering Debian artifact file that needs removing:"
echo " $VARLIB_EXIM_CONF_FILESPEC"
fi
elif [ -f "$EXIM_UPDATE_CONF_FILESPEC" ]; then
echo "Reading $EXIM_UPDATE_CONF_FILESPEC for its settings ..."
# read update for dc_use_split_config setting
# grep ????
DC_USC=$(grep dc_use_split_config "$EXIM_UPDATE_CONF_FILESPEC" | grep -c true )
if [ "$DC_USC" -eq 0 ]; then
echo "'dc_use_split_config' is set to 'false' in $EXIM_UPDATE_CONF_FILESPEC"
echo " ignores : $EXIM_CONF_FILESPEC"
echo " ignores : $EXIM_UPDATE_CONF_FILESPEC"
echo " ignores : $EXIM_CONF_LOCALMACROS_FILESPEC"
echo
echo " Configs goes into: $EXIM_CONF_NONSPLIT_FILESPEC"
echo " reads from : $EXIM_CONF_TEMPLATE_FILESPEC"
echo " writes to : $VARLIB_EXIM_CONF_FILESPEC"
echo " daemon reads from: $VARLIB_EXIM_CONF_FILESPEC"
elif [ "$DC_USC" -eq 1 ]; then
echo "'dc_use_split_config' is set to 'true' in $EXIM_UPDATE_CONF_FILESPEC"
echo " ignores : $EXIM_CONF_FILESPEC"
echo " ignores : $EXIM_CONF_TEMPLATE_FILESPEC"
echo
echo " Configs goes into: $EXIM_CONF_SPLIT_FILESPEC"
echo " reads from : $EXIM_UPDATE_CONF_FILESPEC"
echo " reads from : $EXIM_CONF_LOCALMACROS_FILESPEC"
echo " writes to : $VARLIB_EXIM_CONF_FILESPEC"
echo " daemon reads from: $VARLIB_EXIM_CONF_FILESPEC"
fi
if [ ! -f "$VARLIB_EXIM_CONF_FILESPEC" ]; then
echo "File $VARLIB_EXIM_CONF_FILESPEC is missing"
echo "A simple command:"
echo " update-exim4.conf"
echo "will create this."
fi
else
if [ -f "$VARLIB_EXIM_CONF_FILESPEC" ]; then
echo "WARNING: No configuration files found in $EXIM_CONF_DIRSPEC directory."
echo "WARNING: Exim4 daemon using the following UNKNOWN config file:"
echo " $VARLIB_EXIM_CONF_FILESPEC"
else
echo "ERROR: Exim4 daemon will complain that its config file is missing."
echo
echo "Create one of these files:"
echo " $EXIM_CONF_FILESPEC"
echo " $EXIM_UPDATE_CONF_FILESPEC"
echo "Aborted."
exit 3
fi
fi
# Do simple syntax check
exim4 -bV >/dev/null 2>&1
retsts=$?
if [ $retsts -ne 0 ]; then
echo
echo "Simple syntax-check: **** FAILED ****."
fi