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 | #
|
---|
18 | exit 1;
|
---|
19 |
|
---|
20 |
|
---|
21 | PROT_IMG="MBR-PROT/MBR-PROT.BIN"
|
---|
22 | AB_INTERIM_IMG="AIR-BOOT.COM"
|
---|
23 | AB_IMG="AIRBOOT.BIN"
|
---|
24 | CODE_SIZE_OFFSET=16
|
---|
25 | PROT_IMG_OFFSET=26624
|
---|
26 |
|
---|
27 |
|
---|
28 | function echox() {
|
---|
29 | echo -e $@;
|
---|
30 | }
|
---|
31 |
|
---|
32 |
|
---|
33 | function Header() {
|
---|
34 | echox "\t## FIXCODE script for Linux ##";
|
---|
35 | }
|
---|
36 |
|
---|
37 | function CheckIfFileExists() {
|
---|
38 | echox "\tCheckIfFileExists";
|
---|
39 | if [ ! -f "${1}" ]; then
|
---|
40 | echox "\tERROR: File ${1} could not be found !";
|
---|
41 | echox "\t Aborting...";
|
---|
42 | exit 1;
|
---|
43 | else
|
---|
44 | echox "\tFile ${1} found, OK.";
|
---|
45 | fi;
|
---|
46 | }
|
---|
47 |
|
---|
48 | function CreateImage() {
|
---|
49 | echox "\tCreateImage";
|
---|
50 | cp -a "${1}" "${2}";
|
---|
51 | }
|
---|
52 |
|
---|
53 | function EmbedCodeSize() {
|
---|
54 | echox "\tEmbedCodeSize";
|
---|
55 | echo "${1}"
|
---|
56 | echo -n "5" | dd of="${1}" bs=1 seek=${CODE_SIZE_OFFSET} conv=notrunc 2> /dev/null;
|
---|
57 | }
|
---|
58 |
|
---|
59 | function EmbedProtectionImage() {
|
---|
60 | echox "\tEmbedProtectionImage";
|
---|
61 | dd if="${1}" of="${2}" bs=1 seek=${PROT_IMG_OFFSET} conv=notrunc 2> /dev/null;
|
---|
62 | }
|
---|
63 |
|
---|
64 | function VerifyImage() {
|
---|
65 | echox "\tVerfyImage";
|
---|
66 | }
|
---|
67 |
|
---|
68 | function Footer() {
|
---|
69 | echox "\t## AiR-BOOT code fixed ##";
|
---|
70 | echo "";
|
---|
71 | }
|
---|
72 |
|
---|
73 |
|
---|
74 |
|
---|
75 | #
|
---|
76 | # Main program logic.
|
---|
77 | #
|
---|
78 | function Main() {
|
---|
79 | echo "";
|
---|
80 | Header;
|
---|
81 | CheckIfFileExists "${PROT_IMG}";
|
---|
82 | CheckIfFileExists "${AB_INTERIM_IMG}";
|
---|
83 | CreateImage "${AB_INTERIM_IMG}" "${AB_IMG}";
|
---|
84 | EmbedProtectionImage "${PROT_IMG}" "${AB_IMG}";
|
---|
85 | EmbedCodeSize "${AB_IMG}";
|
---|
86 | Footer;
|
---|
87 | }
|
---|
88 |
|
---|
89 |
|
---|
90 |
|
---|
91 |
|
---|
92 | #
|
---|
93 | # Invoke the main function.
|
---|
94 | #
|
---|
95 | Main;
|
---|