Compare commits
100 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f0efcff07f | |||
| 7280e186dd | |||
| f8d3ba4327 | |||
| 251d8795ea | |||
| 33cfff35b7 | |||
| 5e5aac70fa | |||
| ed79033f44 | |||
| c87fa90e62 | |||
| 9377f60b7d | |||
| 8c2e8d5e08 | |||
| b56434f44e | |||
| ddef5769ee | |||
| 6dd30696b4 | |||
| f89cb7e93b | |||
| 28b7cb428b | |||
| e6057713f9 | |||
| 855c2c0a2d | |||
| af5ab1f3bd | |||
| 5672ff56d2 | |||
| 817c79b149 | |||
| 2d035374fb | |||
| 4940f479a1 | |||
| 81e5b3cb32 | |||
| e60d9d2a70 | |||
| 9e80909bef | |||
| 49406fd2d4 | |||
| 37ccae4552 | |||
| 453c9fb7e2 | |||
| 601d06c1a2 | |||
| ea28dc87ba | |||
| 834f8f4e40 | |||
| 784ccbead8 | |||
| 88a3719a16 | |||
| 9a588bbaaf | |||
| f1365c1967 | |||
| e23b7d2a8a | |||
| e590805570 | |||
| f64775dd68 | |||
| 88d844e364 | |||
| b48b4fc330 | |||
| 25221d9178 | |||
| d91a1fd564 | |||
| 4b5d2e7f70 | |||
| 0c8e7639ca | |||
| 633f20cb76 | |||
| 645250fac6 | |||
| 6433f98d88 | |||
| 398d8ef10f | |||
| d7d5527136 | |||
| 46c91b2801 | |||
| 55338e4218 | |||
| 6fc1b69af5 | |||
| a407b847f6 | |||
| a3a630b984 | |||
| 29cba7893a | |||
| e6c51c0c51 | |||
| 1c4455242b | |||
| d54e836c4e | |||
| eb5662a0c7 | |||
| 02e0a85660 | |||
| 56528fce84 | |||
| d84a19895e | |||
| 67bb65e602 | |||
| a28cb8a0a6 | |||
| ff701ea66f | |||
| e0e7b54a02 | |||
| 7815c001fd | |||
| c7f6e86633 | |||
| ad29ff030e | |||
| 657ffbe822 | |||
| 08231e4243 | |||
| 0182af3aba | |||
| 63fe68f905 | |||
| 1dda690b59 | |||
| 91d0437e8c | |||
| a1ee28b1e1 | |||
| 89628f7d5b | |||
| a117c1028e | |||
| 4fddd2d0a4 | |||
| 902eea04bc | |||
| 4d1817cab4 | |||
| f88908c55a | |||
| dd5774a8cb | |||
| 1259b9c760 | |||
| 4b785c968a | |||
| c8c2b1e815 | |||
| 8ced2eeb78 | |||
| b133457457 | |||
| 2b9542745b | |||
| 8bf0caa601 | |||
| dfc49e2337 | |||
| 5b6b3d18d5 | |||
| 80332769b6 | |||
| a20e21234b | |||
| 9ee41a9591 | |||
| 27706b2893 | |||
| ee195d0126 | |||
| fe49b8427d | |||
| 83dc1b4e6e | |||
| 815993e68c |
260
emmc_backup_from_sd.sh
Normal file
260
emmc_backup_from_sd.sh
Normal file
@ -0,0 +1,260 @@
|
||||
#!/bin/bash
|
||||
#===============================================================================
|
||||
# 从SD卡操作eMMC备份脚本
|
||||
#===============================================================================
|
||||
|
||||
set -e
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
error_msg() { echo -e "${RED}[ERROR] $1${NC}" >&2; exit 1; }
|
||||
info_msg() { echo -e "${GREEN}[INFO] $1${NC}"; }
|
||||
warn_msg() { echo -e "${YELLOW}[WARN] $1${NC}"; }
|
||||
|
||||
[[ $EUID -eq 0 ]] || error_msg "需要root权限"
|
||||
|
||||
EMMC_DEV="/dev/mmcblk0"
|
||||
USB_DIR="/mnt/XIN_USB/rock5c"
|
||||
OUTPUT_FILE="${USB_DIR}/rock5c_emmc_$(date +%Y%m%d_%H%M%S).img"
|
||||
|
||||
info_msg "从SD卡备份eMMC (智能压缩版)..."
|
||||
info_msg "eMMC设备: ${EMMC_DEV}"
|
||||
info_msg "输出到: ${OUTPUT_FILE}"
|
||||
|
||||
# 获取原始eMMC大小
|
||||
ORIGINAL_SIZE=$(blockdev --getsize64 ${EMMC_DEV})
|
||||
ORIGINAL_SIZE_GB=$((ORIGINAL_SIZE / 1073741824))
|
||||
info_msg "原始eMMC大小: ${ORIGINAL_SIZE_GB}GB"
|
||||
|
||||
# 检查设备
|
||||
[[ -b "${EMMC_DEV}" ]] || error_msg "eMMC设备不存在: ${EMMC_DEV}"
|
||||
[[ -d "${USB_DIR}" ]] || error_msg "USB目录不存在: ${USB_DIR}"
|
||||
|
||||
# 检查eMMC没有被挂载
|
||||
if mount | grep -q mmcblk0; then
|
||||
error_msg "eMMC还在使用中!请确保从SD卡启动"
|
||||
fi
|
||||
|
||||
info_msg "✅ eMMC设备可安全操作"
|
||||
|
||||
# 步骤1: 检查eMMC分区信息
|
||||
info_msg "步骤1: 分析eMMC分区..."
|
||||
parted -s ${EMMC_DEV} unit MB print
|
||||
|
||||
# 检查eMMC上的数据大小
|
||||
info_msg "检查eMMC数据使用量..."
|
||||
TEMP_MOUNT="/tmp/check_emmc"
|
||||
mkdir -p "${TEMP_MOUNT}"
|
||||
|
||||
# 检查分区是否存在
|
||||
[[ -b "${EMMC_DEV}p1" ]] || error_msg "未找到boot分区 ${EMMC_DEV}p1"
|
||||
[[ -b "${EMMC_DEV}p2" ]] || error_msg "未找到root分区 ${EMMC_DEV}p2"
|
||||
|
||||
# 临时挂载检查使用量
|
||||
mount ${EMMC_DEV}p1 "${TEMP_MOUNT}" -o ro
|
||||
EMMC_BOOT_USED=$(df --block-size=1M "${TEMP_MOUNT}" | tail -1 | awk '{print $3}')
|
||||
umount "${TEMP_MOUNT}"
|
||||
|
||||
mount ${EMMC_DEV}p2 "${TEMP_MOUNT}" -o ro
|
||||
EMMC_ROOT_USED=$(df --block-size=1M "${TEMP_MOUNT}" | tail -1 | awk '{print $3}')
|
||||
umount "${TEMP_MOUNT}"
|
||||
|
||||
rm -rf "${TEMP_MOUNT}"
|
||||
|
||||
TOTAL_USED=$((EMMC_BOOT_USED + EMMC_ROOT_USED))
|
||||
info_msg "eMMC使用情况: Boot ${EMMC_BOOT_USED}MB + Root ${EMMC_ROOT_USED}MB = 总计 ${TOTAL_USED}MB"
|
||||
MIN_TARGET_SIZE=$((TOTAL_USED + 1024)) # 需要1GB额外空间
|
||||
info_msg "最小目标eMMC: ${MIN_TARGET_SIZE}MB (约$((MIN_TARGET_SIZE / 1024))GB)"
|
||||
|
||||
# 步骤2: 智能收缩eMMC分区
|
||||
info_msg "步骤2: 智能收缩eMMC分区..."
|
||||
|
||||
# 记录原始分区信息
|
||||
parted -s ${EMMC_DEV} unit s print > "${USB_DIR}/original_partition.txt"
|
||||
P1_START=$(parted -s ${EMMC_DEV} unit s print | grep "^ 1" | awk '{print $2}' | sed 's/s$//')
|
||||
P1_END=$(parted -s ${EMMC_DEV} unit s print | grep "^ 1" | awk '{print $3}' | sed 's/s$//')
|
||||
P2_START=$(parted -s ${EMMC_DEV} unit s print | grep "^ 2" | awk '{print $2}' | sed 's/s$//')
|
||||
ORIGINAL_P2_END=$(parted -s ${EMMC_DEV} unit s print | grep "^ 2" | awk '{print $3}' | sed 's/s$//')
|
||||
|
||||
info_msg "分区布局: P1=${P1_START}s-${P1_END}s, P2=${P2_START}s-${ORIGINAL_P2_END}s"
|
||||
|
||||
# 文件系统检查
|
||||
e2fsck -f -y ${EMMC_DEV}p2
|
||||
|
||||
# 先尝试收缩到最小值
|
||||
info_msg "计算文件系统最小大小..."
|
||||
resize2fs -M ${EMMC_DEV}p2 2>&1 | tee /tmp/resize.log
|
||||
|
||||
# 获取收缩后的实际大小
|
||||
FS_SIZE_BLOCKS=$(dumpe2fs -h ${EMMC_DEV}p2 2>/dev/null | grep "^Block count:" | awk '{print $3}')
|
||||
BLOCK_SIZE=$(dumpe2fs -h ${EMMC_DEV}p2 2>/dev/null | grep "^Block size:" | awk '{print $3}')
|
||||
|
||||
# 添加默认值防止空值
|
||||
[[ -z "$FS_SIZE_BLOCKS" ]] && FS_SIZE_BLOCKS=1048576 # 默认4GB worth of blocks
|
||||
[[ -z "$BLOCK_SIZE" ]] && BLOCK_SIZE=4096 # 默认4K
|
||||
|
||||
FS_SIZE_MB=$(( (FS_SIZE_BLOCKS * BLOCK_SIZE) / 1048576 ))
|
||||
|
||||
info_msg "文件系统最小大小: ${FS_SIZE_MB}MB"
|
||||
|
||||
# 添加缓冲空间确保系统能正常运行
|
||||
SHRINK_TARGET=$((FS_SIZE_MB + 512)) # 512MB缓冲
|
||||
resize2fs ${EMMC_DEV}p2 ${SHRINK_TARGET}M
|
||||
|
||||
# 计算新的分区结束位置(扇区)
|
||||
NEW_P2_END_SECTORS=$((P2_START + (SHRINK_TARGET * 1048576 / 512)))
|
||||
|
||||
# 重新创建收缩的分区
|
||||
parted -s ${EMMC_DEV} rm 2
|
||||
parted -s ${EMMC_DEV} unit s mkpart primary ext4 ${P2_START}s ${NEW_P2_END_SECTORS}s
|
||||
|
||||
partprobe ${EMMC_DEV}
|
||||
sleep 2
|
||||
|
||||
info_msg "✅ eMMC分区已收缩到 ${SHRINK_TARGET}MB"
|
||||
|
||||
# 步骤3: 创建备份信息文件
|
||||
info_msg "步骤3: 创建备份信息..."
|
||||
|
||||
cat > "${OUTPUT_FILE}.info" <<EOF
|
||||
#!/bin/bash
|
||||
# 备份信息文件 - 用于智能恢复
|
||||
BACKUP_DATE="$(date)"
|
||||
SOURCE_SIZE_GB=${ORIGINAL_SIZE_GB}
|
||||
DATA_USED_MB=${TOTAL_USED}
|
||||
MIN_TARGET_SIZE_MB=${MIN_TARGET_SIZE}
|
||||
|
||||
# 分区信息
|
||||
P1_START=${P1_START}
|
||||
P1_END=${P1_END}
|
||||
P2_START=${P2_START}
|
||||
P2_SHRUNK_END=${NEW_P2_END_SECTORS}
|
||||
ORIGINAL_P2_END=${ORIGINAL_P2_END}
|
||||
EOF
|
||||
|
||||
# 步骤4: 备份收缩后的eMMC
|
||||
info_msg "步骤4: 备份收缩后的eMMC..."
|
||||
# 确保包含完整的GPT备份表(通常在磁盘末尾)
|
||||
# GPT需要首尾各34个扇区,再加一些缓冲
|
||||
BACKUP_SIZE_SECTORS=$((NEW_P2_END_SECTORS + 34 + 2048)) # 34扇区GPT + 1MB额外缓冲
|
||||
BACKUP_SIZE_MB=$((BACKUP_SIZE_SECTORS * 512 / 1048576))
|
||||
|
||||
info_msg "备份大小: ${BACKUP_SIZE_MB}MB (原始: ${ORIGINAL_SIZE_GB}GB, 可恢复到: ≥${MIN_TARGET_SIZE}MB)"
|
||||
|
||||
dd if=${EMMC_DEV} of="${OUTPUT_FILE}" bs=512 count=${BACKUP_SIZE_SECTORS} status=progress
|
||||
|
||||
# 修复GPT备份表
|
||||
info_msg "修复备份镜像的GPT表..."
|
||||
sgdisk -e "${OUTPUT_FILE}" 2>/dev/null || true
|
||||
|
||||
info_msg "✅ eMMC备份完成"
|
||||
|
||||
# 步骤5: 恢复eMMC原始大小
|
||||
info_msg "步骤5: 恢复eMMC原始分区大小..."
|
||||
parted -s ${EMMC_DEV} rm 2
|
||||
parted -s ${EMMC_DEV} unit s mkpart primary ext4 ${P2_START}s ${ORIGINAL_P2_END}s
|
||||
|
||||
partprobe ${EMMC_DEV}
|
||||
sleep 2
|
||||
|
||||
resize2fs ${EMMC_DEV}p2
|
||||
|
||||
info_msg "✅ eMMC已恢复原始大小 ${ORIGINAL_SIZE_GB}GB"
|
||||
|
||||
# 验证备份镜像
|
||||
info_msg "步骤6: 验证备份镜像..."
|
||||
LOOP_DEV=$(losetup -P -f --show "${OUTPUT_FILE}")
|
||||
sleep 3
|
||||
|
||||
if [[ -b "${LOOP_DEV}p1" ]] && [[ -b "${LOOP_DEV}p2" ]]; then
|
||||
info_msg "✅ 备份镜像分区表完整"
|
||||
parted -s "${LOOP_DEV}" print
|
||||
|
||||
# 检查文件系统
|
||||
e2fsck -n "${LOOP_DEV}p1" && echo "✅ Boot分区文件系统正常"
|
||||
e2fsck -n "${LOOP_DEV}p2" && echo "✅ Root分区文件系统正常"
|
||||
else
|
||||
warn_msg "❌ 备份镜像分区表有问题"
|
||||
fi
|
||||
|
||||
losetup -d "${LOOP_DEV}"
|
||||
|
||||
FINAL_SIZE=$(du -h "${OUTPUT_FILE}" | cut -f1)
|
||||
FINAL_SIZE_ACTUAL=$(du --apparent-size -h "${OUTPUT_FILE}" | cut -f1)
|
||||
|
||||
# 创建智能恢复脚本
|
||||
RESTORE_SCRIPT="${USB_DIR}/restore_adaptive.sh"
|
||||
cat > "${RESTORE_SCRIPT}" <<'RESTORE_EOF'
|
||||
#!/bin/bash
|
||||
# 自适应恢复脚本 - 支持不同大小的eMMC
|
||||
|
||||
set -e
|
||||
IMAGE_FILE="$1"
|
||||
TARGET_DEV="/dev/mmcblk0"
|
||||
|
||||
[[ -f "${IMAGE_FILE}" ]] || { echo "用法: $0 <镜像文件>"; exit 1; }
|
||||
[[ -f "${IMAGE_FILE}.info" ]] || { echo "缺少信息文件"; exit 1; }
|
||||
|
||||
source "${IMAGE_FILE}.info"
|
||||
|
||||
echo "恢复镜像到eMMC"
|
||||
echo "目标设备: ${TARGET_DEV}"
|
||||
|
||||
TARGET_SIZE=$(blockdev --getsize64 ${TARGET_DEV})
|
||||
TARGET_SIZE_MB=$((TARGET_SIZE / 1048576))
|
||||
|
||||
echo "目标eMMC: $((TARGET_SIZE / 1073741824))GB"
|
||||
|
||||
if [[ ${TARGET_SIZE_MB} -lt ${MIN_TARGET_SIZE_MB} ]]; then
|
||||
echo "错误: 目标eMMC太小,需要至少 ${MIN_TARGET_SIZE_MB}MB"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "警告: 将清空 ${TARGET_DEV}!"
|
||||
read -p "继续? (yes): " confirm
|
||||
[[ "$confirm" == "yes" ]] || exit 1
|
||||
|
||||
echo "写入镜像..."
|
||||
dd if="${IMAGE_FILE}" of=${TARGET_DEV} bs=4M status=progress
|
||||
sync
|
||||
|
||||
partprobe ${TARGET_DEV}
|
||||
sleep 3
|
||||
|
||||
# 扩展分区到最大
|
||||
MAX_P2_END=$((TARGET_SIZE / 512 - 34))
|
||||
parted -s ${TARGET_DEV} rm 2
|
||||
parted -s ${TARGET_DEV} unit s mkpart primary ext4 ${P2_START}s ${MAX_P2_END}s
|
||||
partprobe ${TARGET_DEV}
|
||||
sleep 2
|
||||
|
||||
e2fsck -f -y ${TARGET_DEV}p2
|
||||
resize2fs ${TARGET_DEV}p2
|
||||
|
||||
echo "✅ 恢复完成! 分区已扩展到最大空间"
|
||||
RESTORE_EOF
|
||||
|
||||
chmod +x "${RESTORE_SCRIPT}"
|
||||
|
||||
info_msg "========================================="
|
||||
info_msg "🎉 智能eMMC备份成功完成!"
|
||||
info_msg "========================================="
|
||||
info_msg "📁 备份文件: ${OUTPUT_FILE}"
|
||||
info_msg "📏 备份大小: ${FINAL_SIZE}"
|
||||
info_msg "📄 信息文件: ${OUTPUT_FILE}.info"
|
||||
info_msg "🔧 恢复脚本: ${RESTORE_SCRIPT}"
|
||||
info_msg ""
|
||||
info_msg "源eMMC: ${ORIGINAL_SIZE_GB}GB"
|
||||
info_msg "数据使用: ${TOTAL_USED}MB"
|
||||
info_msg "最小目标: ${MIN_TARGET_SIZE}MB (约$((MIN_TARGET_SIZE / 1024))GB)"
|
||||
info_msg ""
|
||||
info_msg "🚀 恢复方法:"
|
||||
info_msg " 1. 从SD卡启动目标设备"
|
||||
info_msg " 2. 运行: bash ${RESTORE_SCRIPT} ${OUTPUT_FILE}"
|
||||
info_msg ""
|
||||
info_msg "✅ 支持恢复到任意大小eMMC (≥${MIN_TARGET_SIZE}MB)"
|
||||
info_msg "✅ 自动扩展分区到最大可用空间"
|
||||
info_msg "✅ 保持双分区结构不变"
|
||||
info_msg "========================================="
|
||||
@ -1 +1 @@
|
||||
http://xplayer-ota.pureroad.cn/files_20250812_171236.tar.xz
|
||||
http://xplayer-ota.pureroad.cn/files_20251203_232832.tar.xz
|
||||
|
||||
@ -2,7 +2,76 @@
|
||||
hosts: localhost
|
||||
become: yes
|
||||
|
||||
vars:
|
||||
packages: "bluez \
|
||||
mpc \
|
||||
libasound2-dev \
|
||||
libudev-dev \
|
||||
libfmt-dev \
|
||||
libfmt9 \
|
||||
libchromaprint1 \
|
||||
libupnp17 \
|
||||
libnfs14 \
|
||||
libavutil58 \
|
||||
libavformat60 \
|
||||
libavcodec60 \
|
||||
libcdio-paranoia2 \
|
||||
libcdio-cdda2 \
|
||||
libcdio19 \
|
||||
libmms0 \
|
||||
libsoxr0 \
|
||||
libid3tag0 \
|
||||
libiso9660-11 \
|
||||
libzzip-0-13 \
|
||||
libao4 \
|
||||
libjack-jackd2-0 \
|
||||
libpipewire-0.3-0 \
|
||||
libpulse0 \
|
||||
libshout3 \
|
||||
libsndio7.0 \
|
||||
libopenal1 \
|
||||
libavahi-common3 \
|
||||
libavahi-client3 \
|
||||
libadplug-2.3.3-0 \
|
||||
libflac12 \
|
||||
libfluidsynth3 \
|
||||
libaudiofile1 \
|
||||
libfaad2 \
|
||||
libgme0 \
|
||||
libmad0 \
|
||||
libmikmod3 \
|
||||
libmodplug1 \
|
||||
libmpcdec6 \
|
||||
libmpg123-0 \
|
||||
libopus0 \
|
||||
libsndfile1 \
|
||||
libogg0 \
|
||||
libvorbis0a \
|
||||
libwavpack1 \
|
||||
libwildmidi2 \
|
||||
libvorbisenc2 \
|
||||
libmp3lame0 \
|
||||
libtwolame0 \
|
||||
libshine3 \
|
||||
net-tools \
|
||||
libconfig9 \
|
||||
avahi-daemon
|
||||
libdbus-1-3 \
|
||||
libglib2.0-0 \
|
||||
libbluetooth3 \
|
||||
libsbc1 \
|
||||
libfdk-aac2 \
|
||||
libldacbt-abr2 \
|
||||
libldacbt-enc2 \
|
||||
aria2 \
|
||||
cloud-guest-utils"
|
||||
|
||||
tasks:
|
||||
- name: update script
|
||||
shell:
|
||||
cmd: |
|
||||
/usr/bin/install_bluealsa_openaptx.sh
|
||||
ignore_errors: yes
|
||||
|
||||
- name: switch mirror
|
||||
copy:
|
||||
@ -11,73 +80,73 @@
|
||||
mode: '0644'
|
||||
tags: apt
|
||||
|
||||
- name: Update apt cache
|
||||
- name: check missing packages
|
||||
shell:
|
||||
cmd: apt update -y
|
||||
cmd: |
|
||||
MISSING=""
|
||||
for pkg in {{ packages }}; do
|
||||
# 先检查原包名
|
||||
if dpkg-query -W -f='${Status}' "$pkg" 2>/dev/null | grep -q "install ok installed"; then
|
||||
continue
|
||||
# 如果原包名不存在,尝试检查带 t64 后缀的版本
|
||||
elif dpkg-query -W -f='${Status}' "${pkg}t64" 2>/dev/null | grep -q "install ok installed"; then
|
||||
continue
|
||||
else
|
||||
MISSING="yes"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -n "$MISSING" ]; then
|
||||
echo "missing"
|
||||
else
|
||||
echo "all_installed"
|
||||
fi
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: package_check
|
||||
changed_when: false
|
||||
ignore_errors: yes
|
||||
tags: apt
|
||||
|
||||
- name: update apt cache
|
||||
shell:
|
||||
cmd: |
|
||||
if command -v apt-fast &> /dev/null; then
|
||||
apt-fast update -y || apt-get update -y
|
||||
else
|
||||
apt-get update -y
|
||||
fi
|
||||
when: package_check.stdout == "missing"
|
||||
ignore_errors: yes
|
||||
tags: apt
|
||||
|
||||
- name: install dependencies
|
||||
apt:
|
||||
name:
|
||||
- bluez
|
||||
- mpc
|
||||
- libasound2-dev
|
||||
- libudev-dev
|
||||
- libfmt-dev
|
||||
- libfmt9
|
||||
- libchromaprint1
|
||||
- libupnp17
|
||||
- libnfs14
|
||||
- libavutil58
|
||||
- libavformat60
|
||||
- libavcodec60
|
||||
- libcdio-paranoia2
|
||||
- libcdio-cdda2
|
||||
- libcdio19
|
||||
- libmms0
|
||||
- libsoxr0
|
||||
- libid3tag0
|
||||
- libiso9660-11
|
||||
- libzzip-0-13
|
||||
- libao4
|
||||
- libjack-jackd2-0
|
||||
- libpipewire-0.3-0
|
||||
- libpulse0
|
||||
- libshout3
|
||||
- libsndio7.0
|
||||
- libopenal1
|
||||
- libavahi-common3
|
||||
- libavahi-client3
|
||||
- libadplug-2.3.3-0
|
||||
- libflac12
|
||||
- libfluidsynth3
|
||||
- libaudiofile1
|
||||
- libfaad2
|
||||
- libgme0
|
||||
- libmad0
|
||||
- libmikmod3
|
||||
- libmodplug1
|
||||
- libmpcdec6
|
||||
- libmpg123-0
|
||||
- libopus0
|
||||
- libsndfile1
|
||||
- libogg0
|
||||
- libvorbis0a
|
||||
- libwavpack1
|
||||
- libwildmidi2
|
||||
- libvorbisenc2
|
||||
- libmp3lame0
|
||||
- libtwolame0
|
||||
- libshine3
|
||||
- libmp3lame0
|
||||
- libtwolame0
|
||||
- net-tools
|
||||
- libconfig9
|
||||
- avahi-daemon
|
||||
# - upmpdcli
|
||||
state: present
|
||||
become: yes
|
||||
shell:
|
||||
cmd: |
|
||||
if command -v apt-fast &> /dev/null; then
|
||||
apt-fast install -y {{ packages }} || apt-get install -y {{ packages }}
|
||||
else
|
||||
apt-get install -y {{ packages }}
|
||||
fi
|
||||
when: package_check.stdout == "missing"
|
||||
ignore_errors: yes
|
||||
tags: apt
|
||||
|
||||
- name: Create directories
|
||||
file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
mode: "{{ item.mode | default('0755') }}"
|
||||
recurse: yes
|
||||
loop:
|
||||
- path: /var/lib/mpd/playlists
|
||||
- path: /var/lib/mpd/music
|
||||
- path: /usr/local/lib/systemd/system
|
||||
- path: /srv/login
|
||||
- path: /usr/var/lib/bluealsa
|
||||
- path: /srv/bluez-alsa
|
||||
|
||||
|
||||
- name: Copy static files
|
||||
copy:
|
||||
src: "{{ item.src }}"
|
||||
@ -86,8 +155,8 @@
|
||||
loop:
|
||||
- src: ../files/modules
|
||||
dest: /etc/modules
|
||||
- src: ../files/login
|
||||
dest: /srv/
|
||||
- src: ../files/login/
|
||||
dest: /srv/login/
|
||||
- src: ../files/sshd_config
|
||||
dest: /etc/ssh/sshd_config
|
||||
mode: '0600'
|
||||
@ -108,16 +177,18 @@
|
||||
- src: ../files/cpufrequtils
|
||||
dest: /etc/default/cpufrequtils
|
||||
mode: '0644'
|
||||
|
||||
- name: Create directories
|
||||
file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
mode: "{{ item.mode | default('0755') }}"
|
||||
loop:
|
||||
- path: /var/lib/mpd/playlists
|
||||
- path: /var/lib/mpd/music
|
||||
- path: /usr/local/lib/systemd/system
|
||||
- src: ../files/led-startup.sh
|
||||
dest: /usr/bin/led-startup.sh
|
||||
mode: '0755'
|
||||
- src: ../files/xplayer-start.sh
|
||||
dest: /usr/local/bin/xplayer-start.sh
|
||||
mode: '0755'
|
||||
- src: ../files/apt-fast
|
||||
dest: /usr/local/bin/apt-fast
|
||||
mode: '0755'
|
||||
- src: ../files/apt-fast.conf
|
||||
dest: /etc/apt-fast.conf
|
||||
mode: '0644'
|
||||
|
||||
- name: update mpd data
|
||||
copy:
|
||||
@ -164,6 +235,29 @@
|
||||
register: copy_result
|
||||
changed_when: copy_result.changed or (force_update | default(false) | bool)
|
||||
|
||||
- name: update bluealsa
|
||||
copy:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: "{{ item.mode | default('0644') }}"
|
||||
loop:
|
||||
- src: ../files/bluealsa.service
|
||||
dest: /etc/systemd/system/bluealsa.service
|
||||
- src: ../files/install_bluealsa_openaptx.sh
|
||||
dest: /usr/bin/install_bluealsa_openaptx.sh
|
||||
mode: '0755'
|
||||
- src: ../files/bluealsa_bundle.tar.gz
|
||||
dest: /srv/bluez-alsa/bluealsa_bundle.tar.gz
|
||||
tags: bluealsa
|
||||
notify:
|
||||
- install_bluealsa_openaptx
|
||||
- reload_systemd
|
||||
- enable_bluealsa
|
||||
- stop_bluealsa
|
||||
- start_bluealsa
|
||||
register: copy_result
|
||||
changed_when: copy_result.changed or (force_update | default(false) | bool)
|
||||
|
||||
- name: update camilladsp
|
||||
copy:
|
||||
src: "{{ item.src }}"
|
||||
@ -205,6 +299,7 @@
|
||||
mode: '0755'
|
||||
- src: ../files/99-usb-auto-mount.rules
|
||||
dest: /etc/udev/rules.d/99-usb-auto-mount.rules
|
||||
|
||||
mode: '0644'
|
||||
tags: usb
|
||||
notify:
|
||||
@ -373,6 +468,23 @@
|
||||
shell:
|
||||
cmd: systemctl restart sing-box
|
||||
|
||||
- name: install_bluealsa_openaptx
|
||||
shell:
|
||||
cmd: /usr/bin/install_bluealsa_openaptx.sh
|
||||
|
||||
- name: enable_bluealsa
|
||||
shell:
|
||||
cmd: systemctl enable bluealsa
|
||||
- name: stop_bluealsa
|
||||
shell:
|
||||
cmd: systemctl stop bluealsa
|
||||
- name: start_bluealsa
|
||||
shell:
|
||||
cmd: systemctl start bluealsa
|
||||
- name: restart_bluealsa
|
||||
shell:
|
||||
cmd: systemctl restart bluealsa
|
||||
|
||||
- name: enable_xplayer_server
|
||||
shell:
|
||||
cmd: systemctl enable xplayer-server
|
||||
@ -387,6 +499,7 @@
|
||||
|
||||
- name: reboot_required
|
||||
shell:
|
||||
cmd: echo "need reboot"
|
||||
cmd: sync && reboot
|
||||
|
||||
|
||||
|
||||
|
||||
75
sync.sh
75
sync.sh
@ -1,34 +1,45 @@
|
||||
mkdir -p files
|
||||
rsync am60:/etc/ssh/sshd_config files/sshd_config
|
||||
rsync am60:/root/.ssh/authorized_keys files/authorized_keys
|
||||
rsync am60:/etc/asound.conf files/asound.conf
|
||||
rsync am60:/usr/local/bin/camilladsp files/camilladsp
|
||||
rsync am60:/etc/camilladsp.yml files/camilladsp.yml
|
||||
# rsync -avz am60:/root/camilladsp-conf files/
|
||||
rsync am60:/usr/local/lib/systemd/system/mpd.socket files/mpd.socket
|
||||
rsync am60:/usr/local/lib/systemd/system/mpd.service files/mpd.service
|
||||
rsync am60:/usr/local/bin/mpd files/mpd
|
||||
rsync am60:/etc/mpd.conf files/mpd.conf
|
||||
rsync am60:/etc/systemd/system/xplayer-server.service files/xplayer-server.service
|
||||
rsync am60:/usr/local/bin/server files/server
|
||||
rsync am60:/usr/bin/ota files/ota
|
||||
rsync -avz am60:/etc/apt/sources.list.d ./files/
|
||||
rsync am60:/etc/modules files/modules
|
||||
rsync am60:/etc/modprobe.d/snd-aloop.conf files/snd-aloop.conf
|
||||
rsync am60:/etc/systemd/system/camilladsp.service files/camilladsp.service
|
||||
rsync am60:/usr/lib/systemd/system/bluetooth.service files/bluetooth.service
|
||||
rsync am60:/etc/udev/rules.d/99-usb-auto-mount.rules files/99-usb-auto-mount.rules
|
||||
rsync am60:/usr/local/bin/usb-mount.sh files/usb-mount.sh
|
||||
rsync am60:/etc/custom_service/start_service.sh files/start_service.sh
|
||||
rsync am60:/etc/bluetooth/input.conf files/input.conf
|
||||
rsync am60:/etc/bluetooth/main.conf files/main.conf
|
||||
rsync am60:/etc/default/cpufrequtils files/cpufrequtils
|
||||
rsync am60:/usr/lib/systemd/system/shairport-sync.service files/shairport-sync.service
|
||||
rsync am60:/usr/local/bin/shairport-sync files/shairport-sync
|
||||
rsync am60:/etc/shairport-sync.conf files/shairport-sync.conf
|
||||
rsync am60:/usr/bin/shairport_monitor.sh files/shairport_monitor.sh
|
||||
rsync am60:/etc/upmpdcli.conf files/upmpdcli.conf
|
||||
rsync am60:/usr/bin/sing-box files/sing-box
|
||||
rsync am60:/etc/systemd/system/sing-box.service files/sing-box.service
|
||||
rsync -avz am60:/srv/login files/
|
||||
rsync 5c:/etc/ssh/sshd_config files/sshd_config
|
||||
rsync 5c:/root/.ssh/authorized_keys files/authorized_keys
|
||||
rsync 5c:/etc/asound.conf files/asound.conf
|
||||
rsync 5c:/usr/local/bin/camilladsp files/camilladsp
|
||||
rsync 5c:/etc/camilladsp.yml files/camilladsp.yml
|
||||
# rsync -avz 5c:/root/camilladsp-conf files/
|
||||
rsync 5c:/usr/local/lib/systemd/system/mpd.socket files/mpd.socket
|
||||
rsync 5c:/usr/local/lib/systemd/system/mpd.service files/mpd.service
|
||||
rsync 5c:/usr/local/bin/mpd files/mpd
|
||||
rsync 5c:/etc/mpd.conf files/mpd.conf
|
||||
rsync 5c:/etc/systemd/system/xplayer-server.service files/xplayer-server.service
|
||||
rsync 5c:/usr/local/bin/server files/server
|
||||
rsync 5c:/usr/bin/ota files/ota
|
||||
rsync -avz 5c:/etc/apt/sources.list.d ./files/
|
||||
rsync 5c:/etc/modules files/modules
|
||||
rsync 5c:/etc/modprobe.d/snd-aloop.conf files/snd-aloop.conf
|
||||
rsync 5c:/etc/systemd/system/camilladsp.service files/camilladsp.service
|
||||
rsync 5c:/usr/lib/systemd/system/bluetooth.service files/bluetooth.service
|
||||
rsync 5c:/etc/udev/rules.d/99-usb-auto-mount.rules files/99-usb-auto-mount.rules
|
||||
rsync 5c:/usr/local/bin/usb-mount.sh files/usb-mount.sh
|
||||
rsync 5c:/etc/custom_service/start_service.sh files/start_service.sh
|
||||
rsync 5c:/etc/bluetooth/input.conf files/input.conf
|
||||
rsync 5c:/etc/bluetooth/main.conf files/main.conf
|
||||
rsync 5c:/etc/default/cpufrequtils files/cpufrequtils
|
||||
rsync 5c:/usr/lib/systemd/system/shairport-sync.service files/shairport-sync.service
|
||||
rsync 5c:/usr/local/bin/shairport-sync files/shairport-sync
|
||||
rsync 5c:/etc/shairport-sync.conf files/shairport-sync.conf
|
||||
rsync 5c:/usr/bin/shairport_monitor.sh files/shairport_monitor.sh
|
||||
# rsync 5c:/etc/upmpdcli.conf files/upmpdcli.conf
|
||||
rsync 5c:/usr/bin/sing-box files/sing-box
|
||||
rsync 5c:/etc/systemd/system/sing-box.service files/sing-box.service
|
||||
rsync -avz --exclude='login/' 5c:/srv/login/ files/login/
|
||||
rsync 5c:/usr/bin/led-startup.sh files/led-startup.sh
|
||||
rsync 5c:/usr/local/bin/xplayer-start.sh files/xplayer-start.sh
|
||||
rsync 5c:/usr/bin/install_bluealsa_openaptx.sh files/install_bluealsa_openaptx.sh
|
||||
rsync 5c:/etc/systemd/system/bluealsa.service files/bluealsa.service
|
||||
rsync 5c:/srv/bluez-alsa/bluealsa_bundle.tar.gz files/bluealsa_bundle.tar.gz
|
||||
rsync 5c:/usr/local/bin/apt-fast files/apt-fast
|
||||
rsync 5c:/etc/apt-fast.conf files/apt-fast.conf
|
||||
|
||||
# Clean up macOS resource fork files
|
||||
find files -name "._*" -type f -delete
|
||||
|
||||
echo "done"
|
||||
Loading…
x
Reference in New Issue
Block a user