Skip to content

Commit

Permalink
Add "apache2-foreground" to the top-level and copy it into apache var…
Browse files Browse the repository at this point in the history
…iant directories
  • Loading branch information
tianon committed May 18, 2018
1 parent 1f00ae6 commit e3bc10f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
40 changes: 40 additions & 0 deletions apache2-foreground
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
set -e

# Note: we don't just use "apache2ctl" here because it itself is just a shell-script wrapper around apache2 which provides extra functionality like "apache2ctl start" for launching apache2 in the background.
# (also, when run as "apache2ctl <apache args>", it does not use "exec", which leaves an undesirable resident shell process)

: "${APACHE_CONFDIR:=/etc/apache2}"
: "${APACHE_ENVVARS:=$APACHE_CONFDIR/envvars}"
if test -f "$APACHE_ENVVARS"; then
. "$APACHE_ENVVARS"
fi

# Apache gets grumpy about PID files pre-existing
: "${APACHE_RUN_DIR:=/var/run/apache2}"
: "${APACHE_PID_FILE:=$APACHE_RUN_DIR/apache2.pid}"
rm -f "$APACHE_PID_FILE"

# create missing directories
# (especially APACHE_RUN_DIR, APACHE_LOCK_DIR, and APACHE_LOG_DIR)
for e in "${!APACHE_@}"; do
if [[ "$e" == *_DIR ]] && [[ "${!e}" == /* ]]; then
# handle "/var/lock" being a symlink to "/run/lock", but "/run/lock" not existing beforehand, so "/var/lock/something" fails to mkdir
# mkdir: cannot create directory '/var/lock': File exists
dir="${!e}"
while [ "$dir" != "$(dirname "$dir")" ]; do
dir="$(dirname "$dir")"
if [ -d "$dir" ]; then
break
fi
absDir="$(readlink -f "$dir" 2>/dev/null || :)"
if [ -n "$absDir" ]; then
mkdir -p "$absDir"
fi
done

mkdir -p "${!e}"
fi
done

exec apache2 -DFOREGROUND "$@"
5 changes: 4 additions & 1 deletion update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,14 @@ for version in "${versions[@]}"; do
ia && ac == 1 { system("cat " variant "-Dockerfile-block-" ab) }
' "$version/$suite/$variant/Dockerfile"

cp \
cp -a \
docker-php-entrypoint \
docker-php-ext-* \
docker-php-source \
"$version/$suite/$variant/"
if [ "$variant" = 'apache' ]; then
cp -a apache2-foreground "$version/$suite/$variant/"
fi

if [ "$alpineVer" = '3.4' ]; then
sed -ri 's!libressl!openssl!g' "$version/$suite/$variant/Dockerfile"
Expand Down

0 comments on commit e3bc10f

Please sign in to comment.