1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-05 08:29:02 -08:00

use xxd in case hexdump is missing in grab

as is the case for minimal debian/ubuntu installs (containers)
This commit is contained in:
Connor Olding 2024-07-13 01:51:58 -07:00
parent 18b6d2cecf
commit 5b29189372

10
sh/grab
View file

@ -31,6 +31,12 @@ will clean up temporary files
! [ -d "$t" ] || rm -r "$t" || die
exit 1
}
hex(){
if [ -f /usr/bin/xxd ]
then exec xxd -p -l4 -- "$@"
else exec hexdump -ve '1 1 "%02x"' -n4 -- "$@"
fi
}
owd="${PWD:?unsupported}"
@ -78,9 +84,9 @@ will verify file integrity of "$fn"
minisign -QVm "$fn" -P "$pub" || die
will determine basic file type
x4="$(exec hexdump -ve '1 1 "%02X"' -n4 -- "$fn")" || die
x4="$(hex "$fn")" || die
x2="${x4%????}"
if [ "$x4" = 7F454C46 ] || [ "$x2" = 2321 ] || [ "$x2" = 4D5A ]
if [ "$x4" = 7f454c46 ] || [ "$x2" = 2321 ] || [ "$x2" = 4d5a ]
then
will set executable permission
chmod +x -- "$fn" || die