tr optimisations

This commit is contained in:
Anatolii Zimovskii 2022-01-25 19:28:57 +03:00
parent 9c37f26f5a
commit 4eab03e0fc
Signed by: stam
GPG Key ID: AA3A575AB99E8469
4 changed files with 90 additions and 39 deletions

View File

@ -4,7 +4,7 @@
function createOptDirectory { function createOptDirectory {
if [ ! -d $1 ] if [ ! -d $1 ]
then then
echo "Creating " $1 echo "[testrail] Creating " $1
mkdir -p $1 mkdir -p $1
fi fi
@ -13,13 +13,11 @@ function createOptDirectory {
/bin/cp -rf /testrail-release/apache-conf/000-default.conf /etc/apache2/sites-enabled/000-default.conf /bin/cp -rf /testrail-release/apache-conf/000-default.conf /etc/apache2/sites-enabled/000-default.conf
echo "##############" echo "[testrail] Unzipping testrail service"
echo "Unzipping testrail"
unzip -o /testrail-release/testrail.zip -d /var/www/ unzip -o /testrail-release/testrail.zip -d /var/www/
unzip -o -j /testrail-release/testrail-auth-ad-1.4.zip testrail-auth-ad-1.4/auth.php -d ${TR_CUSTOM_AUTH_DIR} && \
ls -las ${TR_CUSTOM_AUTH_DIR}
echo "[testrail] Unzipping testrail Active Directory auth plugin"
unzip -o -j /testrail-release/testrail-auth-ad-1.4.zip testrail-auth-ad-1.4/auth.php -d ${TR_CUSTOM_AUTH_DIR}
createOptDirectory $TR_DEFAULT_LOG_DIR createOptDirectory $TR_DEFAULT_LOG_DIR
createOptDirectory $TR_DEFAULT_AUDIT_DIR createOptDirectory $TR_DEFAULT_AUDIT_DIR
@ -28,21 +26,38 @@ createOptDirectory $TR_DEFAULT_ATTACHMENT_DIR
chown -R www-data:www-data /var/www/testrail/config chown -R www-data:www-data /var/www/testrail/config
echo "##############"
echo "Waiting for background task file" #################################################################################
echo "[testrail] Waiting for background task file"
while [ ! -f /var/www/testrail/task.php ] while [ ! -f /var/www/testrail/task.php ]
do do
sleep 2 sleep 2
done done
echo "Starting background task" echo "[testrail] Starting background task"
while /bin/true; do while /bin/true; do
php /var/www/testrail/task.php || true php /var/www/testrail/task.php || true
sleep $TR_DEFAULT_TASK_EXECUTION sleep $TR_DEFAULT_TASK_EXECUTION
done & done &
echo "##############" echo "[testrail] Background task stoped"
#################################################################################
if [[ -z "${FIX_WWW_DATA}" ]]; then
echo "[apache2] env FIX_WWW_DATA is not set. Skipping..."
elif [ "${FIX_WWW_DATA}" == "false" ]; then
echo "[apache2] env FIX_WWW_DATA is set to false. Skipping..."
elif [ "${FIX_WWW_DATA}" == "true" ]; then
echo "[apache2] Changing permissions for /var/www path. Dont worry, please wait."
chown www-data:www-data /var/www -R chown www-data:www-data /var/www -R
echo "[apache2] Done"
else
echo "[apache2] env FIX_WWW_DATA is set to strange value. Skipping..."
fi
echo "[apache2] Starting up"
source /etc/apache2/envvars source /etc/apache2/envvars
tail -F /var/log/apache2/* & tail -F /var/log/apache2/* &

View File

@ -1,8 +1,8 @@
FROM epicmorg/apache2:php7.4 FROM epicmorg/apache2:php7.4
ARG TESTRAIL_VERSION=latest ENV TESTRAIL_VERSION=latest
ARG DOWNLOAD_URL=https://secure.gurock.com/downloads/testrail/testrail-${TESTRAIL_VERSION}-ion72.zip ENV DOWNLOAD_URL=https://secure.gurock.com/downloads/testrail/testrail-${TESTRAIL_VERSION}-ion72.zip
ARG TESTRAIL_RELEASE_DIR=testrail-release ENV TESTRAIL_RELEASE_DIR=/testrail-release
ENV TR_DEFAULT_TASK_EXECUTION=60 ENV TR_DEFAULT_TASK_EXECUTION=60
ENV TR_WWWPATH="/var/www/testrail/" ENV TR_WWWPATH="/var/www/testrail/"
@ -30,15 +30,15 @@ RUN \
mkdir -p /${TESTRAIL_RELEASE_DIR} && \ mkdir -p /${TESTRAIL_RELEASE_DIR} && \
mkdir -p /var/www/testrail && \ mkdir -p /var/www/testrail && \
mkdir -p /opt/testrail/attachments /opt/testrail/reports /opt/testrail/logs /opt/testrail/audit && \ mkdir -p /opt/testrail/attachments /opt/testrail/reports /opt/testrail/logs /opt/testrail/audit && \
wget --no-check-certificate -O /${TESTRAIL_RELEASE_DIR}/testrail.zip ${DOWNLOAD_URL} && \ wget --no-check-certificate -O ${TESTRAIL_RELEASE_DIR}/testrail.zip ${DOWNLOAD_URL} && \
chown -R www-data:www-data /${TESTRAIL_RELEASE_DIR} && \ chown -R www-data:www-data ${TESTRAIL_RELEASE_DIR} && \
unzip -o /testrail-release/testrail.zip -d /var/www/ && \ unzip -o ${TESTRAIL_RELEASE_DIR}/testrail.zip -d /var/www/ && \
ls -las /var/www/testrail && \ ls -las /var/www/testrail && \
chown -R www-data:www-data /var/www/testrail && \ chown -R www-data:www-data /var/www/testrail && \
chown -R www-data:www-data /opt/testrail chown -R www-data:www-data /opt/testrail
COPY apache_testrail.conf /${TESTRAIL_RELEASE_DIR}/apache-conf/000-default.conf COPY apache_testrail.conf ${TESTRAIL_RELEASE_DIR}/apache-conf/000-default.conf
COPY run.sh /run.sh COPY run.sh /run.sh
WORKDIR /var/www/testrail WORKDIR /var/www/testrail

View File

@ -1,44 +1,63 @@
#!/bin/bash #!/bin/bash
#set -e #set -e
#env
##################################################################################
function createOptDirectory { function createOptDirectory {
if [ ! -d $1 ] if [ ! -d $1 ]
then then
echo "Creating " $1 echo "[testrail] Creating " $1
mkdir -p $1 mkdir -p $1
fi fi
chown -R www-data:www-data $1 chown -R www-data:www-data $1
} }
/bin/cp -rf /testrail-release/apache-conf/000-default.conf /etc/apache2/sites-enabled/000-default.conf /bin/cp -rf ${TESTRAIL_RELEASE_DIR}/apache-conf/000-default.conf /etc/apache2/sites-enabled/000-default.conf
echo "##############" echo "[testrail] Unzipping testrail service"
echo "Unzipping testrail" unzip -o ${TESTRAIL_RELEASE_DIR}/testrail.zip -d /var/www/
unzip -o /testrail-release/testrail.zip -d /var/www/
createOptDirectory $TR_DEFAULT_LOG_DIR createOptDirectory $TR_DEFAULT_LOG_DIR
createOptDirectory $TR_DEFAULT_AUDIT_DIR createOptDirectory $TR_DEFAULT_AUDIT_DIR
createOptDirectory $TR_DEFAULT_REPORT_DIR createOptDirectory $TR_DEFAULT_REPORT_DIR
createOptDirectory $TR_DEFAULT_ATTACHMENT_DIR createOptDirectory $TR_DEFAULT_ATTACHMENT_DIR
chown -R www-data:www-data /var/www/testrail/config chown -R www-data:www-data ${TR_CONFIGPATH}
echo "##############"
echo "Waiting for background task file" #################################################################################
echo "[testrail] Waiting for background task file"
while [ ! -f /var/www/testrail/task.php ] while [ ! -f /var/www/testrail/task.php ]
do do
sleep 2 sleep 2
done done
echo "Starting background task" echo "[testrail] Starting background task"
while /bin/true; do while /bin/true; do
php /var/www/testrail/task.php || true php /var/www/testrail/task.php || true
sleep $TR_DEFAULT_TASK_EXECUTION sleep $TR_DEFAULT_TASK_EXECUTION
done & done &
echo "##############" echo "[testrail] Background task stoped"
#################################################################################
if [[ -z "${FIX_WWW_DATA}" ]]; then
echo "[apache2] env FIX_WWW_DATA is not set. Skipping..."
elif [ "${FIX_WWW_DATA}" == "false" ]; then
echo "[apache2] env FIX_WWW_DATA is set to false. Skipping..."
elif [ "${FIX_WWW_DATA}" == "true" ]; then
echo "[apache2] Changing permissions for /var/www path. Dont worry, please wait."
chown www-data:www-data /var/www -R chown www-data:www-data /var/www -R
echo "[apache2] Done"
else
echo "[apache2] env FIX_WWW_DATA is set to strange value. Skipping..."
fi
echo "[apache2] Starting up"
source /etc/apache2/envvars source /etc/apache2/envvars
tail -F /var/log/apache2/* & tail -F /var/log/apache2/* &

View File

@ -4,7 +4,7 @@
function createOptDirectory { function createOptDirectory {
if [ ! -d $1 ] if [ ! -d $1 ]
then then
echo "Creating " $1 echo "[testrail] Creating " $1
mkdir -p $1 mkdir -p $1
fi fi
@ -13,11 +13,11 @@ function createOptDirectory {
/bin/cp -rf /testrail-release/apache-conf/000-default.conf /etc/apache2/sites-enabled/000-default.conf /bin/cp -rf /testrail-release/apache-conf/000-default.conf /etc/apache2/sites-enabled/000-default.conf
echo "##############" echo "[testrail] Unzipping testrail service"
echo "Unzipping testrail"
unzip -o /testrail-release/testrail.zip -d /var/www/ unzip -o /testrail-release/testrail.zip -d /var/www/
unzip -o -j /testrail-release/testrail-auth-ldap-1.4.zip testrail-auth-ldap-1.4/auth.php -d ${TR_CUSTOM_AUTH_DIR} && \
ls -las ${TR_CUSTOM_AUTH_DIR} echo "[testrail] Unzipping testrail LDAP auth plugin"
unzip -o -j /testrail-release/testrail-auth-ldap-1.4.zip testrail-auth-ldap-1.4/auth.php -d ${TR_CUSTOM_AUTH_DIR}
createOptDirectory $TR_DEFAULT_LOG_DIR createOptDirectory $TR_DEFAULT_LOG_DIR
createOptDirectory $TR_DEFAULT_AUDIT_DIR createOptDirectory $TR_DEFAULT_AUDIT_DIR
@ -26,21 +26,38 @@ createOptDirectory $TR_DEFAULT_ATTACHMENT_DIR
chown -R www-data:www-data /var/www/testrail/config chown -R www-data:www-data /var/www/testrail/config
echo "##############"
echo "Waiting for background task file" #################################################################################
echo "[testrail] Waiting for background task file"
while [ ! -f /var/www/testrail/task.php ] while [ ! -f /var/www/testrail/task.php ]
do do
sleep 2 sleep 2
done done
echo "Starting background task" echo "[testrail] Starting background task"
while /bin/true; do while /bin/true; do
php /var/www/testrail/task.php || true php /var/www/testrail/task.php || true
sleep $TR_DEFAULT_TASK_EXECUTION sleep $TR_DEFAULT_TASK_EXECUTION
done & done &
echo "##############" echo "[testrail] Background task stoped"
#################################################################################
if [[ -z "${FIX_WWW_DATA}" ]]; then
echo "[apache2] env FIX_WWW_DATA is not set. Skipping..."
elif [ "${FIX_WWW_DATA}" == "false" ]; then
echo "[apache2] env FIX_WWW_DATA is set to false. Skipping..."
elif [ "${FIX_WWW_DATA}" == "true" ]; then
echo "[apache2] Changing permissions for /var/www path. Dont worry, please wait."
chown www-data:www-data /var/www -R chown www-data:www-data /var/www -R
echo "[apache2] Done"
else
echo "[apache2] env FIX_WWW_DATA is set to strange value. Skipping..."
fi
echo "[apache2] Starting up"
source /etc/apache2/envvars source /etc/apache2/envvars
tail -F /var/log/apache2/* & tail -F /var/log/apache2/* &