1 | #!/bin/bash␊ |
2 | ␊ |
3 | echo "==============================================="␊ |
4 | echo "CheckWindowsDiskSignature: Is Windows installed?"␊ |
5 | echo "************************************************"␊ |
6 | ␊ |
7 | # this script is passed the targetdisk to work from, for example /dev/disk0␊ |
8 | # It then checks the disk sector for a 4-byte Windows disk signature␊ |
9 | # if one is found then it exits with 1, otherwise it exits with 0␊ |
10 | ␊ |
11 | if [ "$#" -eq 1 ]; then␊ |
12 | ␉targetDisk="$1"␊ |
13 | ␉echo "DEBUG: passed argument for targetDisk = $targetDisk"␊ |
14 | else␊ |
15 | ␉echo "Error - wrong number of values passed - Exiting"␊ |
16 | ␉exit 9␊ |
17 | fi␊ |
18 | ␊ |
19 | disksignature=$( dd 2>/dev/null if="$targetDisk" count=1 | dd 2>/dev/null count=4 bs=1 skip=440 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )␊ |
20 | ␊ |
21 | echo "${disksignature}"␊ |
22 | ␊ |
23 | if [ "${disksignature}" = "00000000" ]; then␊ |
24 | ␉echo "No Windows installation detected."␊ |
25 | ␉echo "-----------------------------------------------"␊ |
26 | ␉echo ""␊ |
27 | ␉exit 0␊ |
28 | else␊ |
29 | ␉echo "Detected an existing Windows installation"␊ |
30 | ␉echo "-----------------------------------------------"␊ |
31 | ␉echo ""␊ |
32 | ␉exit 1␊ |
33 | fi␊ |
34 | ␊ |
35 | echo "-----------------------------------------------"␊ |
36 | echo ""␊ |
37 | ␊ |
38 | exit 0 |