#!/usr/bin/env bash # 从服务器安全文件注入极光 Master Secret 到环境变量。 # 不打印文件内容、不写入仓库。供总工部署时 source,本卡不执行。 set -euo pipefail SECRET_FILE="${JPUSH_MASTER_SECRET_FILE:-/root/.config/jinxunda/jpush_master_secret}" if [ ! -f "$SECRET_FILE" ]; then echo "缺少极光 Master Secret 文件(已配置路径,不打印内容)" >&2 exit 1 fi perm=$(stat -c '%a' "$SECRET_FILE" 2>/dev/null || stat -f '%OLp' "$SECRET_FILE") if [ "$perm" != "600" ] && [ "$perm" != "400" ]; then echo "Master Secret 文件权限应为 600 或 400(当前 $perm)" >&2 exit 1 fi len=$(wc -c < "$SECRET_FILE" | tr -d ' ') if [ "$len" -lt 16 ] || [ "$len" -gt 64 ]; then echo "Master Secret 文件长度异常(不打印内容)" >&2 exit 1 fi JPUSH_MASTER_SECRET="$(tr -d '\n\r' < "$SECRET_FILE")" export JPUSH_MASTER_SECRET # 有意不 echo 该变量