-
Notifications
You must be signed in to change notification settings - Fork 5
/
findwin
60 lines (49 loc) · 1.29 KB
/
findwin
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
#!/bin/bash
find_loader()
{
TMPMOUNT=0
#check mountpoint
MOUNTPOINT=`mount|grep -w "$1"|awk '{print $3}'`
if [ -z "$MOUNTPOINT" ]; then #not mount, mounting in temp mountpoint
mkdir -p "/tmp/tmpmount"
mount -t "$2" "$1" "/tmp/tmpmount"
if [ $? -ne 0 ]; then
echo "$1 not mounted"
return
fi
MOUNTPOINT="/tmp/tmpmount"
TMPMOUNT=1
fi
#find loader
#bootmg - Win Vista and newer
FOUND=`find "$MOUNTPOINT" -maxdepth 1 -iname "bootmgr"`
if [ -n "$FOUND" ];then
echo "$1: found bootmgr (Windows Vista and newer)"
else
#ntldr - Win XP and older
FOUND=`find "$MOUNTPOINT" -maxdepth 1 -iname "ntldr"`
if [ -n "$FOUND" ];then
echo "$1: found ntldr (Windows XP and older)"
else
echo "$1: Windows loader not found"
fi
fi
if [ $TMPMOUNT -eq 1 ]; then
sleep 1
umount "/tmp/tmpmount"
fi
}
echo "Find Windows loaders..."
IFS=$'\n'
for DEVDATA in $(blkid); do
VOL=`echo "$DEVDATA" |sed -n 's/\(.*:\).* TYPE=\"\([^\"]*\)\".*/\1\2/p'`
VOLNAME=`echo "$VOL"|awk -F ":" '{print $1}'`
VOLFS=`echo "$VOL"|awk -F ":" '{print $2}'`
if [ -n "$VOLFS" ]; then
if [[ "$VOLFS" == "ntfs" || "$VOLFS" == "vfat" ]];then
find_loader $VOLNAME $VOLFS
else
echo "$VOLNAME not windows volume"
fi
fi
done