1 | #!/bin/bash␊ |
2 | ␊ |
3 | echo "==============================================="␊ |
4 | echo "CheckWindowsDiskSignature: Is Windows installed?"␊ |
5 | echo "************************************************"␊ |
6 | ␊ |
7 | # Checks the disk sector for a 4-byte Windows disk signature␊ |
8 | # if one is found then it exits with 1, otherwise it exits with 0␊ |
9 | ␊ |
10 | # Receives targetdisk: for example, /dev/disk0␊ |
11 | ␊ |
12 | ␊ |
13 | if [ "$#" -eq 1 ]; then␊ |
14 | ␉targetDisk="$1"␊ |
15 | ␉echo "DEBUG: passed argument for targetDisk = $targetDisk"␊ |
16 | else␊ |
17 | ␉echo "Error - wrong number of values passed - Exiting"␊ |
18 | ␉exit 9␊ |
19 | fi␊ |
20 | ␊ |
21 | 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}' )␊ |
22 | ␊ |
23 | #echo "${disksignature}"␊ |
24 | ␊ |
25 | if [ "${disksignature}" = "00000000" ]; then␊ |
26 | ␉echo "No Windows installation detected."␊ |
27 | ␉echo "-----------------------------------------------"␊ |
28 | ␉echo ""␊ |
29 | ␉exit 0␊ |
30 | else␊ |
31 | ␉echo "Detected an existing Windows installation"␊ |
32 | ␉echo "-----------------------------------------------"␊ |
33 | ␉echo ""␊ |
34 | ␉exit 1␊ |
35 | fi␊ |
36 | ␊ |
37 | echo "-----------------------------------------------"␊ |
38 | echo ""␊ |
39 | ␊ |
40 | exit 0 |