#!/bin/sh set -e CONFIG_FILE_PATH="/home/api.yaml" DB_PATH="/home/data/uniapi.db" echo "DEBUG: Entrypoint script started." # 检查配置方式 if [ -n "$API_YAML_CONTENT" ]; then # 从环境变量获取配置 echo "DEBUG: API_YAML_CONTENT secret found. Writing to file..." printf '%s\n' "$API_YAML_CONTENT" > "$CONFIG_FILE_PATH" if [ -f "$CONFIG_FILE_PATH" ]; then echo "DEBUG: Config file created successfully. Size: $(wc -c < "$CONFIG_FILE_PATH") bytes." else echo "ERROR: Config file was NOT created." exit 1 fi elif [ -n "$CONFIG_URL" ]; then # 从URL下载配置 echo "DEBUG: CONFIG_URL found. Downloading configuration..." curl -s -o "$CONFIG_FILE_PATH" "$CONFIG_URL" if [ -f "$CONFIG_FILE_PATH" ] && [ -s "$CONFIG_FILE_PATH" ]; then echo "DEBUG: Config file downloaded successfully." else echo "ERROR: Failed to download config file from URL." exit 1 fi else echo "ERROR: Neither API_YAML_CONTENT nor CONFIG_URL provided. Exiting." exit 1 fi # 确保数据目录存在 mkdir -p "$(dirname "$DB_PATH")" echo "DEBUG: Starting uni-api..." cd /home exec python main.py --config "$CONFIG_FILE_PATH" "$@"