Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Trunk/package/Scripts/Sub/CheckGRUBLinuxLoader.sh

  • Property svn:executable set to *
1#!/bin/bash
2
3echo "==============================================="
4echo "CheckGRUBLinuxLoader: Does GRUB or LILO exist?"
5echo "**********************************************"
6
7# This reads the MBR of the disk in the attempt to find the
8# signature for either the GRUB or Linux bootloaders.
9# The script returns 1 if either is found, or 0 if none found.
10
11# Receives targetdisk: for example, /dev/disk2.
12# Receives targetVolume: Volume to install to.
13# Receives scriptDir: The location of the main script dir.
14
15if [ "$#" -eq 3 ]; then
16targetDisk="$1"
17targetVolume="$2"
18scriptDir="$3"
19echo "DEBUG: passed argument for targetDisk = $targetDisk"
20echo "DEBUG: passed argument for targetVolume = $targetVolume"
21echo "DEBUG: passed argument for scriptDir = $scriptDir"
22else
23echo "Error - wrong number of values passed"
24exit 9
25fi
26
27diskmicrocodetype[1]="GRUB,47525542"
28diskmicrocodetype[2]="LILO,4c494c4f"
29
30diskmicrocode=$( 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}' )
31#echo "DEBUG: ${diskmicrocode}"
32diskmicrocodetypecounter=0
33
34while [ ${diskmicrocodetypecounter} -lt ${#diskmicrocodetype[@]} ]; do
35 diskmicrocodetypecounter=$(( ${diskmicrocodetypecounter} + 1 ))
36 diskmicrocodetypeid=${diskmicrocodetype[${diskmicrocodetypecounter}]#*,}
37 if [ ! "${diskmicrocode}" = "${diskmicrocode/${diskmicrocodetypeid}/}" ]; then
38 echo "${diskmicrocodetype[${diskmicrocodetypecounter}]%,*} found."
39exit 1
40#else
41#echo "DEBUG: Didn't find a match for ${diskmicrocodetype[${diskmicrocodetypecounter}]%,*}"
42 fi
43done
44
45exit 0
46

Archive Download this file

Revision: 1726