a2cloud/setup/shk2image
T. Joseph Carter a3d67123cc Removed a2cScriptURL and renmaed .txt from scripts
Replaced downloading scripts and files from a2cScriptURL with
installation from the source tree.  This obsoletes a2cScriptURL, so it's
been removed.

It made sense to remove the .txt from the script names since I was
rewriting the lines that use them anyway.
2018-04-22 14:44:27 -07:00

26 lines
1017 B
Bash
Executable File

#! /bin/bash
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
origDir="$PWD"
[[ ! -n $1 || ! -n $2 ]] && { echo "Usage: shk2image archiveFileName imageFileName [PRODOS.DIR.NAME]"; exit 1; };
imageFileName="$2";
prodosDir="$3";
[[ ! -f "$1" ]] && { echo "Archive file '$1' was not found."; exit 1; };
[[ ! -f "$imageFileName" ]] && mkpo "$imageFileName";
[[ -n $prodosDir ]] && dirName="$prodosDir/" || dirName=;
IFS="";
[[ ${1:0:1} == "/" ]] && archiveFile="$1" || archiveFile="$origDir/$1"
mkdir -p /tmp/shk2image_temp
cd /tmp/shk2image_temp
shkFiles=$(nulib2 -xse "$archiveFile" | tr "\r" "~" | cut -d "~" -f 2 | cut -c 18-);
cd "$origDir"
while read thisFile; do
fileName=${thisFile%%#*};
fileType=${thisFile##*#};
echo "extracting $fileName...";
acmd -d "$imageFileName" $dirName$fileName &>/dev/null;
acmd -p "$imageFileName" $dirName$fileName \$${fileType:0:2} \$${fileType:2:4} < /tmp/shk2image_temp/"$thisFile"
rm /tmp/shk2image_temp/"$thisFile"
done <<< $shkFiles
rm -r /tmp/shk2image_temp