-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmulti-device-verify.sh
57 lines (48 loc) · 1.72 KB
/
multi-device-verify.sh
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
#!/bin/bash
TARGET_DIR="/home/lede/bin/targets/ramips/mt7621/packages"
PACKAGES_FILE="$TARGET_DIR/Packages"
CONFIG_FILE="/home/lede/.config"
get_dir_hash() {
find "$TARGET_DIR" -type f -exec sha256sum {} \; | sha256sum | awk '{print $1}'
}
get_config_hash() {
sha256sum "$CONFIG_FILE" | awk '{print $1}'
}
get_kernel_version() {
grep "Depends: kernel" "$PACKAGES_FILE" | awk -F '[()]' '{if (!seen[$2]++) print $2}'
}
initial_dir_hash=$(get_dir_hash)
initial_kernel_version=$(get_kernel_version)
echo
echo "初始目录 hash 值: $initial_dir_hash"
echo "初始 kernel 版本: $initial_kernel_version"
initial_config_hash=$(get_config_hash)
echo "初始 .config 文件 hash 值: $initial_config_hash"
echo
while true; do
read -p "multi-device-verify: 按 [1] 继续检查,按 [2] 退出: " user_input
if [ "$user_input" == "2" ]; then
echo "multi-device-verify: 脚本结束!"
exit 0
elif [ "$user_input" == "1" ]; then
current_config_hash=$(get_config_hash)
current_dir_hash=$(get_dir_hash)
current_kernel_version=$(get_kernel_version)
if [ "$initial_dir_hash" != "$current_dir_hash" ] || [ "$initial_kernel_version" != "$current_kernel_version" ]; then
echo "multi-device-verify: 目录 hash 值或 kernel 版本发生变化,脚本结束"
exit 1
else
echo "multi-device-verify: 目录 hash 值和 kernel 版本一致,继续前进吧!"
fi
if [ "$initial_config_hash" != "$current_config_hash" ]; then
echo "multi-device-verify: .config 已修改,继续检查"
echo
initial_config_hash=$current_config_hash
else
echo "multi-device-verify: .config 文件未变化"
fi
echo
else
echo "无效输入,请输入 [1] 或 [2]。"
fi
done