2024-03-30 09:49:09 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
2024-03-30 10:21:42 +08:00
|
|
|
mkdir -p /tmp/upload/backup/
|
2024-03-30 10:08:12 +08:00
|
|
|
|
|
|
|
# 检查backup.tar.gz文件是否存在
|
2024-03-30 10:21:42 +08:00
|
|
|
if [ -f /tmp/upload/backup.tar.gz ]; then
|
|
|
|
tar -xzvf /tmp/upload/backup.tar.gz -C /tmp/upload/backup
|
|
|
|
cd /tmp/upload/backup
|
2024-03-30 10:08:12 +08:00
|
|
|
# 恢复软件源
|
|
|
|
cp distfeeds.conf /etc/opkg/distfeeds.conf
|
|
|
|
# 恢复已安装列表
|
|
|
|
opkg update
|
|
|
|
cat packages-list.txt | cut -f 1 -d ' ' | xargs opkg install
|
|
|
|
# 恢复/overlay 配置
|
|
|
|
tar -xzvf overlay_backup.tar.gz -C /
|
|
|
|
# 恢复/etc 配置
|
|
|
|
tar -xzvf etc_backup.tar.gz -C /
|
|
|
|
|
2024-03-30 10:21:42 +08:00
|
|
|
# 恢复已完成,询问用户是否重启
|
|
|
|
echo "恢复已完成, 是否重启 (y/n)?"
|
|
|
|
read answer
|
|
|
|
if [ "$answer" = "y" ]; then
|
|
|
|
reboot
|
|
|
|
else
|
|
|
|
echo "重启已取消,手动重启以应用所有更改。"
|
|
|
|
fi
|
2024-03-30 10:08:12 +08:00
|
|
|
else
|
|
|
|
# 如果文件不存在,提醒用户并退出脚本
|
2024-03-30 10:21:42 +08:00
|
|
|
echo "请将恢复文档backup.tar.gz 上传到 /tmp/upload 目录 再重试。"
|
2024-03-30 10:08:12 +08:00
|
|
|
exit 1
|
|
|
|
fi
|