ds2api / entrypoint.sh
luckfun233
Fix config.json permission denied on HF Spaces persistent storage
534def0
Raw
History Blame Contribute Delete
1 kB
#!/bin/bash
set -e
# Fix /data permissions for HF Spaces Persistent Storage
if [ -d /data ]; then
chown -R ds2api:ds2api /data 2>/dev/null || true
fi
# Create config file if not exists or is empty (with empty JSON object)
if [ ! -f /data/config.json ] || [ ! -s /data/config.json ]; then
echo {} > /data/config.json
fi
# Always ensure config.json is writable by ds2api user, even if the file
# was created by a previous container with different ownership (common on
# HuggingFace Spaces persistent storage after rebuild).
chown ds2api:ds2api /data/config.json 2>/dev/null || true
chmod 644 /data/config.json 2>/dev/null || true
# Create chat history file if not exists or is empty
if [ ! -f /data/chat_history.json ] || [ ! -s /data/chat_history.json ]; then
echo {} > /data/chat_history.json
fi
chown ds2api:ds2api /data/chat_history.json 2>/dev/null || true
chmod 644 /data/chat_history.json 2>/dev/null || true
# Start the application as ds2api user
exec gosu ds2api /usr/local/bin/ds2api