a2server/scripts/a2server-5-netboot.txt

865 lines
42 KiB
Bash
Executable File

#! /bin/bash
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
# this script downloads and installs the Apple boot blocks required
# for booting an Apple II client over the network, and places
# BASIC.SYSTEM on the shared drive and configures it to be the startup
# program (for Apple IIe users, and IIgs users in ProDOS network mode).
# It also can download and install GS/OS for a network boot configuration.
# Ensure URL we'll use ends in a /
case "$A2SERVER_SCRIPT_URL" in
*/) scriptURL="$A2SERVER_SCRIPT_URL" ;;
*) scriptURL="${A2SERVER_SCRIPT_URL:-http://ivanx.com/a2server}/" ;;
esac
case "$A2SERVER_BINARY_URL" in
*/) binaryURL="$A2SERVER_BINARY_URL" ;;
*) binaryURL="${A2SERVER_BINARY_URL:-http://ivanx.com/a2server/files}/" ;;
esac
useExternalURL=1
[[ $A2SERVER_NO_EXTERNAL ]] && useExternalURL=
gsosDir="/srv/A2SERVER/A2FILES"
imagesDir=$gsosDir/GSOS.Installer/Images
imageToolsDir=$gsosDir/GSOS.Installer/Image.Tools
netInstallDir=$gsosDir/GSOS.Installer/Net.Install
p8Dir="/srv/A2SERVER/A2FILES"
diskToolsP8Dir=$p8Dir/Disk.Tools.P8
commDir="/srv/A2SERVER/A2FILES/Comm"
spectrumDir=$commDir/Spectrum
protermDir=$commDir/ProTERM
zlinkDir=$commDir/Z.Link
adtproDir=$commDir/ADTPro
gsosURL="http://download.info.apple.com/Apple_Support_Area/Apple_Software_Updates/English-North_American/Apple_II/Apple_IIGS_System_6.0.1/"
gsosBackupURL="http://archive.org/download/download.info.apple.com.2012.11/download.info.apple.com.2012.11.zip/download.info.apple.com%2FApple_Support_Area%2FApple_Software_Updates%2FEnglish-North_American%2FApple_II%2FApple_IIGS_System_6.0.1%2F"
# --- bashByter library routines
decToChar () {
# converts single-byte decimal value to equivalent character
# arg: decimal number from 0-255
# out: one character
#exit: 8=extraneous arg, 11=missing arg, 21=invalid arg
[[ $1 ]] || return 11
[[ $2 ]] && return 8
[[ ( $(printf %d "$1" 2> /dev/null ) == $1 ) \
&& ( $1 -ge 0 ) && ( $1 -le 255 ) ]] || return 21
# args are valid
echo -n -e "\x$(printf %02X "$1")"
}
charToDec () {
# converts single character to corresponding decimal value
# stdin OR arg: one character
# [arg overrides stdin; stdin is required for NUL (0) or LF (0x0A)]
# out: decimal value from 0-255
#exit: 8=extraneous arg, 9=invalid stdin,
# 11=missing stdin/arg, 21=invalid arg
[[ ( ! -t 0 ) && $1 ]] && { cat > /dev/null; return 8; }
[[ ( -t 0 ) ]] && { [[ $2 ]] && return 8; [[ $1 ]] || return 11; }
# arg/stdin is potentially valid (additional check below)
charX="$1X"; [[ $1 ]] || charX="$(cat; echo -n 'X';)"
[[ ${#charX} -le 2 ]] || return $(( $([[ $1 ]]; echo $?) ? 9 : 21 ))
# above line verifies that arg/stdin is valid
[[ ${#charX} -ne 2 ]] && { echo -n 0; return 0; }
echo -n "${charX:0:1}" | od -t u1 | \
head -1 | sed 's/[0\ ]*//' | tr -d ' \n'
}
# --- end bashByter
cpAD () {
# copy a file with its AppleDouble component in ./.AppleDouble
# arg1 = source path, # arg2 = destination directory (not filename)
afpsync=
if [[ $1 == "-s" ]]; then
afpsync=1
shift
fi
arg1="$1"
[[ "$arg1" == *"/"* ]] || arg1="./$arg1"
cp -p "$arg1" "$2"
mkdir -p "$2"/.AppleDouble
cp -p "${arg1%/*}"/.AppleDouble/"${arg1##*/}" "$2"/.AppleDouble
[[ $afpsync ]] && afpsync -v > /dev/null
}
checkP8YearTables () {
updateP8YearTables -c $1
return $?
}
updateP8YearTables () {
# JC: Geoff Body and Andrew Roughan helped Joseph Carter with this one
# Update ProDOS 8 year table (and spalsh date because may as well)
# Effectively, we're turning p8 into the 6.0.2 or 6.0.3 version here.
#
# ID: updates the year tables for the Thunderclock driver in ProDOS 8;
# calculated from the day of week and date, as year is unavailable.
# accepts optional arguments for custom patches
# arg1 = year table, comma separated
# arg2 = date string for ProDOS splash screen in format "dd-Mmm-yy"
# OR for presets, arg1=602 or arg1=603, arg2 is empty
check=
if [[ $1 == "-c" ]]; then
check=1
shift
fi
patch1=""
patch2=""
if [[ $1 == "602" ]]; then
patch1=$(echo -n -e "\x12\x11\x0b\x10\x0f\x0e\x0d")
patch2=$(echo -n -e "\xb2\xb2\xad\xca\xf5\xee\xad\xb1\xb5")
elif [[ $1 == "603" ]]; then
patch1=$(echo -n -e "\x12\x11\x0b\x10\x0f\x0e\x0d")
patch2=$(echo -n -e "\xb0\xb2\xad\xc1\xf5\xe7\xad\xb1\xb5")
elif [[ $1 ]]; then # year table supplied as seven comma-separated values
for year in $(tr "," " " <<< $1); do
patch1=${patch1}$(echo -n -e "\x$(printf %02X $year)")
done
if [[ $2 ]]; then # splash screen date supplied, convert to high-ascii bytes
for c in $(sed "s/./& /g" <<< $2); do
patch2=${patch2}$(decToChar $(( $(charToDec $c) + 128 )))
done
fi
fi
wd=$PWD
cd /usr/local/etc/netatalk/a2boot
files=("p8" "ProDOS16 Image" "Apple :2f:2fe Boot Blocks" "$gsosDir/System/P8")
offset1=(3958 7030 7071 3958) # splash screen date
offset2=(38 3110 79 38) # year table
i=0
if [[ $check ]]; then
# check if patched -- we're not actually doing this any more; we're always patching
patched=0 # 0 is true in this case since it's the return value
while (( $i < ${#files[@]} )); do
[[ ! -f "${files[$i]}" ]] && { (( i++ )); continue; }
if [[ ! $patch1 || $patch1 != $(sudo dd if="${files[$i]}" skip=${offset1[$i]} bs=1 count=7 2> /dev/null) ]]; then
patched=1 # 1 is false
break
fi
if [[ ! $patch2 || $patch2 != $(sudo dd if="${files[$i]}" skip=${offset2[$i]} bs=1 count=9 2> /dev/null) ]]; then
patched=1 # 1 is false
break
fi
(( i++ ))
done
else
# perform patch
while (( $i < ${#files[@]} )); do
[[ ! -f "${files[$i]}" ]] && { (( i++ )); continue; }
[[ $patch1 ]] && echo -n -e ${patch1} | sudo dd of="${files[$i]}" seek=${offset1[$i]} bs=1 conv=notrunc 2> /dev/null
[[ $patch2 ]] && echo -n -e ${patch2} | sudo dd of="${files[$i]}" seek=${offset2[$i]} bs=1 conv=notrunc 2> /dev/null
(( i++ ))
done
patched=0 # 0 is true
fi
return $patched
# echo -n -e "\xb0\xb2\xad\xc1\xf5\xe7\xad\xb1\xb5" | sudo dd of="p8" bs=38 seek=1 conv=notrunc 2> /dev/null
# echo -n -e "\x12\x11\x0b\x10\x0f\x0e\x0d" | sudo dd of="p8" bs=3958 seek=1 conv=notrunc 2> /dev/null
# echo -n -e "\xb0\xb2\xad\xc1\xf5\xe7\xad\xb1\xb5" | sudo dd of="ProDOS16 Image" bs=3110 seek=1 conv=notrunc 2> /dev/null
# echo -n -e "\x12\x11\x0b\x10\x0f\x0e\x0d" | sudo dd of="ProDOS16 Image" bs=7030 seek=1 conv=notrunc 2> /dev/null
# echo -n -e "\xb0\xb2\xad\xc1\xf5\xe7\xad\xb1\xb5" | sudo dd of="Apple :2f:2fe Boot Blocks" bs=79 seek=1 conv=notrunc 2> /dev/null
# echo -n -e "\x12\x11\x0b\x10\x0f\x0e\x0d" | sudo dd of="Apple :2f:2fe Boot Blocks" bs=7071 seek=1 conv=notrunc 2> /dev/null
cd "$wd"
}
# bail out on automated netboot setup unless -b is also specified
[[ -f /tmp/a2server-autoAnswerYes ]] && autoAnswerYes=1 || autoAnswerYes=
if [[ ! $autoAnswerYes || -f /tmp/a2server-setupNetBoot ]]; then
if [[ ! $autoAnswerYes ]]; then
echo
echo "Do you want to set up A2SERVER to be able to boot Apple II"
echo -n "computers over the network? "
read
fi
if [[ $autoAnswerYes || ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
nbmode=1
echo
sudo true
mkdir -p /tmp/netboot
cd /tmp/netboot
# this will get "Disk 7" (Apple II Setup) as a raw (block dump) image
if [[ ! -f /usr/local/etc/netatalk/a2boot/ProDOS16\ Boot\ Blocks ]] \
|| [[ ! -f /usr/local/etc/netatalk/a2boot/ProDOS16\ Image ]] \
|| [[ ! -f /usr/local/etc/netatalk/a2boot/Apple\ :2f:2fe\ Boot\ Blocks ]]; then
echo "A2SERVER: Downloading Apple II Boot Blocks..."
cd /tmp/netboot
if [[ $useExternalURL ]]; then
wget --max-redirect 0 -qO Disk_7_of_7-Apple_II_Setup.sea.bin ${gsosURL}Disk_7_of_7-Apple_II_Setup.sea.bin
unar -k skip Disk_7_of_7-Apple_II_Setup.sea.bin &> /dev/null
if (( $? != 0 )); then
wget -qO Disk_7_of_7-Apple_II_Setup.sea.bin ${gsosBackupURL}Disk_7_of_7-Apple_II_Setup.sea.bin
unar -k skip Disk_7_of_7-Apple_II_Setup.sea.bin &> /dev/null
fi
fi
if [[ ! -f 'Disk 7 of 7-Apple II Setup.sea' ]]; then
wget -qO Disk_7_of_7-Apple_II_Setup.sea.bin ${binaryURL}external/appleii/gsos601/Disk_7_of_7-Apple_II_Setup.sea.bin
unar -k skip Disk_7_of_7-Apple_II_Setup.sea.bin &> /dev/null
fi
truncate -s 819284 'Disk 7 of 7-Apple II Setup.sea'
dd if='Disk 7 of 7-Apple II Setup.sea' of=APPLE2SETUP.HDV bs=84 skip=1 2> /dev/null
# copy the Boot Blocks into the right place
mkdir -p a2setup
sudo mount -t hfs -o ro,loop APPLE2SETUP.HDV a2setup
sudo mkdir -p /usr/local/etc/netatalk/a2boot
sudo cp -p a2setup/System\ Folder/* /usr/local/etc/netatalk/a2boot
sudo umount a2setup
sudo mv /usr/local/etc/netatalk/a2boot/Apple* /usr/local/etc/netatalk/a2boot/'Apple :2f:2fe Boot Blocks'
cd /usr/local/etc/netatalk/a2boot
# thanks to Geoff Body for these Boot Blocks patches
# fix cleartext password login bug
echo -n -e "\xA8\xA2\x01\xBD\x80\x38\x99\xA0\x38\xC8\xE8\xE0\x09\x90\xF4" | \
sudo dd of='Apple :2f:2fe Boot Blocks' bs=19779 seek=1 conv=notrunc 2> /dev/null
echo -n -e "\xA8\xA2\x01\xBD\x80\x10\x99\xA0\x10\xC8\xE8\xE0\x09\x90\xF4" | \
sudo dd of='ProDOS16 Image' bs=22583 seek=1 conv=notrunc 2> /dev/null
# enable typing "8" during GS/OS netboot to force ProDOS 8 boot
echo -n -e "\x92" | sudo dd of='ProDOS16 Image' bs=256 seek=1 conv=notrunc 2> /dev/null
echo -n -e "\x20\x7d\x14" | sudo dd of='ProDOS16 Image' bs=864 seek=1 conv=notrunc 2> /dev/null
echo -n -e "\xad\x00\xc0\x29\xff\x00\xc9\xb8\x00\xd0\x06\xa9\x02\x00\x8d\x53\x14\xa9\x10\x0f\x60" | \
sudo dd of='ProDOS16 Image' bs=1661 seek=1 conv=notrunc 2> /dev/null
fi
echo "A2SERVER: Boot Blocks have been installed."
# get a2server-tools if necessary
if [[ ! -f /usr/local/bin/mkatinit ]] \
|| [[ ! -f /usr/local/bin/afptype ]] \
|| [[ ! -f /usr/local/bin/mkvolinfo ]] \
|| [[ ! -f /usr/local/bin/afpsync ]] \
|| [[ ! -f /usr/local/bin/cppo ]]; then
rm /tmp/2.tools &> /dev/null
wget -q -O /tmp/2.tools "${scriptURL}scripts/a2server-2-tools.txt"
chmod ugo+x /tmp/2.tools
/tmp/2.tools
rm /tmp/2.tools
fi
# put BASIC.SYSTEM at root for ProDOS 8 startup
cp -p /usr/local/etc/netatalk/a2boot/Basic.System $gsosDir/BASIC.System
afpsync -v $gsosDir > /dev/null
afptype -p SYS -q $gsosDir/BASIC.System
# create tools for setting GS/OS or ProDOS 8 boot in battery RAM and rebooting. Props yet again to Geoff Body.
if [[ ! -f $p8Dir/NETBOOT.P8 ]]; then
echo
echo "A2SERVER: Creating NETBOOT.P8..."
touch $p8Dir/NETBOOT.P8
echo -n -e "\x38\x20\x1f\xfe\x90\x01\x60\xfb\x08\xc2\x30\xf4\x02\x00\xf4\x62\x00\xa2\x03\x0b\x22\x00\x00\xe1\x78\xf4\x00\x00\xf4\x00\x00\xab\xab\x2b\x38\xfb\xce\xf4\x03\xa9\x0c\x8d\x68\xc0\x9c\x47\xc0\x9c\x41\xc0\xa9\x09\x8d\x39\xc0\xa9\xc0\x8d\x39\xc0\x5c\x62\xfa\x00" | \
sudo dd of="$p8Dir/NETBOOT.P8" 2> /dev/null
afpsync -v $p8Dir > /dev/null
afptype -p SYS -q $p8Dir/NETBOOT.P8
fi
if [[ ! -f $gsosDir/NETBOOT.GSOS ]]; then
echo
echo "A2SERVER: Creating NETBOOT.GSOS..."
# create tool for setting GSOS boot in battery RAM and rebooting. Props yet again to Geoff Body.
touch $gsosDir/NETBOOT.GSOS
echo -n -e "\x38\x20\x1f\xfe\x90\x01\x60\xfb\x08\xc2\x30\xf4\x01\x00\xf4\x62\x00\xa2\x03\x0b\x22\x00\x00\xe1\x78\xf4\x00\x00\xf4\x00\x00\xab\xab\x2b\x38\xfb\xce\xf4\x03\xa9\x0c\x8d\x68\xc0\x9c\x47\xc0\x9c\x41\xc0\xa9\x09\x8d\x39\xc0\xa9\xc0\x8d\x39\xc0\x5c\x62\xfa\x00" | \
sudo dd of="$p8Dir/NETBOOT.GSOS" 2> /dev/null
afpsync -v $gsosDir > /dev/null
afptype -p SYS -q $gsosDir/NETBOOT.GSOS
fi
mkatinit -gs -d -f # GS/OS registered user and Guest starts up with SYSTEM/FINDER
mkatinit -d -f guest # ProDOS 8 Guest starts up with BASIC.SYSTEM (no registered user)
gsosInstall=
gsosReinstall=1
if [[ -f "$gsosDir/SYSTEM/START.GS.OS" ]]; then
while true; do
gsosInstall=
gsosReinstall=
echo
echo "GS/OS is already installed on this volume."
echo "1: leave existing GS/OS system in place"
echo "2: delete installed GS/OS system, then install new GS/OS"
echo "3: install or upgrade GS/OS on top of existing GS/OS system"
echo
echo -n "Which would you like to do? "
read
if [[ $REPLY == "2" || $REPLY == "3" ]]; then
gsosReinstall=$REPLY
if (( $gsosReinstall == 2 )); then
echo
echo -n "Are you sure you want to delete your entire GS/OS System folder? "
read
if [[ ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
rm -r "$gsosDir/SYSTEM/* $gsosDir/System/.AppleDouble/*" 2> /dev/null
afpsync &> /dev/null
echo
break
fi
else
echo -n "Are you sure you want to reinstall GS/OS over your existing system? "
read
if [[ ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
rm -r "$gsosDir/SYSTEM/START.GS.OS $gsosDir/System/.AppleDouble/START.GS.OS" 2> /dev/null
afpsync &> /dev/null
echo
break
fi
fi
else
gsosInstall=1
break
fi
done
fi
if [[ $gsosReinstall ]]; then
if [[ ! $autoAnswerYes ]]; then
echo "You can set up GS/OS for network boot. This may take a while."
echo "0: don't install GS/OS"
echo "1: GS/OS 6.0.1 (official Apple release, May 1993)"
echo "2: GS/OS 6.0.2 (community release by Antoine Vignau, July 2015)"
echo "3: GS/OS 6.0.3 (community release by Tony Diaz, August 2015)"
echo
echo -n "Which flavor would you like? "
read
fi
[[ $autoAnswerYes ]] && gsosVersion=1
if [[ $REPLY == "1" || $REPLY == "2" || $REPLY == "3" ]]; then
gsosInstall=$REPLY
if [[ gsosInstall -gt 1 ]]; then
updateP8YearTables
fi
# get GS/OS disks and put them in IMAGES
# also dump contents into NET.INSTALL and modify scripts to work from there
# echo
echo
echo "A2SERVER: Downloading GS/OS 6.0.${gsosInstall} installer disk images..."
cd /tmp/netboot
mkdir -p $imagesDir
mkdir -p $netInstallDir
activeDisk=0
diskNames=( Install System.Disk SystemTools1 SystemTools2 Fonts synthLAB )
if (( $gsosInstall == 1 )); then
:
elif (( $gsosInstall == 2 )); then
gsosURL="http://mirrors.apple2.org.za/Apple%20II%20Documentation%20Project/Software/Operating%20Systems/Apple%20IIGS%20System/Disk%20Images/"
diskNames=( Install System.Disk SystemTools1 SystemTools2 SystemTools3 Fonts1 Fonts2 synthLAB )
diskWebNames=( Install System%20disk System%20tools%201 System%20tools%202 System%20tools%203 Fonts%201 Fonts%202 Synthlab )
elif (( $gsosInstall == 3 )); then
gsosURL="ftp://ftp.apple.asimov.net/pub/apple_II/images/gs/os/gsos/Apple_IIGS_System_6.0.3/"
fi
# delete previously downloaded installer
rm "$imagesDir/* $imagesDir/.AppleDouble/*" 2> /dev/null
rm "$netInstallDir/* $netInstallDir/.AppleDouble/*" 2> /dev/null
afpsync -v $gsosDir > /dev/null
for diskname in ${diskNames[@]}; do
outfile="$imagesDir/$diskname.po"
(( activeDisk++ ))
echo "A2SERVER: Disk ${activeDisk} of ${#diskNames[@]}: $diskname"
if (( $gsosInstall == 1 )); then
if [[ $useExternalURL ]]; then
wget --max-redirect 0 -qO "Disk_${activeDisk}_of_7-${diskname}.sea.bin" "${gsosURL}Disk_${activeDisk}_of_7-${diskname}.sea.bin"
unar -k skip "Disk_${activeDisk}_of_7-${diskname}.sea.bin" &> /dev/null
if [[ ! -f "Disk ${activeDisk} of 7-${diskname}.sea" ]]; then
wget -qO "Disk_${activeDisk}_of_7-${diskname}.sea.bin" "${gsosBackupURL}Disk_${activeDisk}_of_7-${diskname}.sea.bin"
unar -k skip "Disk_${activeDisk}_of_7-${diskname}.sea.bin" &> /dev/null
fi
fi
if [[ ! -f "Disk ${activeDisk} of 7-${diskname}.sea" ]]; then
wget -qO "Disk_${activeDisk}_of_7-${diskname}.sea.bin" "${binaryURL}external/appleii/gsos601/Disk_${activeDisk}_of_7-${diskname}.sea.bin"
unar -k skip "Disk_${activeDisk}_of_7-${diskname}.sea.bin" &> /dev/null
fi
truncate -s 819284 "Disk ${activeDisk} of 7-${diskname}.sea"
dd if="Disk ${activeDisk} of 7-${diskname}.sea" of=${outfile} bs=84 skip=1 &> /dev/null
elif (( $gsosInstall == 2 )); then
if [[ $useExternalURL ]]; then
wget -qO $outfile "$gsosURL/IIGS%20System%206.0.2%20-%20Disk%20${activeDisk}%20${diskWebNames[$activeDisk-1]}.po"
fi
if [[ $? -ne 0 || ! -f $outfile ]]; then
wget -qO $outfile "${binaryURL}external/appleii/gsos602/$diskname.po"
fi
elif (( $gsosInstall == 3 )); then
if [[ $useExternalURL ]]; then
wget -qO $outfile "$gsosURL/$diskname.po"
fi
if [[ $? -ne 0 || ! -f $outfile ]]; then
wget -qO $outfile "${binaryURL}external/appleii/gsos603/$diskname.po"
fi
fi
cppo -s -ad $outfile $netInstallDir
done
rm *.sea* &> /dev/null
sed -i "s/\([^\\]\r:\)/\1A2FILES:GSOS.Installer:Net.Install:/g" $netInstallDir/Install/Scripts/*
afpsync -v $gsosDir > /dev/null
# install GS/OS
# spec for GS/OS installer scripts: GS/OS Tech Note #64
# http://www.1000bit.it/support/manuali/apple/technotes/iigs/tn.iigs.064.html
processScript () {
scriptEntries=$(cat $1 | tr '\r' '#' | tr '~' '\n' | sed 's/4#D/5/')
IFS=$'\n'
scriptEntries=($scriptEntries)
pathPrefix="/A2FILES/GSOS.Installer/Net.Install"$(tr ':' '/' <<< ${scriptEntries[0]##S*\\\\#})
entryCount=${#scriptEntries[@]}
(( entryCount -= 2 ))
# echo "entryCount: $entryCount"
entryIndex=2
while (( entryIndex <= entryCount )); do
IFS='#'
scriptEntry=(${scriptEntries[entryIndex]})
# echo $entryIndex $entryCount ${scriptEntry[@]}
action=${scriptEntry[1]:0:1}
sourcePathMixed=$(tr ':' '/' <<< ${scriptEntry[5]})
[[ ${sourcePathMixed:0:1} != '/' ]] && sourcePathMixed="${pathPrefix}/$sourcePathMixed"
sourcePath=$sourcePathMixed
targetPath=$gsosDir/$(tr ':' '/' <<< ${scriptEntry[6]})
# volumeName=$(cut -d/ -f 2 <<< $sourcePath)
targetParent=${targetPath%/*}
targetFile=${targetPath##*/}
sourceParent=${sourcePath%/*}
sourceFile=${sourcePath##*/}
if [[ $action == 1 || $action == 2 ]]; then
mkdir -p $targetParent
echo "copying: $sourcePathMixed"
echo " to: $targetPath"
echo
[[ ! -d $targetParent ]] && mkdir -p $targetParent
cp -p ${gsosDir%/*}$sourcePath $targetPath
[[ ! -d $targetParent/.AppleDouble ]] && mkdir -p $targetParent/.AppleDouble
cp -p ${gsosDir%/*}$sourceParent/.AppleDouble/$sourceFile $targetParent/.AppleDouble/$targetFile
elif [[ $action == 3 || $action == 4 ]]; then
if [[ -f "$targetPath" ]]; then
echo "deleting $targetPath"
rm "$targetPath"
[[ -f $targetParent/.AppleDouble/$targetFile ]] && rm "$targetParent/.AppleDouble/$targetFile"
fi
fi
(( entryIndex++ ))
done
unset IFS
}
mkdir -p /tmp/netboot
cd /tmp/netboot
echo "A2SERVER: Preparing GS/OS installer scripts..."
# work through installer scripts
echo "Script: Install.Sys.File"
processScript $netInstallDir/Install/Scripts/Instal.Sys.File
echo "Script: HFS.FST"
processScript $netInstallDir/Install/Scripts/HFS.FST
echo "Script: DOS33.FST"
processScript $netInstallDir/INSTALL/SCRIPTS/DOS3.3.FST
echo "Script: Teach"
processScript $netInstallDir/Install/Scripts/Teach
echo "Script: AppleShare"
processScript $netInstallDir/Install/Scripts/Appleshare
echo "Script: Server.Sys.File"
processScript $netInstallDir/Install/Scripts/Server.Sys.File
# sync netatalk database
afpsync -v $gsosDir > /dev/null
else
gsosInstall=
fi
fi
# if [[ ! $autoAnswerYes && (! $gsosInstall || $gsosInstall -lt 2) ]] && ! checkP8YearTables 603; then
# echo
# echo -n "Do you want to update the ProDOS 8 Thunderclock year tables? "
# read
# fi
# if [[ $autoAnswerYes || ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
# updateP8YearTables 603
# elif [[ $gsosInstall -ge 2 ]]; then
# updateP8YearTables 60${gsosInstall}
# fi
# patch ProDOS 8 Thunderclock driver year table based on today's date
echo
echo "A2SERVER: Updating ProDOS 8 Thunderclock driver year tables..."
mkdir -p /tmp/netboot
wget -qO /tmp/netboot/clock.patch.py "${scriptURL}scripts/clock.patch.py"
updateP8YearTables $(python /tmp/netboot/clock.patch.py $(LANG=C date +"%a %m/%d/%y"))
if [[ ! $autoAnswerYes ]]; then
echo
echo "Do you want to download and install utilities for working with"
echo -n "disk images and archive files in GS/OS? "
read
fi
if [[ $autoAnswerYes || ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
# download image tools and put them in IMAGE.TOOLS
echo "A2SERVER: Downloading GS/OS disk image utilities..."
mkdir -p $imageToolsDir
# get Asimov2 (for GS/OS)
echo -n "Asimov 2.0"
if [[ -f $imageToolsDir/Asimov ]]; then
echo " is already installed."
else
echo
cd /tmp/netboot
if [[ $useExternalURL ]]; then
wget -qO Asimov.shk http://www.ninjaforce.com/downloads/Asimov.shk
nulib2 -x -s Asimov.shk &> /dev/null
fi
if [[ ! -d Asimov ]]; then
wget -qO Asimov.shk ${binaryURL}external/appleii/Asimov.shk
nulib2 -x -s Asimov.shk &> /dev/null
fi
cp -p Asimov/Asimov $imageToolsDir/Asimov
afpsync -v $gsosDir > /dev/null
cat Asimov/Asimov_rsrc_ >> $imageToolsDir/.AppleDouble/Asimov
afptype -p S16 -q $imageToolsDir/Asimov
fi
echo -n "GS-ShrinkIt 1.1"
# get GS-ShrinkIt
if [[ -f $imageToolsDir/GSHK ]]; then
echo " is already installed."
else
echo
mkdir -p /tmp/netboot/gshk
cd /tmp/netboot/gshk
if [[ $useExternalURL ]]; then
wget -qO gshk11.sea http://web.archive.org/web/20131031160750/http://nulib.com/library/gshk11.sea
#wget -qO gshk11.sea http://www.nulib.com/library/gshk11.sea
nulib2 -x -s gshk11.sea &> /dev/null
fi
if [[ ! -f GSHK ]]; then
wget -qO gshk11.sea ${binaryURL}external/appleii/gshk11.sea
nulib2 -x -s gshk11.sea &> /dev/null
fi
cp -p GSHK $imageToolsDir/GSHK
afpsync -v $gsosDir > /dev/null
cat GSHK_rsrc_ >> $imageToolsDir/.AppleDouble/GSHK
afptype -p S16 -a DB07 -q $imageToolsDir/GSHK
cd /tmp/netboot
fi
echo -n "MountIt 1.4"
# get MountIt (for GS/OS)
if [[ -f $imageToolsDir/MOUNTIT.SHK ]]; then
echo " is already installed."
else
echo
mkdir -p /tmp/netboot/mountit
cd /tmp/netboot/mountit
if [[ $useExternalURL ]]; then
wget -q -O MOUNTIT.SHK http://www.brutaldeluxe.fr/products/apple2gs/MOUNTIT.SHK
cppo -s -ad MOUNTIT.SHK System:System.Setup:MountIt . &> /dev/null
cppo -s -ad MOUNTIT.SHK ReadMe . &> /dev/null
fi
if [[ ! -f ReadMe ]]; then
wget -qO MOUNTIT.SHK ${binaryURL}external/appleii/MOUNTIT.SHK
cppo -s -ad MOUNTIT.SHK System:System.Setup:MountIt . &> /dev/null
cppo -s -ad MOUNTIT.SHK ReadMe . &> /dev/null
fi
cpAD ./MountIt $gsosDir/System/System.Setup
mkdir -p $gsosDir/GSOS.Installer/Image.Tools/MountIt
cpAD ./ReadMe $gsosDir/GSOS.Installer/Image.Tools/MountIt
afpsync -v $gsosDir > /dev/null
fi
fi
if [[ ! $autoAnswerYes ]]; then
echo
echo "Do you want to download and install utilities for working with"
echo -n "disk images and archive files in ProDOS 8? "
read
fi
if [[ $autoAnswerYes || ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
echo "A2SERVER: Downloading ProDOS 8 disk image utilities..."
mkdir -p $diskToolsP8Dir
echo -n "ShrinkIt 3.4"
# get ShrinkIt 3.4 (for ProDOS 8)
if [[ -f $diskToolsP8Dir/SHRINKIT ]]; then
echo " is already installed."
else
echo
cd /tmp/netboot
if [[ $useExternalURL ]]; then
wget -qO shrinkit.sdk http://web.archive.org/web/20131031160750/http://www.nulib.com/library/shrinkit.sdk
nulib2 -x -s shrinkit.sdk &> /dev/null
fi
if [[ ! -f SHRINKIT ]]; then
wget -qO shrinkit.sdk ${binaryURL}external/appleii/shrinkit.sdk
nulib2 -x -s shrinkit.sdk &> /dev/null
fi
cppo -s -ad SHRINKIT /SHRINKIT/SHRINKIT $diskToolsP8Dir &> /dev/null
afpsync -v $sharepath > /dev/null
fi
echo -n "DSK2FILE 5.8"
# get DSK2FILE (for ProDOS 8)
if [[ -f $diskToolsP8Dir/DSK2FILE ]]; then
echo " is already installed."
else
echo
cd /tmp/netboot
if [[ $useExternalURL ]]; then
wget -q -O dsk2file.shk http://www.dwheeler.com/6502/oneelkruns/dsk2file.zip
nulib2 -x -s dsk2file.shk &> /dev/null
fi
if [[ ! -f DSK2FILE58 ]]; then
wget -qO dsk2file.shk ${binaryURL}external/appleii/dsk2file.shk
nulib2 -x -s dsk2file.shk &> /dev/null
fi
cp -p DSK2FILE58 $diskToolsP8Dir/DSK2FILE
afpsync -v $sharepath > /dev/null
afptype -p SYS -q $diskToolsP8Dir/DSK2FILE
fi
echo -n "Apple System Utilities 3.1"
if [[ -f $diskToolsP8Dir/SYSUTIL ]]; then
echo " is already installed."
else
echo
cd /tmp/netboot
if [[ $useExternalURL ]]; then
wget --max-redirect 0 -qO Apple_II_System_Disk_3.2.sea.bin http://download.info.apple.com/Apple_Support_Area/Apple_Software_Updates/English-North_American/Apple_II/Apple_II_Supplemental/Apple_II_System_Disk_3.2.sea.bin
if (( $? != 0 )); then
wget -qO Apple_II_System_Disk_3.2.sea.bin http://archive.org/download/download.info.apple.com.2012.11/download.info.apple.com.2012.11.zip/download.info.apple.com%2FApple_Support_Area%2FApple_Software_Updates%2FEnglish-North_American%2FApple_II%2FApple_II_Supplemental%2FApple_II_System_Disk_3.2.sea.bin
unar -k skip Apple_II_System_Disk_3.2.sea.bin &> /dev/null
fi
fi
if [[ ! -f 'Apple II System Disk 3.2.sea' ]]; then
wget -qO Apple_II_System_Disk_3.2.sea.bin ${binaryURL}external/appleii/Apple_II_System_Disk_3.2.sea.bin
unar -k skip Apple_II_System_Disk_3.2.sea.bin &> /dev/null
fi
truncate -s 819284 'Apple II System Disk 3.2.sea'
dd if='Apple II System Disk 3.2.sea' of=A2SYSDISK32.HDV bs=84 skip=1 2> /dev/null
cppo -s -ad A2SYSDISK32.HDV /UTILITIES/SYSUTIL.SYSTEM $diskToolsP8Dir/SYSUTIL &> /dev/null
cppo -s -ad A2SYSDISK32.HDV /UTILITIES/UTIL.0 $diskToolsP8Dir &> /dev/null
cppo -s -ad A2SYSDISK32.HDV /UTILITIES/UTIL.1 $diskToolsP8Dir &> /dev/null
cppo -s -ad A2SYSDISK32.HDV /UTILITIES/UTIL.2 $diskToolsP8Dir &> /dev/null
afpsync -v $sharepath > /dev/null
fi
fi
if [[ ! $autoAnswerYes ]]; then
[[ -f "$gsosDir/System/Start.GS.OS" ]] && gsosInstalled="GS/OS and " || gsosInstalled=
echo
echo "Do you want to download communications software for"
echo -n "$gsosInstalled""ProDOS 8? "
read
fi
if [[ $autoAnswerYes || ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
echo "A2SERVER: Downloading communications software..."
mkdir -p $commDir
if [[ $gsosInstalled ]]; then
echo -n "Spectrum"
# get Spectrum
if [[ -f $spectrumDir/Spectrum ]]; then
echo " is already installed."
else
echo
mkdir -p $spectrumDir
# remove images that might have been installed by 1.2.5
cd $spectrumDir
rm SPECTRUM.HDV MANUALS.HDV SOUNDS.HDV EXTRAS.HDV &> /dev/null
# install Spectrum into GS/OS
mkdir -p /tmp/netboot/spectrum
cd /tmp/netboot/spectrum
if [[ $useExternalURL ]]; then
wget -qO spectrum_gold_2mg.zip http://www.speccie.co.uk/speccie/software/spectrum_gold_2mg.zip
unzip -p spectrum_gold_2mg.zip 2> /dev/null | dd bs=64 skip=1 of=Spectrum.Gold.HDV 2> /dev/null
fi
if [[ ! -f Spectrum.Gold.HDV || $(wc -c < Spectrum.Gold.HDV) -eq 0 ]]; then
wget -qO spectrum_gold_2mg.zip ${binaryURL}external/appleii/spectrum_gold_2mg.zip
unzip -p spectrum_gold_2mg.zip 2> /dev/null | dd bs=64 skip=1 of=Spectrum.Gold.HDV 2> /dev/null
fi
cppo -s -ad Spectrum.Gold.HDV . &> /dev/null
userFolder=$(tr [:lower:] [:upper:] <<< $USER)
for thisFolder in \
Installer/Extras/CDEvs^System/CDevs \
Installer/Extras/Tools^System/Tools \
Installer/Extras/Fonts^System/Fonts \
Installer/Extras/System.Setup^System/System.Setup \
Installer/Help^System/Desk.Accs \
Installer/Spectrum.Sounds^System/Sounds \
Spectrum.2.5.4/Add.Ons^USERS/$userFolder/Add.Ons \
Spectrum.2.5.4/Spectrum.Script^USERS/$userFolder/Spectrum.Script \
Spectrum.2.5.4/Add.Ons^Comm/Spectrum/Add.Ons \
Spectrum.2.5.4/Spectrum.Script^Comm/Spectrum/Spectrum.Script \
Manuals^Comm/Spectrum/Manuals
do
mkdir -p $gsosDir/"${thisFolder##*^}"
cp -R Spectrum.Gold/${thisFolder%%^*}/* $gsosDir/"${thisFolder##*^}"
mkdir -p $gsosDir/"${thisFolder##*^}"/.AppleDouble
cp -R Spectrum.Gold/${thisFolder%%^*}/.AppleDouble/* $gsosDir/"${thisFolder##*^}"/.AppleDouble
done
cpAD Spectrum.Gold/Installer/SoundPatch $spectrumDir
cpAD Spectrum.Gold/Spectrum.2.5.4/Spectrum $spectrumDir
afpsync -v $gsosDir > /dev/null
fi
echo -n "Marinetti 3.0b8"
if [[ -f $gsosDir/System/CDevs/TCPIP ]]; then
echo " is already installed."
else
echo
mkdir -p /tmp/netboot/marinetti
cd /tmp/netboot/marinetti
# Marinetti 3.0b1
wget -qO MarinettiB1.SHK ${binaryURL}appleii/MarinettiB1.SHK
cppo -ad -s -n MarinettiB1.SHK $gsosDir > /dev/null
# TCP/IP update (3.0b8)
if [[ $useExternalURL ]]; then
wget -qO Marinetti3.0b8.po http://www.a2retrosystems.com/downloads/Marinetti3.0b8.po
fi
if [[ $? != 0 || ! -f Marinetti3.0b8.po || $(wc -c < Marinetti3.0b8.po) != "819200" ]]; then
wget -qO Marinetti3.0b8.po ${binaryURL}external/appleii/Marinetti3.0b8.po
fi
cppo -ad Marinetti3.0b8.po /MARINETTI3.0B8/TCPIP $gsosDir/System/System.Setup > /dev/null
cppo -ad Marinetti3.0b8.po /MARINETTI3.0B8/CHANGELOG.3.0B8 $commDir/Marinetti > /dev/null
# PPP Scripted Link Layer update (1.3d4)
if [[ $useExternalURL ]]; then
wget -qO PPPX.1.3d4.SHK http://www.apple2.org/marinetti/PPPX.1.3d4.SHK
fi
if [[ $? != 0 || ! -f PPPX.1.3d4.SHK || $(wc -c < PPPX.1.3d4.SHK) != "22068" ]]; then
wget -qO PPPX.1.3d4.SHK ${binaryURL}external/appleii/PPPX.1.3d4.SHK
fi
cppo -ad -s PPPX.1.3d4.SHK . &> /dev/null
cd PPPX.1.3d4
cpAD PPP.scripted $gsosDir/System/TCPIP
cpAD PPP.Script.DOC $commDir/Marinetti/Documentation
mkdir -p $commDir/Marinetti/PPP.scripted
cpAD Connect.Script $commDir/Marinetti/PPP.scripted
cpAD ChangeLog $commDir/Marinetti/PPP.scripted
# Uthernet Link Layer
if [[ $useExternalURL ]]; then
wget -qO uthernetll.bxy http://www.speccie.co.uk/speccie/software/uthernetll.bxy
fi
if [[ $? != 0 || ! -f uthernetll.bxy || $(wc -c < uthernetll.bxy) -eq 0 ]]; then
wget -qO uthernetll.bxy ${binaryURL}external/appleii/uthernetll.bxy
fi
cppo -ad -s -n uthernetll.bxy $gsosDir/System/TCPIP > /dev/null
# Uthernet II Link Layer
if [[ $useExternalURL ]]; then
wget -qO uthernet2ll.bxy http://www.speccie.co.uk/speccie/software/uthernet2ll.bxy
fi
if [[ $? != 0 || ! -f uthernet2ll.bxy || $(wc -c < uthernet2ll.bxy) -eq 0 ]]; then
wget -qO uthernet2ll.bxy ${binaryURL}external/appleii/uthernet2ll.bxy
fi
cppo -ad -s -n uthernet2ll.bxy $gsosDir/System/TCPIP > /dev/null
# MacIP Link Layer settings for A2SERVER
wget -qO- ${binaryURL}macip-prefs.tgz | tar Pxz
afpsync -v $gsosDir > /dev/null
fi
fi
echo -n "ProTERM and Z-Link"
# get A2CLOUD disk and copy from there
if [[ -f $protermDir/PROTERM ]]; then
echo " are already installed."
else
echo
mkdir -p $protermDir
mkdir -p $protermDir/.AppleDouble
mkdir -p $zlinkDir
mkdir -p $zlinkDir/.AppleDouble
cd /tmp/netboot
wget -qO A2CLOUD.HDV "${binaryURL}appleii/A2CLOUD.HDV"
cppo -ad A2CLOUD.HDV . &> /dev/null
cd A2CLOUD
mv *PT3* *PROTERM* $protermDir
mv Z.LINK $zlinkDir
cd .AppleDouble
mv *PT3* *PROTERM* $protermDir/.AppleDouble
mv Z.LINK $zlinkDir/.AppleDouble
afpsync -v $gsosDir > /dev/null
fi
echo -n "ADTPro and VSDRIVE"
if [[ -f $adtproDir/ADTPRO ]]; then
echo " are already installed."
else
mkdir -p $adtproDir
mkdir -p $adtproDir/.AppleDouble
echo
cd /tmp/netboot/A2CLOUD
mv *ADTPRO* *VEDRIVE* *VSDRIVE* $adtproDir
cd .AppleDouble
mv *ADTPRO* *VEDRIVE* *VSDRIVE* $adtproDir/.AppleDouble
afpsync -v $gsosDir > /dev/null
fi
fi
# clean up
cd
# rock and roll!
echo
echo
if [[ $gsosInstall ]]; then
echo "GS/OS network boot (for registered user and Guest) and"
fi
echo "ProDOS 8 network boot (for Guest only) is now configured."
echo "See http://ivanx.com/a2server for info using it."
fi
if [[ ! $autoAnswerYes ]]; then
echo
echo "Do you want to download the patch required for using"
echo -n "a Farallon LocalTalk-to-Ethernet bridge with GS/OS? "
read
fi
if [[ $autoAnswerYes || ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
# Farallon bridge patch for GS/OS courtesy of Geoff Body
echo "A2SERVER: Downloading Farallon bridge patch..."
wget -qO /tmp/FARALLON.PO "${binaryURL}appleii/FARALLON.B1.PO" &> /dev/null
if [[ -d $gsosDir/SYSTEM/SYSTEM.SETUP ]]; then
cppo -s -ad /tmp/FARALLON.PO /ATALKPATCH/ATALKIRQ $gsosDir/SYSTEM/SYSTEM.SETUP &> /dev/null
echo
echo "A2SERVER: The Farallon bridge patch is installed."
else
cppo -s -ad /tmp/FARALLON.PO /ATALKPATCH/ATALKIRQ $gsosDir &> /dev/null
echo
echo "On your Apple IIgs, copy the file ATALKIRQ in /A2SHARED to the"
echo "SYSTEM.SETUP folder of the SYSTEM folder of your GSOS startup disk,"
echo "or, if you can't, download the patch from the A2SERVER web site."
fi
echo
echo "Note: Farallon bridges can only be used in GS/OS (with this patch)"
echo "and Apple IIe computers. Apple IIgs computers which network boot"
echo "directly into ProDOS 8 will freeze after a few minutes."
fi
fi