Skip to content

Commit

Permalink
Expand arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
JimMadge committed Oct 22, 2024
1 parent 2941bf9 commit 917342f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
run: docker compose up -d

- name: Wait for Nexus to start
run: sleep 180
run: sleep 120

- name: Show nexus allowlist container logs
run: docker compose logs allowlist
Expand Down
17 changes: 6 additions & 11 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ export ALLOWLIST_DIR=/allowlists
export PYPI_ALLOWLIST="$ALLOWLIST_DIR"/pypi.allowlist
export CRAN_ALLOWLIST="$ALLOWLIST_DIR"/cran.allowlist

export CONNECT_ARGS="--admin-password $NEXUS_ADMIN_PASSWORD --nexus-host $NEXUS_HOST --nexus-port $NEXUS_PORT"
if [ -n "$NEXUS_PATH" ]; then
export CONNECT_ARGS="$CONNECT_ARGS --nexus-path $NEXUS_PATH"
fi

timestamp() {
date -Is
}
Expand Down Expand Up @@ -41,34 +36,34 @@ nexus-allowlist --version
# Initial configuration
if [ -f "$NEXUS_DATA_DIR/admin.password" ]; then
echo "$(timestamp) Initial password file present, running initial configuration"
nexus-allowlist "$CONNECT_ARGS" change-initial-password --path "$NEXUS_DATA_DIR"
nexus-allowlist "$CONNECT_ARGS" initial-configuration --packages "$NEXUS_PACKAGES" --pypi-package-file "$ALLOWLIST_DIR/pypi.allowlist" --cran-package-file "$ALLOWLIST_DIR/cran.allowlist"
nexus-allowlist --admin-password "$NEXUS_ADMIN_PASSWORD" --nexus-host "$NEXUS_HOST" --nexus-path "$NEXUS_PATH" --nexus-port "$NEXUS_PORT" change-initial-password --path "$NEXUS_DATA_DIR"
nexus-allowlist --admin-password "$NEXUS_ADMIN_PASSWORD" --nexus-host "$NEXUS_HOST" --nexus-path "$NEXUS_PATH" --nexus-port "$NEXUS_PORT" initial-configuration --packages "$NEXUS_PACKAGES" --pypi-package-file "$ALLOWLIST_DIR/pypi.allowlist" --cran-package-file "$ALLOWLIST_DIR/cran.allowlist"
else
echo "$(timestamp) No initial password file found, skipping initial configuration"
fi

# Test authentication
if ! nexus-allowlist "$CONNECT_ARGS" test-authentication; then
if ! nexus-allowlist --admin-password "$NEXUS_ADMIN_PASSWORD" --nexus-host "$NEXUS_HOST" --nexus-path "$NEXUS_PATH" --nexus-port "$NEXUS_PORT" test-authentication; then
echo "$(timestamp) API authentication test failed, exiting"
exit 1
fi

if [ -n "$ENTR_FALLBACK" ]; then
echo "$(timestamp) Using fallback file monitoring"
# Run allowlist configuration now
nexus-allowlist "$CONNECT_ARGS" update-allowlists --packages "$NEXUS_PACKAGES" --pypi-package-file "$PYPI_ALLOWLIST" --cran-package-file "$CRAN_ALLOWLIST"
nexus-allowlist --admin-password "$NEXUS_ADMIN_PASSWORD" --nexus-host "$NEXUS_HOST" --nexus-path "$NEXUS_PATH" --nexus-port "$NEXUS_PORT" update-allowlists --packages "$NEXUS_PACKAGES" --pypi-package-file "$PYPI_ALLOWLIST" --cran-package-file "$CRAN_ALLOWLIST"
# Periodically check for modification of allowlist files and run configuration again when they are
hash=$(hashes)
while true; do
new_hash=$(hashes)
if [ "$hash" != "$new_hash" ]; then
nexus-allowlist "$CONNECT_ARGS" update-allowlists --packages "$NEXUS_PACKAGES" --pypi-package-file "$PYPI_ALLOWLIST" --cran-package-file "$CRAN_ALLOWLIST"
nexus-allowlist --admin-password "$NEXUS_ADMIN_PASSWORD" --nexus-host "$NEXUS_HOST" --nexus-path "$NEXUS_PATH" --nexus-port "$NEXUS_PORT" update-allowlists --packages "$NEXUS_PACKAGES" --pypi-package-file "$PYPI_ALLOWLIST" --cran-package-file "$CRAN_ALLOWLIST"
hash=$new_hash
fi
sleep 5
done
else
echo "$(timestamp) Using entr for file monitoring"
# Run allowlist configuration now, and again whenever allowlist files are modified
find "$ALLOWLIST_DIR"/*.allowlist | entr -n nexus-allowlist "$CONNECT_ARGS" update-allowlists --packages "$NEXUS_PACKAGES" --pypi-package-file "$PYPI_ALLOWLIST" --cran-package-file "$CRAN_ALLOWLIST"
find "$ALLOWLIST_DIR"/*.allowlist | entr -n nexus-allowlist --admin-password "$NEXUS_ADMIN_PASSWORD" --nexus-host "$NEXUS_HOST" --nexus-path "$NEXUS_PATH" --nexus-port "$NEXUS_PORT" update-allowlists --packages "$NEXUS_PACKAGES" --pypi-package-file "$PYPI_ALLOWLIST" --cran-package-file "$CRAN_ALLOWLIST"
fi

0 comments on commit 917342f

Please sign in to comment.