Skip to content

Commit ab04a02

Browse files
committed
Handle DMA configuration variables
1 parent e0e0435 commit ab04a02

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

utils/docker-entrypoint-as-root.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,26 @@ fi
116116
unset DOCKER_FOR_MAC_REMOTE_HOST
117117
unset REMOTE_HOST_FOUND
118118

119+
if [ -e /usr/bin/dma ]; then
120+
# set sendmail path for PHP
121+
if [ "$DMA_FROM" = "" ]; then
122+
123+
fi
124+
export PHP_INI_SENDMAIL_PATH="/usr/sbin/sendmail -t -i -f'$DMA_FROM'"
125+
126+
# generate DMA config based on DMA_CONF_... environment variables
127+
php /usr/local/bin/generate_dma.php > /etc/dma/dma.conf
128+
129+
# generate DMA authentication file based on DMA_AUTH_... environment variables
130+
if [ -n "$DMA_AUTH_USERNAME" ] && [ -n "$DMA_AUTH_PASSWORD" ]; then
131+
if [ -z "$DMA_CONF_SMARTHOST" ]; then
132+
echo "DMA_AUTH_USERNAME and DMA_AUTH_PASSWORD are set, but DMA_CONF_SMARTHOST is empty - not attempting authentication" >&2
133+
else
134+
echo "$DMA_AUTH_USERNAME|$DMA_CONF_SMARTHOST:$DMA_AUTH_PASSWORD" > /etc/dma/auth.conf
135+
fi
136+
fi
137+
fi
138+
119139
php /usr/local/bin/generate_conf.php > /etc/php/${PHP_VERSION}/mods-available/generated_conf.ini
120140
php /usr/local/bin/setup_extensions.php | sudo bash
121141

utils/generate_dma.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/**
3+
* A very simple script in charge of generating the DMA configuration based on environment variables.
4+
* The script is run on each start of the container.
5+
*/
6+
7+
require __DIR__.'/utils.php';
8+
9+
$found = false;
10+
11+
foreach ($_SERVER as $key => $value) {
12+
if (strpos($key, 'DMA_') === 0) {
13+
$found = true;
14+
}
15+
if (strpos($key, 'DMA_CONF_') === 0) {
16+
$suffix = substr($key, 9);
17+
18+
echo $suffix." ".$value."\n";
19+
}
20+
}
21+
22+
if (($found === true) && !file_exists('/usr/bin/dma')) {
23+
// Let's check DMA is installed (it could be not installed is we are using the slim version...)
24+
error_log('DMA is not available in this image. If you are using the thecodingmachine/php "slim" variant, do not forget to add "ARG INSTALL_DMA=1" in your Dockerfile. Check the documentation for more details.');
25+
exit(1);
26+
}

0 commit comments

Comments
 (0)