fix(render): disable set -e during permission testing
- Disable set -e for entire permission testing section - Re-enable set -e after config is written - Simpler logic without complex conditionals - More reliable error handling
This commit is contained in:
parent
c23dd3e3e3
commit
3c1e781ab0
@ -6,17 +6,16 @@ echo "=== Render startup script ==="
|
|||||||
echo "CLAWDBOT_STATE_DIR=${CLAWDBOT_STATE_DIR}"
|
echo "CLAWDBOT_STATE_DIR=${CLAWDBOT_STATE_DIR}"
|
||||||
echo "HOME=${HOME}"
|
echo "HOME=${HOME}"
|
||||||
|
|
||||||
# Ensure HOME is set (fallback to /tmp if not set)
|
# Ensure HOME is set (node user's home is typically /home/node)
|
||||||
if [ -z "${HOME}" ]; then
|
if [ -z "${HOME}" ]; then
|
||||||
HOME="/tmp"
|
HOME="/home/node"
|
||||||
|
if [ ! -d "${HOME}" ]; then
|
||||||
|
HOME="/tmp"
|
||||||
|
fi
|
||||||
echo "Warning: HOME not set, using ${HOME}"
|
echo "Warning: HOME not set, using ${HOME}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Determine config directory - try in order until one works
|
# Config content
|
||||||
# 1. CLAWDBOT_STATE_DIR if set
|
|
||||||
# 2. /data/.clawdbot (Render persistent disk)
|
|
||||||
# 3. $HOME/.clawdbot (always writable by node user)
|
|
||||||
|
|
||||||
CONFIG_CONTENT='{
|
CONFIG_CONTENT='{
|
||||||
"gateway": {
|
"gateway": {
|
||||||
"mode": "local",
|
"mode": "local",
|
||||||
@ -27,29 +26,33 @@ CONFIG_CONTENT='{
|
|||||||
}
|
}
|
||||||
}'
|
}'
|
||||||
|
|
||||||
|
# Determine config directory - try in order until one works
|
||||||
|
# Temporarily disable set -e for permission testing
|
||||||
|
set +e
|
||||||
CONFIG_DIR=""
|
CONFIG_DIR=""
|
||||||
CONFIG_FILE=""
|
CONFIG_FILE=""
|
||||||
|
|
||||||
# Try each directory in order
|
# Try CLAWDBOT_STATE_DIR first if set
|
||||||
for dir in "${CLAWDBOT_STATE_DIR:-}" "/data/.clawdbot" "${HOME}/.clawdbot"; do
|
if [ -n "${CLAWDBOT_STATE_DIR}" ]; then
|
||||||
if [ -z "${dir}" ]; then
|
mkdir -p "${CLAWDBOT_STATE_DIR}" 2>/dev/null
|
||||||
continue
|
if echo "${CONFIG_CONTENT}" > "${CLAWDBOT_STATE_DIR}/clawdbot.json" 2>/dev/null; then
|
||||||
|
CONFIG_DIR="${CLAWDBOT_STATE_DIR}"
|
||||||
|
CONFIG_FILE="${CLAWDBOT_STATE_DIR}/clawdbot.json"
|
||||||
|
echo "Using CLAWDBOT_STATE_DIR: ${CONFIG_DIR}"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
# Temporarily disable set -e for this test
|
|
||||||
set +e
|
|
||||||
mkdir -p "${dir}" 2>/dev/null
|
|
||||||
if echo "${CONFIG_CONTENT}" > "${dir}/clawdbot.json" 2>/dev/null; then
|
|
||||||
set -e
|
|
||||||
CONFIG_DIR="${dir}"
|
|
||||||
CONFIG_FILE="${dir}/clawdbot.json"
|
|
||||||
echo "Successfully wrote config to: ${CONFIG_FILE}"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
set -e
|
|
||||||
done
|
|
||||||
|
|
||||||
# Ensure we have a config directory (should always succeed with HOME fallback)
|
# Try /data/.clawdbot if not set yet
|
||||||
|
if [ -z "${CONFIG_DIR}" ]; then
|
||||||
|
mkdir -p "/data/.clawdbot" 2>/dev/null
|
||||||
|
if echo "${CONFIG_CONTENT}" > "/data/.clawdbot/clawdbot.json" 2>/dev/null; then
|
||||||
|
CONFIG_DIR="/data/.clawdbot"
|
||||||
|
CONFIG_FILE="/data/.clawdbot/clawdbot.json"
|
||||||
|
echo "Using /data/.clawdbot: ${CONFIG_DIR}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Final fallback: use HOME (always writable by node user)
|
||||||
if [ -z "${CONFIG_DIR}" ]; then
|
if [ -z "${CONFIG_DIR}" ]; then
|
||||||
CONFIG_DIR="${HOME}/.clawdbot"
|
CONFIG_DIR="${HOME}/.clawdbot"
|
||||||
CONFIG_FILE="${CONFIG_DIR}/clawdbot.json"
|
CONFIG_FILE="${CONFIG_DIR}/clawdbot.json"
|
||||||
@ -58,6 +61,9 @@ if [ -z "${CONFIG_DIR}" ]; then
|
|||||||
echo "Using fallback: ${CONFIG_FILE}"
|
echo "Using fallback: ${CONFIG_FILE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Re-enable set -e for the rest of the script
|
||||||
|
set -e
|
||||||
|
|
||||||
echo "Config dir: ${CONFIG_DIR}"
|
echo "Config dir: ${CONFIG_DIR}"
|
||||||
echo "Config file: ${CONFIG_FILE}"
|
echo "Config file: ${CONFIG_FILE}"
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user