wok annotate BootProg/stuff/bootprog.sh @ rev 24531
updated osip and osip-dev (5.1.1 -> 5.3.0)
author | Hans-G?nter Theisgen |
---|---|
date | Wed Feb 23 09:00:20 2022 +0100 (2022-02-23) |
parents | |
children | d1f31f5f6401 |
rev | line source |
---|---|
pascal@24476 | 1 #!/bin/sh |
pascal@24476 | 2 |
pascal@24476 | 3 [ ! -e "$1" ] && cat <<EOT && exit 2 |
pascal@24476 | 4 Usage: [FAT=<FAT12|FAT16|FAT32|EXFAT>] $0 device [boot name entry] [boot.bin] |
pascal@24476 | 5 Example: $0 /dev/fd0 STARTUP.BIN |
pascal@24476 | 6 EOT |
pascal@24476 | 7 |
pascal@24476 | 8 while read chk ofs fat bin name; do |
pascal@24476 | 9 [ $FAT -eq $fat ] || [ "$(dd if="$1" bs=1 count=8 skip=$chk)" = "$fat " ] || continue |
pascal@24476 | 10 echo "Install $fat bootsector on $1." |
pascal@24476 | 11 for arg in "skip=$(($ofs+8)) seek=$(($ofs+8))" "count=11" ; do |
pascal@24476 | 12 if [ "$3" ]; then |
pascal@24476 | 13 cat "$3" |
pascal@24476 | 14 else |
pascal@24476 | 15 sed '1,/^exit 1/d' $0 | tar xzOf - boot$bin.bin |
pascal@24476 | 16 fi | dd of="$1" bs=1 conv=notrunc $arg |
pascal@24476 | 17 done |
pascal@24476 | 18 [ "$2" ] && echo "Set bootfile '$2'" && echo -en "$name" | \ |
pascal@24476 | 19 dd of="$1" bs=1 conv=notrunc seek=499 count=11 |
pascal@24476 | 20 case "$fat" in |
pascal@24476 | 21 EXFAT) dd if="$1" bs=512 count=11 | od -v -An -t u1 -w1 - | awk ' |
pascal@24476 | 22 BEGIN { chk=0; i=-1 } |
pascal@24476 | 23 { |
pascal@24476 | 24 i++ |
pascal@24476 | 25 if (i == 106 || i == 107 || i == 112) next |
pascal@24476 | 26 chk = or(lshift(chk,31),rshift(chk,1)) + $1 |
pascal@24476 | 27 } |
pascal@24476 | 28 END { a=chk%256; b=(chk/256)%256; c=(chk/256/256)%256; d=chk/256/256/256 |
pascal@24476 | 29 for (i=0;i<128;i++) printf "echo -en \"\\x%02X\\x%02X\\x%02X\\x%02X\"\n",a,b,c,d |
pascal@24476 | 30 } ' | sh | dd bs=512 of="$1" seek=11 |
pascal@24476 | 31 esac |
pascal@24476 | 32 exit 0 |
pascal@24476 | 33 done 2> /dev/null <<EOT |
pascal@24476 | 34 54 54 FAT12 16 $(A="${2/./ }";echo "${A:0:8}${A##* } " | tr '[a-z]' '[A-Z]' | sed 's| |\\\\x20|g') |
pascal@24476 | 35 54 54 FAT16 16 $(A="${2/./ }";echo "${A:0:8}${A##* } " | tr '[a-z]' '[A-Z]' | sed 's| |\\\\x20|g') |
pascal@24476 | 36 82 82 FAT32 32 $(A="${2/./ }";echo "${A:0:8}${A##* } " | tr '[a-z]' '[A-Z]' | sed 's| |\\\\x20|g') |
pascal@24476 | 37 3 105 EXFAT ex $(echo "$2" | sed 's| |.|;s| ||g')\\\\0\\\\0\\\\0\\\\0\\\\0\\\\0\\\\0\\\\0\\\\0\\\\0 |
pascal@24476 | 38 EOT |
pascal@24476 | 39 exit 1 |