File size: 1,002 Bytes
feccc69
 
 
 
 
 
 
 
 
 
 
 
534def0
 
 
 
33b8f8e
feccc69
 
 
 
 
534def0
 
feccc69
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/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 600 /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