修复系统配置文件同步并补充打包校验

This commit is contained in:
huaxin
2026-11-27 00:24:48 -08:00
parent 6e51cbd82b
commit 07c25024b9
4 changed files with 52 additions and 3 deletions
+3
View File
@@ -1,2 +1,5 @@
#!/bin/bash
set -euo pipefail
./sync.sh
./compress_and_upload_files.sh
+44 -2
View File
@@ -3,10 +3,10 @@
# 压缩并上传files目录到七牛云
# 需要环境变量: QINIU_ACCESS_KEY, QINIU_SECRET_KEY
set -e
set -euo pipefail
# 检查环境变量
if [[ -z "$QINIU_ACCESS_KEY" ]] || [[ -z "$QINIU_SECRET_KEY" ]]; then
if [[ -z "${QINIU_ACCESS_KEY:-}" ]] || [[ -z "${QINIU_SECRET_KEY:-}" ]]; then
echo "错误: 请设置环境变量 QINIU_ACCESS_KEY 和 QINIU_SECRET_KEY"
exit 1
fi
@@ -17,6 +17,48 @@ if [[ ! -d "files" ]]; then
exit 1
fi
# 打包前静态校验: 解析 playbooks/site.yml 中所有未注释的 ../files/... 引用并确认本地存在
PLAYBOOK_PATH="playbooks/site.yml"
if [[ ! -f "$PLAYBOOK_PATH" ]]; then
echo "错误: $PLAYBOOK_PATH 不存在"
exit 1
fi
echo "正在校验 $PLAYBOOK_PATH 引用的本地文件完整性..."
REFERENCED_FILES=()
while IFS= read -r ref_path; do
if [[ -n "$ref_path" ]]; then
REFERENCED_FILES+=("$ref_path")
fi
done < <(sed 's/#.*$//' "$PLAYBOOK_PATH" | grep -Eo '\.\./files/[^[:space:]"'\'']+' | sed 's|^\.\./||' | sort -u)
if [[ ${#REFERENCED_FILES[@]} -eq 0 ]]; then
echo "错误: 未能从 $PLAYBOOK_PATH 解析出任何 ../files/ 引用"
exit 1
fi
MISSING_FILES=()
for rel_path in "${REFERENCED_FILES[@]}"; do
if [[ "$rel_path" == */ ]]; then
if [[ ! -d "$rel_path" ]]; then
MISSING_FILES+=("$rel_path")
fi
else
if [[ ! -e "$rel_path" ]]; then
MISSING_FILES+=("$rel_path")
fi
fi
done
if [[ ${#MISSING_FILES[@]} -gt 0 ]]; then
echo "错误: 以下被 $PLAYBOOK_PATH 引用的文件或目录在本地缺失,已中止打包上传:"
for missing in "${MISSING_FILES[@]}"; do
echo " - $missing"
done
exit 1
fi
echo "校验通过: 已确认 ${#REFERENCED_FILES[@]} 处 $PLAYBOOK_PATH 活跃引用文件均存在。"
# 生成带时间戳的文件名
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
ARCHIVE_NAME="files_${TIMESTAMP}.tar.xz"
+1 -1
View File
@@ -1 +1 @@
http://xplayer-ota.pureroad.cn/files_20261126_170113.tar.xz
http://xplayer-ota.pureroad.cn/files_20261127_002252.tar.xz
+4
View File
@@ -1,3 +1,6 @@
#!/bin/bash
set -euo pipefail
mkdir -p files
rsync am60-ts:/etc/ssh/sshd_config files/sshd_config
rsync am60-ts:/root/.ssh/authorized_keys files/authorized_keys
@@ -14,6 +17,7 @@ rsync am60-ts:/usr/local/bin/server files/server
rsync am60-ts:/usr/bin/ota files/ota
rsync -avz am60-ts:/etc/apt/sources.list.d ./files/
rsync am60-ts:/etc/modprobe.d/snd-aloop.conf files/snd-aloop.conf
rsync -avz am60-ts:/etc/modprobe.d/99-snd-usb-audio-index.conf ./files/99-snd-usb-audio-index.conf
rsync am60-ts:/etc/systemd/system/camilladsp.service files/camilladsp.service
rsync am60-ts:/usr/lib/systemd/system/bluetooth.service files/bluetooth.service
rsync am60-ts:/etc/udev/rules.d/99-usb-auto-mount.rules files/99-usb-auto-mount.rules