Chameleon Applications

Chameleon Applications Svn Source Tree

Root/branches/blackosx/trunk/PackageBuilder/Main_Package_Elements/Scripts/CheckDiskMicrocodeType.sh

  • Property svn:executable set to *
1#!/bin/bash
2
3echo "==============================================="
4echo "Diskmicrocodetype:"
5echo "******************"
6
7# This script is passed the targetdisk
8# it then reads the MBR of the disk in the attempt to find the
9# signature for either the GRUB or Linux bootloaders.
10# The script returns 1 if either is found, or 0 if none found.
11
12if [ "$#" -eq 1 ]; then
13targetDisk="$1"
14echo "DEBUG: passed argument for targetDisk = $targetDisk"
15else
16echo "Error - wrong number of values passed"
17exit 9
18fi
19
20diskmicrocodetype[1]="GRUB,47525542"
21diskmicrocodetype[2]="LILO,4c494c4f"
22
23
24diskmicrocode=$( dd 2>/dev/null if="$targetDisk" count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
25#echo "${diskmicrocode}"
26diskmicrocodetypecounter=0
27while [ ${diskmicrocodetypecounter} -lt ${#diskmicrocodetype[@]} ]; do
28 diskmicrocodetypecounter=$(( ${diskmicrocodetypecounter} + 1 ))
29 diskmicrocodetypeid=${diskmicrocodetype[${diskmicrocodetypecounter}]#*,}
30 if [ ! "${diskmicrocode}" = "${diskmicrocode/${diskmicrocodetypeid}/}" ]; then
31 echo "${diskmicrocodetype[${diskmicrocodetypecounter}]%,*} found."
32exit 1
33else
34echo "Didn't find a match for ${diskmicrocodetype[${diskmicrocodetypecounter}]%,*}"
35 fi
36done
37echo "-----------------------------------------------"
38echo ""
39
40exit 0

Archive Download this file

Revision: 221