Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/package/Scripts/Install/CheckWindowsDiskSignature.sh

  • Property svn:executable set to *
1#!/bin/bash
2
3echo "==============================================="
4echo "CheckWindowsDiskSignature: Is Windows installed?"
5echo "************************************************"
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
14if [ "$#" -eq 3 ]; then
15targetDisk="$1"
16targetVolume="$2"
17scriptDir="$3"
18echo "DEBUG: passed argument for targetDisk = $targetDisk"
19echo "DEBUG: passed argument for targetVolume = $targetVolume"
20echo "DEBUG: passed argument for scriptDir = $scriptDir"
21else
22echo "Error - wrong number of values passed - Exiting"
23exit 9
24fi
25
26disksignature=$( 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 "${disksignature}"
29
30if [ "${disksignature}" = "00000000" ]; then
31echo "No Windows installation detected."
32echo "-----------------------------------------------"
33echo ""
34exit 0
35else
36echo "Detected an existing Windows installation"
37echo "-----------------------------------------------"
38echo ""
39"$scriptDir"InstallLog.sh "${targetVolume}" "Detected a Windows installation on this volume."
40exit 1
41fi
42
43echo "-----------------------------------------------"
44echo ""
45
46exit 0

Archive Download this file

Revision: 1612