2022-01-25 19:01:36 +03:00
|
|
|
#!/bin/bash
|
2022-01-25 21:42:26 +03:00
|
|
|
|
|
|
|
echo "[testrail] Starting testrail service"
|
|
|
|
|
|
|
|
#################################################################################
|
2022-01-25 19:01:36 +03:00
|
|
|
|
|
|
|
function createOptDirectory {
|
|
|
|
if [ ! -d $1 ]
|
|
|
|
then
|
2022-01-25 19:28:57 +03:00
|
|
|
echo "[testrail] Creating " $1
|
2022-01-25 19:01:36 +03:00
|
|
|
mkdir -p $1
|
|
|
|
fi
|
|
|
|
|
|
|
|
chown -R www-data:www-data $1
|
|
|
|
}
|
|
|
|
|
2022-01-25 20:29:02 +03:00
|
|
|
/bin/cp -rf ${TESTRAIL_RELEASE_DIR}/apache-conf/000-default.conf /etc/apache2/sites-enabled/000-default.conf
|
2022-01-25 19:01:36 +03:00
|
|
|
|
2022-01-25 19:28:57 +03:00
|
|
|
echo "[testrail] Unzipping testrail service"
|
2022-01-25 21:42:26 +03:00
|
|
|
unzip -q -o ${TESTRAIL_RELEASE_DIR}/testrail.zip -d /var/www/
|
2022-01-25 19:28:57 +03:00
|
|
|
|
|
|
|
echo "[testrail] Unzipping testrail LDAP auth plugin"
|
2022-01-25 21:42:26 +03:00
|
|
|
unzip -q -o -j ${TESTRAIL_RELEASE_DIR}/${TESTRAIL_PLUGIN_FILE} ${TESTRAIL_PLUGIN_FULLNAME}/auth.php -d ${TR_CUSTOM_AUTH_DIR}
|
2022-01-25 19:01:36 +03:00
|
|
|
|
2022-01-25 20:29:02 +03:00
|
|
|
createOptDirectory ${TR_DEFAULT_LOG_DIR}
|
|
|
|
createOptDirectory ${TR_DEFAULT_AUDIT_DIR}
|
|
|
|
createOptDirectory ${TR_DEFAULT_REPORT_DIR}
|
|
|
|
createOptDirectory ${TR_DEFAULT_ATTACHMENT_DIR}
|
2022-01-25 19:01:36 +03:00
|
|
|
|
2022-01-25 20:29:02 +03:00
|
|
|
chown -R www-data:www-data ${TR_CONFIG_DIR}
|
2022-01-25 19:01:36 +03:00
|
|
|
|
2022-01-25 19:28:57 +03:00
|
|
|
#################################################################################
|
|
|
|
|
|
|
|
echo "[testrail] Waiting for background task file"
|
2022-01-25 19:01:36 +03:00
|
|
|
while [ ! -f /var/www/testrail/task.php ]
|
|
|
|
do
|
|
|
|
sleep 2
|
|
|
|
done
|
|
|
|
|
2022-01-25 19:28:57 +03:00
|
|
|
echo "[testrail] Starting background task"
|
2022-01-25 19:01:36 +03:00
|
|
|
while /bin/true; do
|
|
|
|
php /var/www/testrail/task.php || true
|
2022-01-25 20:29:02 +03:00
|
|
|
sleep ${TR_DEFAULT_TASK_EXECUTION}
|
2022-01-25 19:01:36 +03:00
|
|
|
done &
|
2022-01-25 19:28:57 +03:00
|
|
|
echo "[testrail] Background task stoped"
|
|
|
|
|
|
|
|
#################################################################################
|
|
|
|
|
|
|
|
if [[ -z "${FIX_WWW_DATA}" ]]; then
|
2022-01-25 21:06:27 +03:00
|
|
|
echo "[apache2] env FIX_WWW_DATA is not set. Fixing permissions anyway"
|
|
|
|
chown www-data:www-data /var/www -R
|
2022-01-25 19:28:57 +03:00
|
|
|
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
|
|
|
|
echo "[apache2] Done"
|
|
|
|
else
|
|
|
|
echo "[apache2] env FIX_WWW_DATA is set to strange value. Skipping..."
|
|
|
|
fi
|
2022-01-25 19:01:36 +03:00
|
|
|
|
2022-01-25 19:28:57 +03:00
|
|
|
echo "[apache2] Starting up"
|
2022-01-25 19:01:36 +03:00
|
|
|
|
|
|
|
source /etc/apache2/envvars
|
|
|
|
tail -F /var/log/apache2/* &
|
|
|
|
exec apache2 -D FOREGROUND
|