-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrestore.run
69 lines (61 loc) · 2.05 KB
/
restore.run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
# 定义颜色输出函数
red() { echo -e "\033[31m\033[01m[WARNING] $1\033[0m"; }
green() { echo -e "\033[32m\033[01m[INFO] $1\033[0m"; }
yellow() { echo -e "\033[33m\033[01m[NOTICE] $1\033[0m"; }
blue() { echo -e "\033[34m\033[01m[MESSAGE] $1\033[0m"; }
light_magenta() { echo -e "\033[95m\033[01m[NOTICE] $1\033[0m"; }
light_yellow() { echo -e "\033[93m\033[01m[NOTICE] $1\033[0m"; }
# 检查文件传输是否已安装
check_istoreos_style_installed() {
# 检查luci-app-filetransfer的一些关键文件是否存在
CHECK_FILES="/usr/lib/lua/luci/controller/filetransfer.lua
/usr/lib/lua/luci/view/filetransfer
/usr/lib/lua/luci/model/cbi/filetransfer"
# 设置一个标记,用来表示文件是否找到
FOUND=0
for FILE in $CHECK_FILES; do
if [ -e "$FILE" ]; then
FOUND=1
break
fi
done
if [ $FOUND -eq 1 ]; then
echo "luci-app-filetransfer is installed."
else
# 先恢复到一键iStoreOS风格化
wget -O /tmp/restore.sh https://github.com/tbdavid2019/openwrt-backup-full-script/raw/main/restore_origin.sh && sh /tmp/restore.sh
fi
}
# 恢复标准的iStoreOS
normal_restore() {
mkdir -p /tmp/upload/restore
# 查找符合模式的备份文件
BACKUP_FILE=$(ls /tmp/upload/*-iStorebk.tar.gz 2>/dev/null | head -n 1)
if [ -f "$BACKUP_FILE" ]; then
tar -xzvf "$BACKUP_FILE" -C /tmp/upload/restore
cd /tmp/upload/restore
# 恢复overlay
tar -xzvf overlay_backup.tar.gz -C /
green "恢复已完成, 系统正在重新啟動."
reboot
else
red "请将恢复文档(格式為日期-iStorebk.tar.gz)上傳到/tmp/upload 目錄再重试。"
exit 1
fi
}
restore() {
model_info=$(cat /tmp/sysinfo/model)
green "型号:$model_info"
case "$model_info" in
*2500* | *3000* | *6000*)
check_istoreos_style_installed
normal_restore
;;
*)
echo "Router name does not contain '3000', '6000', or '2500'."
normal_restore
;;
esac
}
restore