Skip to content

Commit

Permalink
RELEASE 1.2.0-09
Browse files Browse the repository at this point in the history
adjust modification date for git repositories
obfuscate password checking out git repositories
improve error detection in conjunction with git
  • Loading branch information
1thorsten committed Feb 12, 2024
1 parent bc31aa3 commit 6c115e3
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 24 deletions.
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ ENV PHP_SOCK=/var/run/php/php${PHP_VERSION}-fpm.sock
ENV PHP_LOG_SYSOUT=true

# http-over-all part
ARG RELEASE="1.2.0-08"
ARG RELEASE="1.2.0-09"

ARG SSL_COUNTRY=DE
ARG SSL_STATE=Berlin
Expand Down Expand Up @@ -81,7 +81,11 @@ RUN set -x && \
find /scripts -name "*.sh" -exec sed -i 's/\r$//' {} + && \
echo "\nexport RELEASE=${RELEASE}\n" >> /scripts/system-helper.sh && \
echo "source /scripts/system-helper.sh" >> /etc/bash.bashrc && \
echo "http-over-all part successfully terminated" && \
# colors (bash)
sed -i 's/^# export/export/' /root/.bashrc && \
sed -i 's/^# alias l/alias l/g' /root/.bashrc && \
echo "alias grep=\"grep --color=always\"" >> /root/.bashrc && \
echo "alias grep=\"grep --color=always\"" >> /home/$USER/.bashrc && \
set +x

HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD [ "/scripts/healthcheck.sh" ]
Expand Down
Binary file modified favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 24 additions & 5 deletions incontainer/connect-services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -340,31 +340,36 @@ function connect_or_update_git_repos() {

# check accessibility
local ACCESSIBLE

local OBF_REPO_URL=$REPO_URL
parse_url "${REPO_URL%/}/"

local URL_STRICT="${PARSED_PROTO}${PARSED_HOST}${PARSED_PORT}"
if [ -n "$PARSED_USER" ]; then
local CURL_CREDENTIALS="--user ${PARSED_USER%@}"
local OBF_CURL_CREDENTIALS="--user obfuscated"
OBF_REPO_URL=${REPO_URL//$PARSED_USER/obfuscated@}
fi
# shellcheck disable=SC2086
local HTTP_STATUS="$(curl ${CURL_CREDENTIALS} -s -o /dev/null -I -w "%{http_code}" --connect-timeout 1 "${URL_STRICT}")"
if [[ "${HTTP_STATUS}" -eq '200' || "${HTTP_STATUS}" -eq '401' || "${HTTP_STATUS}" -eq '302' ]]; then
ACCESSIBLE=true
else
ACCESSIBLE=false
echo "command: curl ${CURL_CREDENTIALS} -s -o /dev/null -I -w %{http_code} --connect-timeout 1 ${URL_STRICT}"
echo "resource ('${REPO_URL}' -> '${URL_STRICT}') is not accessible -> ${HTTP_STATUS}"
echo "command: curl ${OBF_CURL_CREDENTIALS} -s -o /dev/null -I -w %{http_code} --connect-timeout 1 ${URL_STRICT}"
echo "resource ('${OBF_REPO_URL}' -> '${URL_STRICT}') is not accessible -> ${HTTP_STATUS}"
fi

if [ ! -d "${GIT_MOUNT}" ]; then
if ! ${ACCESSIBLE}; then
echo "${GIT_MOUNT} not exists -> ignore"
continue
fi
clone_git_repo "${GIT_REPO_PATH}" "${REPO_URL}" "$RESOURCE_NAME"
clone_git_repo "${GIT_REPO_PATH}" "${REPO_URL}" "${OBF_REPO_URL}" "$RESOURCE_NAME"
elif [ -e "${GIT_REPO_PATH}.error" ]; then
echo "detect previous error: ${GIT_REPO_PATH}.error"
if ${ACCESSIBLE}; then
clone_git_repo_safe "${GIT_REPO_PATH}" "${REPO_URL}" "$RESOURCE_NAME"
clone_git_repo_safe "${GIT_REPO_PATH}" "${REPO_URL}" "${OBF_REPO_URL}" "$RESOURCE_NAME"
fi
# if error file still exists, go with the existing local repo
if [ -e "${GIT_REPO_PATH}.error" ]; then
Expand All @@ -384,7 +389,9 @@ function connect_or_update_git_repos() {

if ${ACCESSIBLE}; then
local git_checkout=$(git -C "${GIT_MOUNT}" checkout "${git_branch}" -f 2>&1)
if [[ "${git_checkout}" != *"Already on"* ]]; then echo "${git_checkout}"; fi
if [[ "${git_checkout}" != *"Already on"* ]]; then
echo "${git_checkout}";
fi

git -C "${GIT_MOUNT}" clean -df
git -C "${GIT_MOUNT}" reset --hard >/dev/null
Expand All @@ -409,6 +416,9 @@ function connect_or_update_git_repos() {
elif [[ "${git_output}" == *"Authentication failed"* ]]; then
echo "git repo is currently not accessible -> Authentication failed"
ACCESSIBLE=false
elif [[ "${git_output}" == "fatal:"* ]]; then
echo "local git repo is not accessible"
ACCESSIBLE=false
else
echo "error resetting state, retrieve repo again"
echo "touch ${GIT_REPO_PATH}.error"
Expand All @@ -421,6 +431,15 @@ function connect_or_update_git_repos() {
# all works well / show subject of last commit
local git_log=$(git -C "${GIT_MOUNT}" log -1 --pretty=format:'%s (%ar, %an)')
echo "last_commit_log: ${git_log}"

# set file times
if pushd "$GIT_MOUNT" > /dev/null ; then
local num=$(/usr/share/rsync/scripts/git-set-file-times | wc -l)
if [ "$num" != "0" ]; then
echo "set time for $num files -> /usr/share/rsync/scripts/git-set-file-times"
fi
popd > /dev/null || echo "ERR: popd from '$(pwd)'"
fi
fi

# update -> call from periodic_jobs
Expand Down
22 changes: 13 additions & 9 deletions incontainer/helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -512,39 +512,43 @@ function initial_create_symlinks_for_resources() {
function clone_git_repo() {
local GIT_REPO_PATH="${1}"
local REPO_URL="${2}"
local RESOURCE_NAME="${3}"
local OBF_REPO_URL="${3}"
local RESOURCE_NAME="${4}"

echo mkdir -p "${GIT_REPO_PATH}"
mkdir -p "${GIT_REPO_PATH}"

echo git -C "${GIT_REPO_PATH}" clone "${REPO_URL}"
git -C "${GIT_REPO_PATH}" clone "${REPO_URL}"
echo git -C "${GIT_REPO_PATH}" clone "${OBF_REPO_URL}"
if ! git -C "${GIT_REPO_PATH}" clone "${REPO_URL}"; then
echo "cloning repo failed"
fi

echo "$(date +'%T'): git cloned: ${RESOURCE_NAME}"
echo "$(date +'%T'): git repo cloned: ${RESOURCE_NAME}"
}

function clone_git_repo_safe() {
local GIT_REPO_PATH="${1}"
local REPO_URL="${2}"
local RESOURCE_NAME="${3}"
local OBF_REPO_URL="${3}"
local RESOURCE_NAME="${4}"

local PATH_SAFE="${GIT_REPO_PATH}_safe"
rm -rf "${PATH_SAFE}"
mkdir -p "${PATH_SAFE}"

echo git -C "${PATH_SAFE}" clone "${REPO_URL}"
echo git -C "${PATH_SAFE}" clone "${OBF_REPO_URL}"
if git -C "${PATH_SAFE}" clone "${REPO_URL}"; then
echo "clone succeeded"
echo "cloning repo succeeded"
rm -f "${GIT_REPO_PATH}.error"
rm -rf "${GIT_REPO_PATH}"
echo "mv ${PATH_SAFE} ${GIT_REPO_PATH}"
mv "${PATH_SAFE}" "${GIT_REPO_PATH}"
else
echo "clone failed"
echo "cloning repo failed"
rm -rf "${PATH_SAFE}"
fi

echo "$(date +'%T'): git safe cloned: ${RESOURCE_NAME}"
echo "$(date +'%T'): git repo safe cloned: ${RESOURCE_NAME}"
}

function periodic_jobs() {
Expand Down
5 changes: 4 additions & 1 deletion tools/doclig/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ RUN set -x && \
find /scripts -name "*.sh" -exec sed -i 's/\r$//' {} + && \
echo "\nexport RELEASE=${RELEASE}\n" >> /scripts/system-helper.sh && \
echo "source /scripts/system-helper.sh" >> /etc/bash.bashrc && \
echo "http-over-all part successfully terminated" && \
# colors (bash)
sed -i 's/^# export/export/' /root/.bashrc && \
sed -i 's/^# alias l/alias l/g' /root/.bashrc && \
echo "alias grep=\"grep --color=always\"" >> /root/.bashrc && \
set +x

ADD tools/doclig/bin/doclig_lnx /usr/local/bin/doclig
Expand Down
14 changes: 7 additions & 7 deletions tools/doclig/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.21

require (
github.com/docker/distribution v2.8.3+incompatible
github.com/docker/docker v25.0.0+incompatible
github.com/docker/docker v25.0.3+incompatible
)

require (
Expand All @@ -24,12 +24,12 @@ require (
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.47.0 // indirect
go.opentelemetry.io/otel v1.22.0 // indirect
go.opentelemetry.io/otel/metric v1.22.0 // indirect
go.opentelemetry.io/otel/trace v1.22.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/sys v0.16.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.48.0 // indirect
go.opentelemetry.io/otel v1.23.1 // indirect
go.opentelemetry.io/otel/metric v1.23.1 // indirect
go.opentelemetry.io/otel/trace v1.23.1 // indirect
golang.org/x/mod v0.15.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.17.0 // indirect
gotest.tools/v3 v3.5.1 // indirect
Expand Down

0 comments on commit 6c115e3

Please sign in to comment.