Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | trap "postfix stop" EXIT |
| 4 | |
| 5 | [[ ! -d /opt/postfix/conf/sql/ ]] && mkdir -p /opt/postfix/conf/sql/ |
| 6 | |
| 7 | # Wait for MySQL to warm-up |
| 8 | while ! mysqladmin status --socket=/var/run/mysqld/mysqld.sock -u${DBUSER} -p${DBPASS} --silent; do |
| 9 | echo "Waiting for database to come up..." |
| 10 | sleep 2 |
| 11 | done |
| 12 | |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 13 | until dig +short mailcow.email > /dev/null; do |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 14 | echo "Waiting for DNS..." |
| 15 | sleep 1 |
| 16 | done |
| 17 | |
| 18 | cat <<EOF > /etc/aliases |
| 19 | # Autogenerated by mailcow |
| 20 | null: /dev/null |
| 21 | watchdog: /dev/null |
| 22 | ham: "|/usr/local/bin/rspamd-pipe-ham" |
| 23 | spam: "|/usr/local/bin/rspamd-pipe-spam" |
| 24 | EOF |
| 25 | newaliases; |
| 26 | |
| 27 | # create sni configuration |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 28 | if [[ "${SKIP_LETS_ENCRYPT}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then |
| 29 | echo -n "" > /opt/postfix/conf/sni.map |
| 30 | else |
| 31 | echo -n "" > /opt/postfix/conf/sni.map; |
| 32 | for cert_dir in /etc/ssl/mail/*/ ; do |
| 33 | if [[ ! -f ${cert_dir}domains ]] || [[ ! -f ${cert_dir}cert.pem ]] || [[ ! -f ${cert_dir}key.pem ]]; then |
| 34 | continue; |
| 35 | fi |
| 36 | IFS=" " read -r -a domains <<< "$(cat "${cert_dir}domains")" |
| 37 | for domain in "${domains[@]}"; do |
| 38 | echo -n "${domain} ${cert_dir}key.pem ${cert_dir}cert.pem" >> /opt/postfix/conf/sni.map; |
| 39 | echo "" >> /opt/postfix/conf/sni.map; |
| 40 | done |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 41 | done |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 42 | fi |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 43 | postmap -F hash:/opt/postfix/conf/sni.map; |
| 44 | |
| 45 | cat <<EOF > /opt/postfix/conf/sql/mysql_relay_ne.cf |
| 46 | # Autogenerated by mailcow |
| 47 | user = ${DBUSER} |
| 48 | password = ${DBPASS} |
| 49 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 50 | dbname = ${DBNAME} |
| 51 | query = SELECT IF(EXISTS(SELECT address, domain FROM alias |
| 52 | WHERE address = '%s' |
| 53 | AND domain IN ( |
| 54 | SELECT domain FROM domain |
| 55 | WHERE backupmx = '1' |
| 56 | AND relay_all_recipients = '1' |
| 57 | AND relay_unknown_only = '1') |
| 58 | |
| 59 | ), 'lmtp:inet:dovecot:24', NULL) AS 'transport' |
| 60 | EOF |
| 61 | |
| 62 | cat <<EOF > /opt/postfix/conf/sql/mysql_relay_recipient_maps.cf |
| 63 | # Autogenerated by mailcow |
| 64 | user = ${DBUSER} |
| 65 | password = ${DBPASS} |
| 66 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 67 | dbname = ${DBNAME} |
| 68 | query = SELECT DISTINCT |
| 69 | CASE WHEN '%d' IN ( |
| 70 | SELECT domain FROM domain |
| 71 | WHERE relay_all_recipients=1 |
| 72 | AND domain='%d' |
| 73 | AND backupmx=1 |
| 74 | ) |
| 75 | THEN '%s' ELSE ( |
| 76 | SELECT goto FROM alias WHERE address='%s' AND active='1' |
| 77 | ) |
| 78 | END AS result; |
| 79 | EOF |
| 80 | |
| 81 | cat <<EOF > /opt/postfix/conf/sql/mysql_tls_policy_override_maps.cf |
| 82 | # Autogenerated by mailcow |
| 83 | user = ${DBUSER} |
| 84 | password = ${DBPASS} |
| 85 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 86 | dbname = ${DBNAME} |
| 87 | query = SELECT CONCAT(policy, ' ', parameters) AS tls_policy FROM tls_policy_override WHERE active = '1' AND dest = '%s' |
| 88 | EOF |
| 89 | |
| 90 | cat <<EOF > /opt/postfix/conf/sql/mysql_tls_enforce_in_policy.cf |
| 91 | # Autogenerated by mailcow |
| 92 | user = ${DBUSER} |
| 93 | password = ${DBPASS} |
| 94 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 95 | dbname = ${DBNAME} |
| 96 | query = SELECT IF(EXISTS( |
| 97 | SELECT 'TLS_ACTIVE' FROM alias |
| 98 | LEFT OUTER JOIN mailbox ON mailbox.username = alias.goto |
| 99 | WHERE (address='%s' |
| 100 | OR address IN ( |
| 101 | SELECT CONCAT('%u', '@', target_domain) FROM alias_domain |
| 102 | WHERE alias_domain='%d' |
| 103 | ) |
| 104 | ) AND JSON_UNQUOTE(JSON_VALUE(attributes, '$.tls_enforce_in')) = '1' AND mailbox.active = '1' |
| 105 | ), 'reject_plaintext_session', NULL) AS 'tls_enforce_in'; |
| 106 | EOF |
| 107 | |
| 108 | cat <<EOF > /opt/postfix/conf/sql/mysql_sender_dependent_default_transport_maps.cf |
| 109 | # Autogenerated by mailcow |
| 110 | user = ${DBUSER} |
| 111 | password = ${DBPASS} |
| 112 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 113 | dbname = ${DBNAME} |
| 114 | query = SELECT GROUP_CONCAT(transport SEPARATOR '') AS transport_maps |
| 115 | FROM ( |
| 116 | SELECT IF(EXISTS(SELECT 'smtp_type' FROM alias |
| 117 | LEFT OUTER JOIN mailbox ON mailbox.username = alias.goto |
| 118 | WHERE (address = '%s' |
| 119 | OR address IN ( |
| 120 | SELECT CONCAT('%u', '@', target_domain) FROM alias_domain |
| 121 | WHERE alias_domain = '%d' |
| 122 | ) |
| 123 | ) |
| 124 | AND JSON_UNQUOTE(JSON_VALUE(attributes, '$.tls_enforce_out')) = '1' |
| 125 | AND mailbox.active = '1' |
| 126 | ), 'smtp_enforced_tls:', 'smtp:') AS 'transport' |
| 127 | UNION ALL |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 128 | SELECT COALESCE( |
| 129 | (SELECT hostname FROM relayhosts |
| 130 | LEFT OUTER JOIN mailbox ON JSON_UNQUOTE(JSON_VALUE(mailbox.attributes, '$.relayhost')) = relayhosts.id |
| 131 | WHERE relayhosts.active = '1' |
| 132 | AND ( |
| 133 | mailbox.username IN (SELECT alias.goto from alias |
| 134 | JOIN mailbox ON mailbox.username = alias.goto |
| 135 | WHERE alias.active = '1' |
| 136 | AND alias.address = '%s' |
| 137 | AND alias.address NOT LIKE '@%%' |
| 138 | ) |
| 139 | ) |
| 140 | ), |
| 141 | (SELECT hostname FROM relayhosts |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 142 | LEFT OUTER JOIN domain ON domain.relayhost = relayhosts.id |
| 143 | WHERE relayhosts.active = '1' |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 144 | AND (domain.domain = '%d' |
| 145 | OR domain.domain IN ( |
| 146 | SELECT target_domain FROM alias_domain |
| 147 | WHERE alias_domain = '%d' |
| 148 | ) |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 149 | ) |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 150 | ) |
| 151 | ) |
| 152 | ) AS transport_view; |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 153 | EOF |
| 154 | |
| 155 | cat <<EOF > /opt/postfix/conf/sql/mysql_transport_maps.cf |
| 156 | # Autogenerated by mailcow |
| 157 | user = ${DBUSER} |
| 158 | password = ${DBPASS} |
| 159 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 160 | dbname = ${DBNAME} |
| 161 | query = SELECT CONCAT('smtp_via_transport_maps:', nexthop) AS transport FROM transports |
| 162 | WHERE active = '1' |
| 163 | AND destination = '%s'; |
| 164 | EOF |
| 165 | |
| 166 | cat <<EOF > /opt/postfix/conf/sql/mysql_virtual_resource_maps.cf |
| 167 | # Autogenerated by mailcow |
| 168 | user = ${DBUSER} |
| 169 | password = ${DBPASS} |
| 170 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 171 | dbname = ${DBNAME} |
| 172 | query = SELECT 'null@localhost' FROM mailbox |
| 173 | WHERE kind REGEXP 'location|thing|group' AND username = '%s'; |
| 174 | EOF |
| 175 | |
| 176 | cat <<EOF > /opt/postfix/conf/sql/mysql_sasl_passwd_maps_sender_dependent.cf |
| 177 | # Autogenerated by mailcow |
| 178 | user = ${DBUSER} |
| 179 | password = ${DBPASS} |
| 180 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 181 | dbname = ${DBNAME} |
| 182 | query = SELECT CONCAT_WS(':', username, password) AS auth_data FROM relayhosts |
| 183 | WHERE id IN ( |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 184 | SELECT COALESCE( |
| 185 | (SELECT id FROM relayhosts |
| 186 | LEFT OUTER JOIN domain ON domain.relayhost = relayhosts.id |
| 187 | WHERE relayhosts.active = '1' |
| 188 | AND (domain.domain = '%d' |
| 189 | OR domain.domain IN ( |
| 190 | SELECT target_domain FROM alias_domain |
| 191 | WHERE alias_domain = '%d' |
| 192 | ) |
| 193 | ) |
| 194 | ), |
| 195 | (SELECT id FROM relayhosts |
| 196 | LEFT OUTER JOIN mailbox ON JSON_UNQUOTE(JSON_VALUE(mailbox.attributes, '$.relayhost')) = relayhosts.id |
| 197 | WHERE relayhosts.active = '1' |
| 198 | AND ( |
| 199 | mailbox.username IN ( |
| 200 | SELECT alias.goto from alias |
| 201 | JOIN mailbox ON mailbox.username = alias.goto |
| 202 | WHERE alias.active = '1' |
| 203 | AND alias.address = '%s' |
| 204 | AND alias.address NOT LIKE '@%%' |
| 205 | ) |
| 206 | ) |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 207 | ) |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 208 | ) |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 209 | ) |
| 210 | AND active = '1' |
| 211 | AND username != ''; |
| 212 | EOF |
| 213 | |
| 214 | cat <<EOF > /opt/postfix/conf/sql/mysql_sasl_passwd_maps_transport_maps.cf |
| 215 | # Autogenerated by mailcow |
| 216 | user = ${DBUSER} |
| 217 | password = ${DBPASS} |
| 218 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 219 | dbname = ${DBNAME} |
| 220 | query = SELECT CONCAT_WS(':', username, password) AS auth_data FROM transports |
| 221 | WHERE nexthop = '%s' |
| 222 | AND active = '1' |
| 223 | AND username != '' |
| 224 | LIMIT 1; |
| 225 | EOF |
| 226 | |
| 227 | cat <<EOF > /opt/postfix/conf/sql/mysql_virtual_alias_domain_maps.cf |
| 228 | # Autogenerated by mailcow |
| 229 | user = ${DBUSER} |
| 230 | password = ${DBPASS} |
| 231 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 232 | dbname = ${DBNAME} |
| 233 | query = SELECT username FROM mailbox, alias_domain |
| 234 | WHERE alias_domain.alias_domain = '%d' |
| 235 | AND mailbox.username = CONCAT('%u', '@', alias_domain.target_domain) |
| 236 | AND (mailbox.active = '1' OR mailbox.active = '2') |
| 237 | AND alias_domain.active='1' |
| 238 | EOF |
| 239 | |
| 240 | cat <<EOF > /opt/postfix/conf/sql/mysql_virtual_alias_maps.cf |
| 241 | # Autogenerated by mailcow |
| 242 | user = ${DBUSER} |
| 243 | password = ${DBPASS} |
| 244 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 245 | dbname = ${DBNAME} |
| 246 | query = SELECT goto FROM alias |
| 247 | WHERE address='%s' |
| 248 | AND (active='1' OR active='2'); |
| 249 | EOF |
| 250 | |
| 251 | cat <<EOF > /opt/postfix/conf/sql/mysql_recipient_bcc_maps.cf |
| 252 | # Autogenerated by mailcow |
| 253 | user = ${DBUSER} |
| 254 | password = ${DBPASS} |
| 255 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 256 | dbname = ${DBNAME} |
| 257 | query = SELECT bcc_dest FROM bcc_maps |
| 258 | WHERE local_dest='%s' |
| 259 | AND type='rcpt' |
| 260 | AND active='1'; |
| 261 | EOF |
| 262 | |
| 263 | cat <<EOF > /opt/postfix/conf/sql/mysql_sender_bcc_maps.cf |
| 264 | # Autogenerated by mailcow |
| 265 | user = ${DBUSER} |
| 266 | password = ${DBPASS} |
| 267 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 268 | dbname = ${DBNAME} |
| 269 | query = SELECT bcc_dest FROM bcc_maps |
| 270 | WHERE local_dest='%s' |
| 271 | AND type='sender' |
| 272 | AND active='1'; |
| 273 | EOF |
| 274 | |
| 275 | cat <<EOF > /opt/postfix/conf/sql/mysql_recipient_canonical_maps.cf |
| 276 | # Autogenerated by mailcow |
| 277 | user = ${DBUSER} |
| 278 | password = ${DBPASS} |
| 279 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 280 | dbname = ${DBNAME} |
| 281 | query = SELECT new_dest FROM recipient_maps |
| 282 | WHERE old_dest='%s' |
| 283 | AND active='1'; |
| 284 | EOF |
| 285 | |
| 286 | cat <<EOF > /opt/postfix/conf/sql/mysql_virtual_domains_maps.cf |
| 287 | # Autogenerated by mailcow |
| 288 | user = ${DBUSER} |
| 289 | password = ${DBPASS} |
| 290 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 291 | dbname = ${DBNAME} |
| 292 | query = SELECT alias_domain from alias_domain WHERE alias_domain='%s' AND active='1' |
| 293 | UNION |
| 294 | SELECT domain FROM domain |
| 295 | WHERE domain='%s' |
| 296 | AND active = '1' |
| 297 | AND backupmx = '0' |
| 298 | EOF |
| 299 | |
| 300 | cat <<EOF > /opt/postfix/conf/sql/mysql_virtual_mailbox_maps.cf |
| 301 | # Autogenerated by mailcow |
| 302 | user = ${DBUSER} |
| 303 | password = ${DBPASS} |
| 304 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 305 | dbname = ${DBNAME} |
| 306 | query = SELECT CONCAT(JSON_UNQUOTE(JSON_VALUE(attributes, '$.mailbox_format')), mailbox_path_prefix, '%d/%u/') FROM mailbox WHERE username='%s' AND (active = '1' OR active = '2') |
| 307 | EOF |
| 308 | |
| 309 | cat <<EOF > /opt/postfix/conf/sql/mysql_virtual_relay_domain_maps.cf |
| 310 | # Autogenerated by mailcow |
| 311 | user = ${DBUSER} |
| 312 | password = ${DBPASS} |
| 313 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 314 | dbname = ${DBNAME} |
| 315 | query = SELECT domain FROM domain WHERE domain='%s' AND backupmx = '1' AND active = '1' |
| 316 | EOF |
| 317 | |
| 318 | cat <<EOF > /opt/postfix/conf/sql/mysql_virtual_sender_acl.cf |
| 319 | # Autogenerated by mailcow |
| 320 | user = ${DBUSER} |
| 321 | password = ${DBPASS} |
| 322 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 323 | dbname = ${DBNAME} |
| 324 | # First select queries domain and alias_domain to determine if domains are active. |
| 325 | query = SELECT goto FROM alias |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 326 | WHERE id IN ( |
| 327 | SELECT COALESCE ( |
| 328 | ( |
| 329 | SELECT id FROM alias |
| 330 | WHERE address='%s' |
| 331 | AND (active='1' OR active='2') |
| 332 | ), ( |
| 333 | SELECT id FROM alias |
| 334 | WHERE address='@%d' |
| 335 | AND (active='1' OR active='2') |
| 336 | ) |
| 337 | ) |
| 338 | ) |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 339 | AND active='1' |
| 340 | AND (domain IN |
| 341 | (SELECT domain FROM domain |
| 342 | WHERE domain='%d' |
| 343 | AND active='1') |
| 344 | OR domain in ( |
| 345 | SELECT alias_domain FROM alias_domain |
| 346 | WHERE alias_domain='%d' |
| 347 | AND active='1' |
| 348 | ) |
| 349 | ) |
| 350 | UNION |
| 351 | SELECT logged_in_as FROM sender_acl |
| 352 | WHERE send_as='@%d' |
| 353 | OR send_as='%s' |
| 354 | OR send_as='*' |
| 355 | OR send_as IN ( |
| 356 | SELECT CONCAT('@',target_domain) FROM alias_domain |
| 357 | WHERE alias_domain = '%d') |
| 358 | OR send_as IN ( |
| 359 | SELECT CONCAT('%u','@',target_domain) FROM alias_domain |
| 360 | WHERE alias_domain = '%d') |
| 361 | AND logged_in_as NOT IN ( |
| 362 | SELECT goto FROM alias |
| 363 | WHERE address='%s') |
| 364 | UNION |
| 365 | SELECT username FROM mailbox, alias_domain |
| 366 | WHERE alias_domain.alias_domain = '%d' |
| 367 | AND mailbox.username = CONCAT('%u','@',alias_domain.target_domain) |
| 368 | AND (mailbox.active = '1' OR mailbox.active ='2') |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 369 | AND alias_domain.active='1'; |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 370 | EOF |
| 371 | |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 372 | # MX based routing |
| 373 | cat <<EOF > /opt/postfix/conf/sql/mysql_mbr_access_maps.cf |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 374 | # Autogenerated by mailcow |
| 375 | user = ${DBUSER} |
| 376 | password = ${DBPASS} |
| 377 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 378 | dbname = ${DBNAME} |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 379 | query = SELECT CONCAT('FILTER smtp_via_transport_maps:', nexthop) as transport FROM transports |
| 380 | WHERE '%s' REGEXP destination |
| 381 | AND active='1' |
| 382 | AND is_mx_based='1'; |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 383 | EOF |
| 384 | |
| 385 | cat <<EOF > /opt/postfix/conf/sql/mysql_virtual_spamalias_maps.cf |
| 386 | # Autogenerated by mailcow |
| 387 | user = ${DBUSER} |
| 388 | password = ${DBPASS} |
| 389 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 390 | dbname = ${DBNAME} |
| 391 | query = SELECT goto FROM spamalias |
| 392 | WHERE address='%s' |
| 393 | AND validity >= UNIX_TIMESTAMP() |
| 394 | EOF |
| 395 | |
| 396 | sed -i '/User overrides/q' /opt/postfix/conf/main.cf |
| 397 | echo >> /opt/postfix/conf/main.cf |
| 398 | touch /opt/postfix/conf/extra.cf |
| 399 | sed -i '/myhostname/d' /opt/postfix/conf/extra.cf |
| 400 | echo -e "myhostname = ${MAILCOW_HOSTNAME}\n$(cat /opt/postfix/conf/extra.cf)" > /opt/postfix/conf/extra.cf |
| 401 | |
| 402 | cat /opt/postfix/conf/extra.cf >> /opt/postfix/conf/main.cf |
| 403 | |
| 404 | if [ ! -f /opt/postfix/conf/custom_transport.pcre ]; then |
| 405 | echo "Creating dummy custom_transport.pcre" |
| 406 | touch /opt/postfix/conf/custom_transport.pcre |
| 407 | fi |
| 408 | |
| 409 | if [[ ! -f /opt/postfix/conf/custom_postscreen_whitelist.cidr ]]; then |
| 410 | echo "Creating dummy custom_postscreen_whitelist.cidr" |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 411 | cat <<EOF > /opt/postfix/conf/custom_postscreen_whitelist.cidr |
| 412 | # Autogenerated by mailcow |
| 413 | # Rules are evaluated in the order as specified. |
| 414 | # Blacklist 192.168.* except 192.168.0.1. |
| 415 | # 192.168.0.1 permit |
| 416 | # 192.168.0.0/16 reject |
| 417 | EOF |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 418 | fi |
| 419 | |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 420 | # Fix Postfix permissions |
| 421 | chown -R root:postfix /opt/postfix/conf/sql/ /opt/postfix/conf/custom_transport.pcre |
| 422 | chmod 640 /opt/postfix/conf/sql/*.cf /opt/postfix/conf/custom_transport.pcre |
| 423 | chgrp -R postdrop /var/spool/postfix/public |
| 424 | chgrp -R postdrop /var/spool/postfix/maildrop |
| 425 | postfix set-permissions |
| 426 | |
| 427 | # Check Postfix configuration |
| 428 | postconf -c /opt/postfix/conf > /dev/null |
| 429 | |
| 430 | if [[ $? != 0 ]]; then |
| 431 | echo "Postfix configuration error, refusing to start." |
| 432 | exit 1 |
| 433 | else |
| 434 | postfix -c /opt/postfix/conf start |
| 435 | sleep 126144000 |
| 436 | fi |