33 lines
817 B
Bash
33 lines
817 B
Bash
#!/usr/bin/env bash
|
||
# 去掉各目录 .env 的 Windows 换行符(解决 PM2 agent errored: $'\r': command not found)
|
||
set -euo pipefail
|
||
|
||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
REPO="$(cd "${SCRIPT_DIR}/../.." && pwd)"
|
||
|
||
dirs=(
|
||
"${REPO}/manual_trading_hub"
|
||
"${REPO}/crypto_monitor_binance"
|
||
"${REPO}/crypto_monitor_okx"
|
||
"${REPO}/crypto_monitor_gate"
|
||
"${REPO}/crypto_monitor_gate_bot"
|
||
)
|
||
|
||
fixed=0
|
||
for d in "${dirs[@]}"; do
|
||
f="${d}/.env"
|
||
if [[ ! -f "${f}" ]]; then
|
||
echo "跳过(无文件): ${f}"
|
||
continue
|
||
fi
|
||
if grep -q $'\r' "${f}" 2>/dev/null; then
|
||
sed -i 's/\r$//' "${f}"
|
||
echo "已修复 CRLF: ${f}"
|
||
fixed=$((fixed + 1))
|
||
else
|
||
echo "已是 LF: ${f}"
|
||
fi
|
||
done
|
||
|
||
echo "完成,共修复 ${fixed} 个 .env。请执行: pm2 restart ecosystem.config.cjs"
|