Skip to content

Commit

Permalink
Changes to how entrypoint handles arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaSBrown committed Feb 14, 2024
1 parent 9e059fe commit f5817b3
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
8 changes: 4 additions & 4 deletions core/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ set -euf -o pipefail

if [ -n "$UID" ]; then
usermod -u $UID datafed
su datafed
fi

SCRIPT=$(realpath "$0")
Expand All @@ -19,7 +18,7 @@ log_path="$DATAFED_DEFAULT_LOG_PATH"

if [ ! -d "${log_path}" ]
then
mkdir -p "${log_path}"
su -c "mkdir -p ${log_path}" datafed
fi

if [ "$#" -eq 0 ]; then
Expand All @@ -32,9 +31,10 @@ datafed_core_exec=$(basename "$1")
if [ "${datafed_core_exec}" = "datafed-core" ]
then
# Send output to log file
"$@" 2>&1 | tee "$log_path/datafed-core.log"
# For this to work all commands must be passed in as a single string
su datafed -c '"$@"' -- argv0 "$@" 2>&1 | tee "$log_path/datafed-core.log"
else
echo "Not sending output to datafed-core.log"
# If not do not by default send to log file
exec "$@"
su datafed -c '"$@"' -- argv0 "$@"
fi
2 changes: 2 additions & 0 deletions repository/docker/Dockerfile.repo.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ COPY ./repository/docker/entrypoint_repo.sh ${BUILD_DIR}/repository/docker/
# All files should be owned by the datafed user
RUN chown -R datafed:datafed ${DATAFED_DIR}

USER datafed

RUN ${BUILD_DIR}/scripts/generate_datafed.sh &&\
cmake -S. -B build -DBUILD_REPO_SERVER=True -DBUILD_AUTHZ=False \
-DBUILD_CORE_SERVER=False -DBUILD_WEB_SERVER=False \
Expand Down
5 changes: 2 additions & 3 deletions repository/docker/entrypoint_authz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ set -euf -o pipefail

if [ -n "$UID" ]; then
usermod -u $UID datafed
su datafed
fi


Expand All @@ -22,7 +21,7 @@ log_path="$DATAFED_DEFAULT_LOG_PATH"

if [ ! -d "${log_path}" ]
then
mkdir -p "${log_path}"
su -c "mkdir -p ${log_path}" datafed
fi

exec "$@"
su datafed -c '"$@"' -- argv0 "$@"
5 changes: 2 additions & 3 deletions repository/docker/entrypoint_repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ set -euf -o pipefail

if [ -n "$UID" ]; then
usermod -u $UID datafed
su datafed
fi

SCRIPT=$(realpath "$0")
Expand All @@ -19,7 +18,7 @@ log_path="$DATAFED_DEFAULT_LOG_PATH"

if [ ! -d "${log_path}" ]
then
mkdir -p "${log_path}"
su -c "mkdir -p ${log_path}" datafed
fi

exec "$@"
su datafed -c '"$@"' -- argv0 "$@"
7 changes: 3 additions & 4 deletions web/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ set -euf -o pipefail

if [ -n "$UID" ]; then
usermod -u $UID datafed
su datafed
fi


Expand All @@ -27,7 +26,7 @@ log_path=$(grep "log-path" /datafed/install/web/datafed-ws.cfg | cut -d "=" -f 2

if [ ! -d "${log_path}" ]
then
mkdir -p "${log_path}"
su -c "mkdir -p ${log_path}" datafed
fi

if [ "$#" -eq 0 ]; then
Expand All @@ -40,9 +39,9 @@ datafed_ws_exec=$(basename "$1")
if [ "${datafed_ws_exec}" = "datafed-ws.js" ]
then
# Send output to log file
"$@" 2>&1 | tee "$log_path/datafed-ws.log"
su datafed -c '"$@"' -- argv0 "$@" 2>&1 | tee "$log_path/datafed-ws.log"
else
echo "Not sending output to datafed-ws.log"
# If not do not by default send to log file
exec "$@"
su datafed -c '"$@"' -- argv0 "$@"
fi

0 comments on commit f5817b3

Please sign in to comment.