1 | #!/bin/bash
|
---|
2 |
|
---|
3 | #
|
---|
4 | # $airboot@ecomstation.com$
|
---|
5 | #
|
---|
6 | # This is a quick-hack until the Linux version of FIXCODE.C is finished.
|
---|
7 | # Note that it does not search for the AiR-BOOT Protection Signature,
|
---|
8 | # but embeds it at the 'well known' location.
|
---|
9 | # If the protection image is moved, this script will produce a corrupted
|
---|
10 | # AIRBOOT.BIN.
|
---|
11 | # Also, a code-size of 35h (max size) is always inserted.
|
---|
12 | # Furthermore, it does not do any sanity checks whatsoever.
|
---|
13 | #
|
---|
14 |
|
---|
15 | #
|
---|
16 | # This script is now obsolete.
|
---|
17 | # Don't use since the MBR Protaction Image has moved !!
|
---|
18 | #
|
---|
19 | exit 1;
|
---|
20 |
|
---|
21 |
|
---|
22 | PROT_IMG="MBR-PROT/MBR-PROT.BIN"
|
---|
23 | AB_INTERIM_IMG="AIR-BOOT.COM"
|
---|
24 | AB_IMG="AIRBOOT.BIN"
|
---|
25 | CODE_SIZE_OFFSET=16
|
---|
26 | PROT_IMG_OFFSET=26624
|
---|
27 |
|
---|
28 |
|
---|
29 | function echox() {
|
---|
30 | echo -e $@;
|
---|
31 | }
|
---|
32 |
|
---|
33 |
|
---|
34 | function Header() {
|
---|
35 | echox "\t## FIXCODE script for Linux ##";
|
---|
36 | }
|
---|
37 |
|
---|
38 | function CheckIfFileExists() {
|
---|
39 | echox "\tCheckIfFileExists";
|
---|
40 | if [ ! -f "${1}" ]; then
|
---|
41 | echox "\tERROR: File ${1} could not be found !";
|
---|
42 | echox "\t Aborting...";
|
---|
43 | exit 1;
|
---|
44 | else
|
---|
45 | echox "\tFile ${1} found, OK.";
|
---|
46 | fi;
|
---|
47 | }
|
---|
48 |
|
---|
49 | function CreateImage() {
|
---|
50 | echox "\tCreateImage";
|
---|
51 | cp -a "${1}" "${2}";
|
---|
52 | }
|
---|
53 |
|
---|
54 | function EmbedCodeSize() {
|
---|
55 | echox "\tEmbedCodeSize";
|
---|
56 | echo "${1}"
|
---|
57 | echo -n "5" | dd of="${1}" bs=1 seek=${CODE_SIZE_OFFSET} conv=notrunc 2> /dev/null;
|
---|
58 | }
|
---|
59 |
|
---|
60 | function EmbedProtectionImage() {
|
---|
61 | echox "\tEmbedProtectionImage";
|
---|
62 | dd if="${1}" of="${2}" bs=1 seek=${PROT_IMG_OFFSET} conv=notrunc 2> /dev/null;
|
---|
63 | }
|
---|
64 |
|
---|
65 | function VerifyImage() {
|
---|
66 | echox "\tVerfyImage";
|
---|
67 | }
|
---|
68 |
|
---|
69 | function Footer() {
|
---|
70 | echox "\t## AiR-BOOT code fixed ##";
|
---|
71 | echo "";
|
---|
72 | }
|
---|
73 |
|
---|
74 |
|
---|
75 |
|
---|
76 | #
|
---|
77 | # Main program logic.
|
---|
78 | #
|
---|
79 | function Main() {
|
---|
80 | echo "";
|
---|
81 | Header;
|
---|
82 | CheckIfFileExists "${PROT_IMG}";
|
---|
83 | CheckIfFileExists "${AB_INTERIM_IMG}";
|
---|
84 | CreateImage "${AB_INTERIM_IMG}" "${AB_IMG}";
|
---|
85 | EmbedProtectionImage "${PROT_IMG}" "${AB_IMG}";
|
---|
86 | EmbedCodeSize "${AB_IMG}";
|
---|
87 | Footer;
|
---|
88 | }
|
---|
89 |
|
---|
90 |
|
---|
91 |
|
---|
92 |
|
---|
93 | #
|
---|
94 | # Invoke the main function.
|
---|
95 | #
|
---|
96 | Main;
|
---|