wok diff 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 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/BootProg/stuff/bootprog.sh Wed Feb 23 09:00:20 2022 +0100 1.3 @@ -0,0 +1,39 @@ 1.4 +#!/bin/sh 1.5 + 1.6 +[ ! -e "$1" ] && cat <<EOT && exit 2 1.7 +Usage: [FAT=<FAT12|FAT16|FAT32|EXFAT>] $0 device [boot name entry] [boot.bin] 1.8 +Example: $0 /dev/fd0 STARTUP.BIN 1.9 +EOT 1.10 + 1.11 +while read chk ofs fat bin name; do 1.12 + [ $FAT -eq $fat ] || [ "$(dd if="$1" bs=1 count=8 skip=$chk)" = "$fat " ] || continue 1.13 + echo "Install $fat bootsector on $1." 1.14 + for arg in "skip=$(($ofs+8)) seek=$(($ofs+8))" "count=11" ; do 1.15 + if [ "$3" ]; then 1.16 + cat "$3" 1.17 + else 1.18 + sed '1,/^exit 1/d' $0 | tar xzOf - boot$bin.bin 1.19 + fi | dd of="$1" bs=1 conv=notrunc $arg 1.20 + done 1.21 + [ "$2" ] && echo "Set bootfile '$2'" && echo -en "$name" | \ 1.22 + dd of="$1" bs=1 conv=notrunc seek=499 count=11 1.23 + case "$fat" in 1.24 + EXFAT) dd if="$1" bs=512 count=11 | od -v -An -t u1 -w1 - | awk ' 1.25 +BEGIN { chk=0; i=-1 } 1.26 +{ 1.27 + i++ 1.28 + if (i == 106 || i == 107 || i == 112) next 1.29 + chk = or(lshift(chk,31),rshift(chk,1)) + $1 1.30 +} 1.31 +END { a=chk%256; b=(chk/256)%256; c=(chk/256/256)%256; d=chk/256/256/256 1.32 + for (i=0;i<128;i++) printf "echo -en \"\\x%02X\\x%02X\\x%02X\\x%02X\"\n",a,b,c,d 1.33 +} ' | sh | dd bs=512 of="$1" seek=11 1.34 + esac 1.35 + exit 0 1.36 +done 2> /dev/null <<EOT 1.37 +54 54 FAT12 16 $(A="${2/./ }";echo "${A:0:8}${A##* } " | tr '[a-z]' '[A-Z]' | sed 's| |\\\\x20|g') 1.38 +54 54 FAT16 16 $(A="${2/./ }";echo "${A:0:8}${A##* } " | tr '[a-z]' '[A-Z]' | sed 's| |\\\\x20|g') 1.39 +82 82 FAT32 32 $(A="${2/./ }";echo "${A:0:8}${A##* } " | tr '[a-z]' '[A-Z]' | sed 's| |\\\\x20|g') 1.40 +3 105 EXFAT ex $(echo "$2" | sed 's| |.|;s| ||g')\\\\0\\\\0\\\\0\\\\0\\\\0\\\\0\\\\0\\\\0\\\\0\\\\0 1.41 +EOT 1.42 +exit 1