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 | # Receives targetVolume: Volume to install to.␊ |
12 | # Receives scriptDir: The location of the main script dir.␊ |
13 | ␊ |
14 | if [ "$#" -eq 3 ]; then␊ |
15 | ␉targetDisk="$1"␊ |
16 | ␉targetVolume="$2"␊ |
17 | ␉scriptDir="$3"␊ |
18 | ␉echo "DEBUG: passed argument for targetDisk = $targetDisk"␊ |
19 | ␉echo "DEBUG: passed argument for targetVolume = $targetVolume"␊ |
20 | ␉echo "DEBUG: passed argument for scriptDir = $scriptDir"␊ |
21 | else␊ |
22 | ␉echo "Error - wrong number of values passed - Exiting"␊ |
23 | ␉exit 9␊ |
24 | fi␊ |
25 | ␊ |
26 | 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}' )␊ |
27 | ␊ |
28 | #echo "DEBUG: ${disksignature}"␊ |
29 | ␊ |
30 | if [ "${disksignature}" = "00000000" ]; then␊ |
31 | ␉#echo "DEBUG: No Windows installation detected."␊ |
32 | ␉exit 0␊ |
33 | else␊ |
34 | ␉#echo "DEBUG: Detected an existing Windows installation"␊ |
35 | ␉"$scriptDir"InstallLog.sh "${targetVolume}" "Detected a Windows installation on this volume."␊ |
36 | ␉exit 1␊ |
37 | fi␊ |
38 | ␊ |
39 | exit 0␊ |
40 | |