From cf31c7c25db548c64764a1c32055b2da738e7ed6 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Tue, 1 Apr 2025 19:37:58 -0600 Subject: [PATCH] fix(goose): ensure configuration is run as user --- mcontainer/drivers/goose/mc-init.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mcontainer/drivers/goose/mc-init.sh b/mcontainer/drivers/goose/mc-init.sh index be87139..75a755f 100755 --- a/mcontainer/drivers/goose/mc-init.sh +++ b/mcontainer/drivers/goose/mc-init.sh @@ -103,17 +103,6 @@ if [ -n "$LANGFUSE_INIT_PROJECT_SECRET_KEY" ] && [ -n "$LANGFUSE_INIT_PROJECT_PU export LANGFUSE_URL="${LANGFUSE_URL:-https://cloud.langfuse.com}" fi -# Update Goose configuration with available MCP servers -if [ -f "/usr/local/bin/update-goose-config.sh" ]; then - echo "Updating Goose configuration with MCP servers..." - bash /usr/local/bin/update-goose-config.sh -elif [ -f "$(dirname "$0")/update-goose-config.sh" ]; then - echo "Updating Goose configuration with MCP servers..." - bash "$(dirname "$0")/update-goose-config.sh" -else - echo "Warning: update-goose-config.sh script not found. Goose configuration will not be updated." -fi - # Create symlinks for persistent configurations defined in the driver if [ -n "$MC_PERSISTENT_LINKS" ]; then echo "Creating persistent configuration symlinks..." @@ -151,6 +140,17 @@ if [ -n "$MC_PERSISTENT_LINKS" ]; then echo "Persistent configuration symlinks created." fi +# Update Goose configuration with available MCP servers (run as mcuser after symlinks are created) +if [ -f "/usr/local/bin/update-goose-config.sh" ]; then + echo "Updating Goose configuration with MCP servers as mcuser..." + gosu mcuser bash /usr/local/bin/update-goose-config.sh +elif [ -f "$(dirname "$0")/update-goose-config.sh" ]; then + echo "Updating Goose configuration with MCP servers as mcuser..." + gosu mcuser bash "$(dirname "$0")/update-goose-config.sh" +else + echo "Warning: update-goose-config.sh script not found. Goose configuration will not be updated." +fi + # Mark initialization as complete echo "=== MC Initialization completed at $(date) ===" echo "INIT_COMPLETE=true" > /init.status