From 649cb5c66b1424d229d322a00970d866b17242d6 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sat, 19 Dec 2020 10:12:22 +0000 Subject: [PATCH] added docker/apache2-fg.sh --- codepot/docker/Dockerfile.ubnt2004 | 2 +- codepot/docker/apache2-fg.sh | 40 ++++++++++++++++++++++++++++++ codepot/docker/build-ubnt2004.sh | 2 +- 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100755 codepot/docker/apache2-fg.sh diff --git a/codepot/docker/Dockerfile.ubnt2004 b/codepot/docker/Dockerfile.ubnt2004 index a7fb1e79..07328892 100644 --- a/codepot/docker/Dockerfile.ubnt2004 +++ b/codepot/docker/Dockerfile.ubnt2004 @@ -3,4 +3,4 @@ FROM ubuntu:20.04 COPY build-ubnt2004.sh /tmp RUN /tmp/build-ubnt2004.sh && rm -rf /tmp/* -CMD ["/bin/bash"] +CMD ["/usr/sbin/apache2-fg.sh"] diff --git a/codepot/docker/apache2-fg.sh b/codepot/docker/apache2-fg.sh new file mode 100755 index 00000000..5fe22e26 --- /dev/null +++ b/codepot/docker/apache2-fg.sh @@ -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 ", 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 "$@" diff --git a/codepot/docker/build-ubnt2004.sh b/codepot/docker/build-ubnt2004.sh index b4de8c04..2a766158 100755 --- a/codepot/docker/build-ubnt2004.sh +++ b/codepot/docker/build-ubnt2004.sh @@ -38,6 +38,7 @@ sed -ri -e 's|^database_hostname[[:space:]]*=[[:space:]]*""$|database_hostname = -e 's|^database_driver[[:space:]]*=[[:space:]]*""$|database_driver = "mysqli"|g' /etc/codepot/codepot.ini && \ sed -ri -e 's|Digest::SHA1|Digest::SHA|g' /usr/sbin/codepot-user && \ sed -ri -e 's|Digest::SHA1|Digest::SHA|g' /etc/codepot/perl/Codepot/AccessHandler.pm && \ +install -m 0755 -D -t /usr/sbin docker/apache2-fg.sh && \ cd .. && \ cd .. && \ \ @@ -45,6 +46,5 @@ cp -pf /etc/codepot/codepot.httpd /etc/apache2/conf-enabled/codepot.conf && \ echo "PerlSwitches -Mlib=/etc/codepot/perl" >> /etc/apache2/conf-enabled/perl.conf - apt-get remove -y php-dev libsvn-dev make && \ apt-get auto-remove -y && rm -rf /var/lib/apt/lists/*