Skip to content

Commit

Permalink
Merge pull request docker-library#330 from twang2218/tmpfs
Browse files Browse the repository at this point in the history
Setup the `$APACHE_RUN_DIR` and `$APACHE_LOCK_DIR` directories in runtime
  • Loading branch information
yosifkit authored Jan 26, 2017
2 parents d7181e0 + e573f8f commit fe1ff7e
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 3 deletions.
25 changes: 24 additions & 1 deletion 5.6/apache/apache2-foreground
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,30 @@ if test -f "$APACHE_ENVVARS"; then
fi

# Apache gets grumpy about PID files pre-existing
: "${APACHE_PID_FILE:=${APACHE_RUN_DIR:=/var/run/apache2}/apache2.pid}"
: "${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 "$@"
25 changes: 24 additions & 1 deletion 7.0/apache/apache2-foreground
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,30 @@ if test -f "$APACHE_ENVVARS"; then
fi

# Apache gets grumpy about PID files pre-existing
: "${APACHE_PID_FILE:=${APACHE_RUN_DIR:=/var/run/apache2}/apache2.pid}"
: "${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 "$@"
25 changes: 24 additions & 1 deletion 7.1/apache/apache2-foreground
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,30 @@ if test -f "$APACHE_ENVVARS"; then
fi

# Apache gets grumpy about PID files pre-existing
: "${APACHE_PID_FILE:=${APACHE_RUN_DIR:=/var/run/apache2}/apache2.pid}"
: "${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 "$@"

0 comments on commit fe1ff7e

Please sign in to comment.