@@ -23,46 +23,56 @@ trap 'log "An error occurred. Exiting with status $?."' ERR
2323
2424log " Starting node setup (common)."
2525
26+ if [ -n " ${GOOSE_CONFIG_DIR:- } " ]; then
27+ RESOLVED_GOOSE_CONFIG_DIR=" ${GOOSE_CONFIG_DIR} "
28+ elif [ -n " ${GOOSE_PATH_ROOT:- } " ]; then
29+ RESOLVED_GOOSE_CONFIG_DIR=" ${GOOSE_PATH_ROOT} /config"
30+ else
31+ RESOLVED_GOOSE_CONFIG_DIR=" ${HOME} /.config/goose"
32+ fi
33+ MCP_HERMIT_DIR=" ${RESOLVED_GOOSE_CONFIG_DIR} /mcp-hermit"
34+
2635# One-time cleanup for existing Linux users to fix locking issues
27- CLEANUP_MARKER=" ${HOME} /.config/goose /.mcp-hermit-cleanup-v1"
36+ CLEANUP_MARKER=" ${RESOLVED_GOOSE_CONFIG_DIR} /.mcp-hermit-cleanup-v1"
2837if [[ " $( uname -s) " == " Linux" ]] && [ ! -f " ${CLEANUP_MARKER} " ]; then
2938 log " Performing one-time cleanup of old mcp-hermit directory to fix locking issues."
30- if [ -d " ${HOME} /.config/goose/mcp-hermit " ]; then
31- rm -rf " ${HOME} /.config/goose/mcp-hermit "
39+ if [ -d " ${MCP_HERMIT_DIR} " ]; then
40+ rm -rf " ${MCP_HERMIT_DIR} "
3241 log " Removed old mcp-hermit directory."
3342 fi
43+ mkdir -p " ${RESOLVED_GOOSE_CONFIG_DIR} "
3444 touch " ${CLEANUP_MARKER} "
3545 log " Cleanup completed. Marker file created."
3646fi
3747
38- # Ensure ${HOME}/.config/goose/ mcp-hermit/bin exists
39- log " Creating directory ${HOME} /.config/goose/mcp-hermit /bin if it does not exist."
40- mkdir -p " ${HOME} /.config/goose/mcp-hermit /bin"
48+ # Ensure mcp-hermit/bin exists
49+ log " Creating directory ${MCP_HERMIT_DIR} /bin if it does not exist."
50+ mkdir -p " ${MCP_HERMIT_DIR} /bin"
4151
42- # Change to the ${HOME}/.config/goose/ mcp-hermit directory
43- log " Changing to directory ${HOME} /.config/goose/mcp-hermit ."
44- cd " ${HOME} /.config/goose/mcp-hermit "
52+ # Change to the mcp-hermit directory
53+ log " Changing to directory ${MCP_HERMIT_DIR} ."
54+ cd " ${MCP_HERMIT_DIR} "
4555
4656
4757# Check if hermit binary exists and download if not
48- if [ ! -f " ${HOME} /.config/goose/mcp-hermit /bin/hermit" ]; then
58+ if [ ! -f " ${MCP_HERMIT_DIR} /bin/hermit" ]; then
4959 log " Hermit binary not found. Downloading hermit binary."
5060 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" \
51- | gzip -dc > " ${HOME} /.config/goose/mcp-hermit/ bin/hermit" && chmod +x " ${HOME} /.config/goose/mcp-hermit /bin/hermit"
61+ | gzip -dc > " ${MCP_HERMIT_DIR} / bin/hermit" && chmod +x " ${MCP_HERMIT_DIR} /bin/hermit"
5262 log " Hermit binary downloaded and made executable."
5363else
5464 log " Hermit binary already exists. Skipping download."
5565fi
5666
5767
5868log " setting hermit cache to be local for MCP servers"
59- mkdir -p " ${HOME} /.config/goose/mcp-hermit /cache"
60- export HERMIT_STATE_DIR=" ${HOME} /.config/goose/mcp-hermit /cache"
69+ mkdir -p " ${MCP_HERMIT_DIR} /cache"
70+ export HERMIT_STATE_DIR=" ${MCP_HERMIT_DIR} /cache"
6171
6272
6373# Update PATH
64- export PATH=" ${HOME} /.config/goose/mcp-hermit /bin:${PATH} "
65- log " Updated PATH to include ${HOME} /.config/goose/mcp-hermit /bin."
74+ export PATH=" ${MCP_HERMIT_DIR} /bin:${PATH} "
75+ log " Updated PATH to include ${MCP_HERMIT_DIR} /bin."
6676
6777
6878# Verify hermit installation
@@ -78,7 +88,7 @@ if [ ! -f "bin/activate-hermit" ]; then
7888 log " Creating temp dir with bin subdirectory for hermit copy to avoid self-update locks."
7989 HERMIT_TMP_DIR=" /tmp/hermit_tmp_$$ /bin"
8090 mkdir -p " ${HERMIT_TMP_DIR} "
81- cp " ${HOME} /.config/goose/mcp-hermit /bin/hermit" " ${HERMIT_TMP_DIR} /hermit"
91+ cp " ${MCP_HERMIT_DIR} /bin/hermit" " ${HERMIT_TMP_DIR} /hermit"
8292 chmod +x " ${HERMIT_TMP_DIR} /hermit"
8393 export PATH=" ${HERMIT_TMP_DIR} :${PATH} "
8494 HERMIT_CLEANUP_DIR=" /tmp/hermit_tmp_$$ "
@@ -124,10 +134,10 @@ if [ -n "${GOOSE_NPM_REGISTRY:-}" ] && curl -s --head --fail "${GOOSE_NPM_REGIST
124134 # Check if GOOSE_NPM_CERT is set and accessible
125135 if [ -n " ${GOOSE_NPM_CERT:- } " ] && curl -s --head --fail " ${GOOSE_NPM_CERT} " > /dev/null; then
126136 log " Downloading certificate from: ${GOOSE_NPM_CERT} "
127- curl -sSL -o " ${HOME} /.config/goose/mcp-hermit /cert.pem" " ${GOOSE_NPM_CERT} "
137+ curl -sSL -o " ${MCP_HERMIT_DIR} /cert.pem" " ${GOOSE_NPM_CERT} "
128138 if [ $? -eq 0 ]; then
129139 log " Certificate downloaded successfully."
130- export NODE_EXTRA_CA_CERTS=" ${HOME} /.config/goose/mcp-hermit /cert.pem"
140+ export NODE_EXTRA_CA_CERTS=" ${MCP_HERMIT_DIR} /cert.pem"
131141 else
132142 log " Unable to download the certificate. Skipping certificate setup."
133143 fi
0 commit comments