| 1 | #!/bin/bash |
| 2 | |
| 3 | # put this file in /etc/network/if-up.d/exim4-smarthost |
| 4 | # add an exim4-smarthost smtp.server.example.com::587 line to your interface |
| 5 | # stanza in /etc/network/interfaces |
| 6 | |
| 7 | # this will only work for split config, since in non-split config we |
| 8 | # only have a single file which is included and which would need more |
| 9 | # serious string processing to alter. With split config, we can blindly |
| 10 | # overwrite our previous file. |
| 11 | |
| 12 | # Environment: |
| 13 | # MODE = { start | stop } |
| 14 | # IF_EXIM4_SMARTHOST = hostname[::port] |
| 15 | |
| 16 | SMARTHOSTFILE="/etc/exim4/conf.d/main/00_local_DCsmarthost" |
| 17 | |
| 18 | if [ -z "$IF_EXIM4_SMARTHOST" ]; then |
| 19 | exit 0 |
| 20 | fi |
| 21 | |
| 22 | if [ "$MODE" = 'stop' ]; then |
| 23 | rm -f $SMARTHOSTFILE |
| 24 | invoke exim4 reload > /dev/null || true |
| 25 | exit 0 |
| 26 | fi |
| 27 | |
| 28 | if [ "$IF_EXIM4_SMARTHOST" = "none" ]; then |
| 29 | rm -f $SMARTHOSTFILE |
| 30 | invoke exim4 reload > /dev/null || true |
| 31 | exit 0 |
| 32 | fi |
| 33 | |
| 34 | echo "DCsmarthost = ${IF_EXIM4_SMARTHOST}" > $SMARTHOSTFILE |
| 35 | |
| 36 | invoke exim4 reload > /dev/null || true |
| 37 | /usr/sbin/exim4 -qqf |