From 9016c1b24f0195906593e5b44358c36e13f526b3 Mon Sep 17 00:00:00 2001 From: Sarmad Abualkaz Date: Fri, 26 Mar 2021 22:19:05 +0000 Subject: [PATCH 1/2] option to configure public/robot.txt - append or overwrite --- gitlab-workhorse/scripts/start-workhorse | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gitlab-workhorse/scripts/start-workhorse b/gitlab-workhorse/scripts/start-workhorse index 560a4b30c..b934692d5 100755 --- a/gitlab-workhorse/scripts/start-workhorse +++ b/gitlab-workhorse/scripts/start-workhorse @@ -14,6 +14,18 @@ if [[ "${GITLAB_WORKHORSE_PROM_LISTEN_ADDR}" =~ ^.+:[0-9][0-9]{0,4}$ ]]; then export PROM_LISTEN_ADDR="-prometheusListenAddr ${GITLAB_WORKHORSE_PROM_LISTEN_ADDR}" fi +# option to append/overwrite robot.txt +ROBOTS_TXT_APPEND_FILE="${ROBOTS_TXT_APPEND_FILE:-$TMPDIR/robots_append.txt}" +ROBOTS_TXT_OVERWRITE_FILE="${ROBOTS_TXT_OVERWRITE_FILE:-$TMPDIR/robots_overwrite.txt}" + +export ROBOTS_TXT_FILE=/srv/gitlab/public/robots.txt + +if [ -f "${ROBOTS_TXT_APPEND_FILE}" ]; then + cat ${ROBOTS_TXT_APPEND_FILE} >> ROBOTS_TXT_FILE +elif [ -f "${ROBOTS_TXT_OVERWRITE_FILE}" ]; then + cat ${ROBOTS_TXT_OVERWRITE_FILE} > ROBOTS_TXT_FILE +fi + gitlab-workhorse \ -logFile ${GITLAB_WORKHORSE_LOG_FILE} \ -logFormat ${GITLAB_WORKHORSE_LOG_FORMAT} \ -- GitLab From a6e58e515a7368af92871f4a64c48fecfd3fc0d4 Mon Sep 17 00:00:00 2001 From: Sarmad Abualkaz Date: Sat, 17 Apr 2021 20:50:26 +0000 Subject: [PATCH 2/2] configure public/robot.txt: on configuring mount-path and check for readability --- gitlab-workhorse/scripts/start-workhorse | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gitlab-workhorse/scripts/start-workhorse b/gitlab-workhorse/scripts/start-workhorse index b934692d5..1622c88ed 100755 --- a/gitlab-workhorse/scripts/start-workhorse +++ b/gitlab-workhorse/scripts/start-workhorse @@ -15,14 +15,19 @@ if [[ "${GITLAB_WORKHORSE_PROM_LISTEN_ADDR}" =~ ^.+:[0-9][0-9]{0,4}$ ]]; then fi # option to append/overwrite robot.txt -ROBOTS_TXT_APPEND_FILE="${ROBOTS_TXT_APPEND_FILE:-$TMPDIR/robots_append.txt}" -ROBOTS_TXT_OVERWRITE_FILE="${ROBOTS_TXT_OVERWRITE_FILE:-$TMPDIR/robots_overwrite.txt}" +if [[ ! -z "${ROBOTSTXT_CONFIG_MOUNT_PATH}" ]]; then + ROBOTS_TXT_APPEND_FILE="${ROBOTS_TXT_APPEND_FILE:-$ROBOTSTXT_CONFIG_MOUNT_PATH/robots_append.txt}" + ROBOTS_TXT_OVERWRITE_FILE="${ROBOTS_TXT_OVERWRITE_FILE:-$ROBOTSTXT_CONFIG_MOUNT_PATH/robots_overwrite.txt}" +else + ROBOTS_TXT_APPEND_FILE="${ROBOTS_TXT_APPEND_FILE:-$TMPDIR/robots_append.txt}" + ROBOTS_TXT_OVERWRITE_FILE="${ROBOTS_TXT_OVERWRITE_FILE:-$TMPDIR/robots_overwrite.txt}" +fi export ROBOTS_TXT_FILE=/srv/gitlab/public/robots.txt -if [ -f "${ROBOTS_TXT_APPEND_FILE}" ]; then +if [ -f "${ROBOTS_TXT_APPEND_FILE}" ] && [ -r "${ROBOTS_TXT_APPEND_FILE}" ]; then cat ${ROBOTS_TXT_APPEND_FILE} >> ROBOTS_TXT_FILE -elif [ -f "${ROBOTS_TXT_OVERWRITE_FILE}" ]; then +elif [ -f "${ROBOTS_TXT_OVERWRITE_FILE}" ] && && [ -r "${ROBOTS_TXT_OVERWRITE_FILE}" ]; then cat ${ROBOTS_TXT_OVERWRITE_FILE} > ROBOTS_TXT_FILE fi -- GitLab