Skip to content

Commit

Permalink
parametrise based on config
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelneale committed Jan 21, 2025
1 parent 05eb0c7 commit 6686713
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 23 deletions.
51 changes: 39 additions & 12 deletions ui/desktop/src/bin/npx
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,27 @@ trap 'log "An error occurred. Exiting with status $?."' ERR

log "Starting npx setup script."

# Ensure ~/.goose/mcp-hermit/bin exists
log "Creating directory ~/.goose/mcp-hermit/bin if it does not exist."
mkdir -p ~/.goose/mcp-hermit/bin
# Ensure ~/.config/goose/mcp-hermit/bin exists
log "Creating directory ~/.config/goose/mcp-hermit/bin if it does not exist."
mkdir -p ~/.config/goose/mcp-hermit/bin

# Change to the ~/.goose/mcp-hermit directory
log "Changing to directory ~/.goose/mcp-hermit."
cd ~/.goose/mcp-hermit
# Change to the ~/.config/goose/mcp-hermit directory
log "Changing to directory ~/.config/goose/mcp-hermit."
cd ~/.config/goose/mcp-hermit

# Check if hermit binary exists and download if not
if [ ! -f ~/.goose/mcp-hermit/bin/hermit ]; then
if [ ! -f ~/.config/goose/mcp-hermit/bin/hermit ]; then
log "Hermit binary not found. Downloading hermit binary."
curl -fsSL "https://github.com/cashapp/hermit/releases/download/stable/hermit-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/').gz" \
| gzip -dc > ~/.goose/mcp-hermit/bin/hermit && chmod +x ~/.goose/mcp-hermit/bin/hermit
| gzip -dc > ~/.config/goose/mcp-hermit/bin/hermit && chmod +x ~/.config/goose/mcp-hermit/bin/hermit
log "Hermit binary downloaded and made executable."
else
log "Hermit binary already exists. Skipping download."
fi

# Update PATH
export PATH=~/.goose/mcp-hermit/bin:$PATH
log "Updated PATH to include ~/.goose/mcp-hermit/bin."
export PATH=~/.config/goose/mcp-hermit/bin:$PATH
log "Updated PATH to include ~/.config/goose/mcp-hermit/bin."


# Verify hermit installation
Expand All @@ -61,8 +61,35 @@ log "hermit: $(which hermit)"
log "node: $(which node)"
log "npx: $(which npx)"

# Set default registry to npm
export NPM_CONFIG_REGISTRY="https://registry.npmjs.org/"

log "Checking for GOOSE_NPM_REGISTRY and GOOSE_NPM_CERT environment variables for custom npm registry setup..."
# Check if GOOSE_NPM_REGISTRY is set and accessible
if [ -n "${GOOSE_NPM_REGISTRY:-}" ] && curl -s --head --fail "$GOOSE_NPM_REGISTRY" > /dev/null; then
log "Checking custom goose registry availability: $GOOSE_NPM_REGISTRY"
log "$GOOSE_NPM_REGISTRY is accessible. Using it for npm registry."
export NPM_CONFIG_REGISTRY="$GOOSE_NPM_REGISTRY"

# Check if GOOSE_NPM_CERT is set and accessible
if [ -n "${GOOSE_NPM_CERT:-}" ] && curl -s --head --fail "$GOOSE_NPM_CERT" > /dev/null; then
log "Downloading certificate from: $GOOSE_NPM_CERT"
curl -sSL -o ~/.config/goose/mcp-hermit/cert.pem "$GOOSE_NPM_CERT"
if [ $? -eq 0 ]; then
log "Certificate downloaded successfully."
export NODE_EXTRA_CA_CERTS=~/.config/goose/mcp-hermit/cert.pem
else
log "Unable to download the certificate. Skipping certificate setup."
fi
else
log "GOOSE_NPM_CERT is either not set or not accessible. Skipping certificate setup."
fi

else
log "GOOSE_NPM_REGISTRY is either not set or not accessible. Falling back to default npm registry."
export NPM_CONFIG_REGISTRY="https://registry.npmjs.org/"
fi




# Final step: Execute npx with passed arguments
log "Executing 'npx' command with arguments: $*"
Expand Down
49 changes: 38 additions & 11 deletions ui/desktop/src/bin/uvx
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,27 @@ trap 'log "An error occurred. Exiting with status $?."' ERR

log "Starting uvx setup script."

# Ensure ~/.goose/mcp-hermit/bin exists
log "Creating directory ~/.goose/mcp-hermit/bin if it does not exist."
mkdir -p ~/.goose/mcp-hermit/bin
# Ensure ~/.config/goose/mcp-hermit/bin exists
log "Creating directory ~/.config/goose/mcp-hermit/bin if it does not exist."
mkdir -p ~/.config/goose/mcp-hermit/bin

# Change to the ~/.goose/mcp-hermit directory
log "Changing to directory ~/.goose/mcp-hermit."
cd ~/.goose/mcp-hermit
# Change to the ~/.config/goose/mcp-hermit directory
log "Changing to directory ~/.config/goose/mcp-hermit."
cd ~/.config/goose/mcp-hermit

# Check if hermit binary exists and download if not
if [ ! -f ~/.goose/mcp-hermit/bin/hermit ]; then
if [ ! -f ~/.config/goose/mcp-hermit/bin/hermit ]; then
log "Hermit binary not found. Downloading hermit binary."
curl -fsSL "https://github.com/cashapp/hermit/releases/download/stable/hermit-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/').gz" \
| gzip -dc > ~/.goose/mcp-hermit/bin/hermit && chmod +x ~/.goose/mcp-hermit/bin/hermit
| gzip -dc > ~/.config/goose/mcp-hermit/bin/hermit && chmod +x ~/.config/goose/mcp-hermit/bin/hermit
log "Hermit binary downloaded and made executable."
else
log "Hermit binary already exists. Skipping download."
fi

# Update PATH
export PATH=~/.goose/mcp-hermit/bin:$PATH
log "Updated PATH to include ~/.goose/mcp-hermit/bin."
export PATH=~/.config/goose/mcp-hermit/bin:$PATH
log "Updated PATH to include ~/.config/goose/mcp-hermit/bin."


# Verify hermit installation
Expand All @@ -62,7 +62,34 @@ log "uv: $(which uv)"
log "uvx: $(which uvx)"


export UV_INDEX_URL="https://pypi.org/simple"
log "Checking for GOOSE_UV_REGISTRY and GOOSE_UV_CERT environment variables for custom python/pip/UV registry setup..."
# Check if GOOSE_UV_REGISTRY is set and accessible
if [ -n "${GOOSE_UV_REGISTRY:-}" ] && curl -s --head --fail "$GOOSE_UV_REGISTRY" > /dev/null; then
log "Checking custom goose registry availability: $GOOSE_UV_REGISTRY"
log "$GOOSE_UV_REGISTRY is accessible. Using it for UV registry."
export UV_INDEX_URL="$GOOSE_UV_REGISTRY"

if [ -n "${GOOSE_UV_CERT:-}" ] && curl -s --head --fail "$GOOSE_UV_CERT" > /dev/null; then
log "Downloading certificate from: $GOOSE_UV_CERT"
curl -sSL -o ~/.config/goose/mcp-hermit/cert.pem "$GOOSE_UV_CERT"
if [ $? -eq 0 ]; then
log "Certificate downloaded successfully."
export SSL_CLIENT_CERT=~/.config/goose/mcp-hermit/cert.pem
else
log "Unable to download the certificate. Skipping certificate setup."
fi
else
log "GOOSE_UV_CERT is either not set or not accessible. Skipping certificate setup."
fi

else
log "GOOSE_UV_REGISTRY is either not set or not accessible. Falling back to default pip registry."
export UV_INDEX_URL="https://pypi.org/simple"
fi






# Final step: Execute uvx with passed arguments
Expand Down

0 comments on commit 6686713

Please sign in to comment.