Fix: 修复环境变量无法穿透的问题,导致crontab无法正确更新模组

This commit is contained in:
2025-07-24 23:54:22 +08:00
parent 7e15b3a84e
commit ee8a5840df
3 changed files with 22 additions and 2 deletions

View File

@@ -6,6 +6,11 @@
set -e
# 加载环境变量解决cron任务无法读取环境变量的问题
if [ -f "/etc/environment" ]; then
export $(cat /etc/environment | xargs)
fi
# 设置日志文件路径
LOG_FILE="/var/log/updatemod.log"
@@ -17,6 +22,9 @@ echo "==========================================" >> "$LOG_FILE"
# 检查环境变量
if [ -z "$STEAM_USERNAME" ] || [ -z "$STEAM_PASSWORD" ]; then
echo "错误: 请设置 STEAM_USERNAME 和 STEAM_PASSWORD 环境变量" >> "$LOG_FILE"
echo "当前环境变量状态:" >> "$LOG_FILE"
echo "STEAM_USERNAME: ${STEAM_USERNAME:-未设置}" >> "$LOG_FILE"
echo "STEAM_PASSWORD: ${STEAM_PASSWORD:-未设置}" >> "$LOG_FILE"
exit 1
fi