-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathget-xda.sh
More file actions
31 lines (25 loc) · 688 Bytes
/
get-xda.sh
File metadata and controls
31 lines (25 loc) · 688 Bytes
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
#!/bin/sh
# debian ubuntu redhat 安装模式共用此脚本
# alpine 未用到此脚本
get_all_disks() {
# shellcheck disable=SC2010
ls /sys/block/ | grep -Ev '^(loop|sr|nbd)'
}
get_xda() {
# 如果没找到 main_disk 或 xda
# 返回假的值,防止意外地格式化全部盘
eval "$(grep -o 'extra_main_disk=[^ ]*' /proc/cmdline | sed 's/^extra_//')"
if [ -z "$main_disk" ]; then
echo 'MAIN_DISK_NOT_FOUND'
return 1
fi
for disk in $(get_all_disks); do
if fdisk -l "/dev/$disk" | grep -iq "$main_disk"; then
echo "$disk"
return
fi
done
echo 'XDA_NOT_FOUND'
return 1
}
get_xda