nomid2 commited on
Commit
614f648
·
verified ·
1 Parent(s): 747871c

Update entrypoint-wrapper.sh

Browse files
Files changed (1) hide show
  1. entrypoint-wrapper.sh +10 -35
entrypoint-wrapper.sh CHANGED
@@ -1,47 +1,22 @@
1
  #!/bin/sh
2
 
3
- # 使用临时目录替代 /data
4
  APP_DATA_DIR="/tmp/data"
5
 
6
  echo "Entrypoint wrapper: Attempting to create necessary directories in ephemeral FS..."
7
 
8
- echo "Ensuring directory $APP_DATA_DIR exists (for SQLite or other app data)..."
9
- mkdir -p "$APP_DATA_DIR"
10
- mkdir -p "$APP_DATA_DIR/logs" # 预先创建logs目录
11
- if [ $? -ne 0 ]; then
12
- echo "ERROR: Failed to create $APP_DATA_DIR. Application data storage might fail."
13
- else
14
- echo "$APP_DATA_DIR was created or already exists."
15
- echo "Listing permissions for /tmp:"
16
- ls -ld /tmp
17
- echo "Listing permissions for $APP_DATA_DIR:"
18
- ls -ld "$APP_DATA_DIR"
19
- echo "Attempting to create a test file in $APP_DATA_DIR:"
20
- touch "$APP_DATA_DIR/test_writable.txt"
21
- if [ $? -eq 0 ]; then
22
- echo "$APP_DATA_DIR is writable, test file created."
23
- rm "$APP_DATA_DIR/test_writable.txt"
24
- else
25
- echo "$APP_DATA_DIR is NOT writable directly by this script for creating files."
26
- fi
27
- fi
28
 
29
- # 创建符号链接,将 /data 指向 /tmp/data
30
- echo "Creating symbolic link from /data to $APP_DATA_DIR"
31
- if [ -d "/data" ]; then
32
- rm -rf /data 2>/dev/null || echo "Cannot remove /data, trying to work around..."
33
- fi
34
- ln -sf "$APP_DATA_DIR" /data 2>/dev/null || echo "Cannot create symlink, trying alternative approach..."
35
 
36
- # 如果符号链接失败,尝试绑定挂载(可能不会成功,但值得一试)
37
- if [ ! -L "/data" ]; then
38
- echo "Symlink failed, the application will likely still fail to write to /data/logs"
39
- echo "This is a limitation of the Hugging Face Spaces environment"
40
- fi
41
-
42
- # 设置环境变量(以防应用支持)
43
  export DATA_DIR="$APP_DATA_DIR"
44
  export LOG_DIR="$APP_DATA_DIR/logs"
45
 
46
- echo "Entrypoint wrapper: Starting application (expecting it to try /data/logs by default)"
47
  exec /one-api
 
1
  #!/bin/sh
2
 
 
3
  APP_DATA_DIR="/tmp/data"
4
 
5
  echo "Entrypoint wrapper: Attempting to create necessary directories in ephemeral FS..."
6
 
7
+ # 创建临时目录
8
+ mkdir -p "$APP_DATA_DIR/logs"
9
+ chmod 777 "$APP_DATA_DIR" "$APP_DATA_DIR/logs"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
+ # 尝试修改/data目录权限
12
+ echo "Attempting to fix /data permissions..."
13
+ chmod 777 /data 2>/dev/null || echo "Cannot change /data permissions"
14
+ mkdir -p /data/logs 2>/dev/null || echo "Cannot create /data/logs"
15
+ chmod 777 /data/logs 2>/dev/null || echo "Cannot change /data/logs permissions"
 
16
 
17
+ # 设置环境变量
 
 
 
 
 
 
18
  export DATA_DIR="$APP_DATA_DIR"
19
  export LOG_DIR="$APP_DATA_DIR/logs"
20
 
21
+ echo "Entrypoint wrapper: Starting application"
22
  exec /one-api