echo "Amiga Unix install script"
trap ' echo "Running interactive shell:"
exec /bin/sh -i' 2
stty erase '^H' kill '^U' intr '^C' eof '^D' quit '^\'
stty iexten echoke echoe echoctl echoprt
TAPEn=/dev/rmt/4n
TAPE=/dev/rmt/4
OFFSET=128 # Number of blocks to leave at beginning of disk
MINROOT=66 # Minimum size of root filesystem in megabytes
MINSWAP=10 # Minimum size of swap area in megabytes
MINBOOT=2 # Minimum size of bootstrap partition in megabytes
BOOTSIZE=2 # Default bootstrap partition size
MINUNIX=`expr $MINROOT '+' $MINSWAP '+' $BOOTSIZE`
restart ()
echo "\nPress return to restart the installation script: \c"
read ask || exec /bin/sh -i
exit 99
getdisksize ()
DISKLEN=`/etc/ddsize $rDISK`
echo "\nYour disk is `expr $DISKLEN '/' 2048` megabytes."
makebootable ()
/etc/rdb -p $BOOTPART -M -B -C 2 -P 2 -F 0x554e4901 $DISK
/etc/rdb -p $ROOTPART -m -F 0x554e4900 $DISK
/etc/rdb -p $SWAPPART -m -F 0x72657376 $DISK
if [ "$HAVE_AMIGADOS" = "y" ]
then
if [ "$HAVE13" = "y" ]
then
/etc/rdb -p 4 -M -B -P 1 -R 2 -F 0x444f5301 $DISK
/etc/rdb -p 5 -M -B -P 0 -R 2 -F 0x444f5301 $DISK
/etc/rdb -p 6 -M -b -R 2 -F 0x444f5301 $DISK
else
/etc/rdb -p 4 -M -B -P 1 -R 2 -F 0x444f5301 $DISK
/etc/rdb -p 5 -M -b -R 2 -F 0x444f5301 $DISK
fi
readrdbinfo ()
while [ "$ROOT_INFO" = "" ]
echo "\nWhich partition is for the root filesystem? \c"
read ROOTPART || exec /bin/sh -i
case "$ROOTPART" in
[1-9] )
UPART=/dev/dsk/c${SCSI}d0s${ROOTPART}
ROOT_INFO=`/etc/rdb -p $ROOTPART $DISK`
if [ "$?" != "0" ]
then
echo "\nNo such partition is defined."
unset ROOT_INFO
fi
esac
done
while [ "$SWAP_INFO" = "" ]
echo "\nWhich partition is for the swap space? \c"
read SWAPPART || exec /bin/sh -i
case "$SWAPPART" in
[1-9] )
SPART=/dev/dsk/c${SCSI}d0s${SWAPPART}
SWAP_INFO=`/etc/rdb -p $SWAPPART $DISK`
if [ "$?" != "0" ]
then
echo "\nNo such partition is defined."
unset SWAP_INFO
fi
esac
if [ "$ROOTPART" = "$SWAPPART" ]
then
echo "\nThe root and swap partitions cannot be the same."
unset SWAP_INFO
fi
done
while [ "$BOOT_INFO" = "" ]
echo "\nWhich partition is for the Unix bootstrap? \c"
read BOOTPART || exec /bin/sh -i
case "$BOOTPART" in
[1-9] )
BPART=/dev/dsk/c${SCSI}d0s${BOOTPART}
BOOT_INFO=`/etc/rdb -p $BOOTPART $DISK`
if [ "$?" != "0" ]
then
echo "\nNo such partition is defined."
unset BOOT_INFO
fi
esac
if [ "$ROOTPART" = "$BOOTPART" ] ||
[ "$SWAPPART" = "$BOOTPART" ]
then
echo "\nThe boot partition must not be the same as root or swap."
unset BOOT_INFO
fi
done
set $ROOT_INFO
ROOTOFF=$2
ROOTLEN=$3
set $SWAP_INFO
SWAPOFF=$2
SWAPLEN=$3
set $BOOT_INFO
BOOTOFF=$2
BOOTLEN=$3
ROOTSIZE=`expr $ROOTLEN '/' 2048`
SWAPSIZE=`expr $SWAPLEN '/' 2048`
BOOTSIZE=`expr $BOOTLEN '/' 2048`
if [ "$ROOTSIZE" -lt $MINROOT ]
then
echo "\nYour root filesystem is less than $MINROOT megabytes."
echo "It is too small for Amiga Unix to install."
restart
makebootable
getsizes ()
BOOTLEN=`expr $BOOTSIZE '*' 2048`
REMAIN=`expr $DISKLEN '-' $OFFSET '-' $BOOTLEN`
ROOTLEN=`expr $REMAIN '-' '(' $MINSWAP '*' 2048 ')'`
ROOTSIZE=`expr $ROOTLEN '/' 2048`
if [ $DISKLEN -lt 220000 ]
then
AM_DEF="n"
else
AM_DEF="y"
while [ "$HAVE_AMIGADOS" = "" ]
echo "\nDo you want to reserve space for AmigaDOS? [$AM_DEF] \c"
read ask
case $ask in
[yY]|[yY][eE][sS] )
HAVE_AMIGADOS="y"
;;
[nN]|[nN][oO] )
HAVE_AMIGADOS="n"
;;
"" )
HAVE_AMIGADOS="$AM_DEF"
;;
esac
done
if [ "$HAVE_AMIGADOS" = "y" ]
then
if [ $DISKLEN -gt 307200 ]
then
AMIGASIZE=30
else
AMIGASIZE=10
fi
MAXAMIGA=`expr $ROOTSIZE '-' $MINROOT`
unset ANS
while [ "$ANS" = "" ]
do
echo "\nHow much space do you want to set aside for AmigaDOS? [$AMIGASIZE] \c"
read ask
case $ask in
"" )
ANS="$AMIGASIZE"
;;
[0-9]* )
if [ $ask -gt $MAXAMIGA ]
then
echo "The most space you can use for AmigaDOS and still have enough"
echo "room left for Unix is $MAXAMIGA megabytes."
else
ANS="$ask"
fi
if [ $ANS -lt 7 ]
then
echo "You must set aside at least 7 megabytes for AmigaDOS."
unset ANS
fi
;;
esac
done
AMIGASIZE="$ANS"
AMIGALEN=`expr $AMIGASIZE '*' 2048`
REMAIN=`expr $REMAIN '-' $AMIGALEN`
while [ "$HAVE13" = "" ]
do
echo "\nDo you want an AmigaDOS 1.3 partition? [$AM_DEF] \c"
read ask
case $ask in
"")
HAVE13="$AM_DEF"
;;
[yY]|[yY][eE][sS] )
HAVE13="y"
;;
[nN]|[nN][oO] )
HAVE13="n"
;;
esac
done
if [ "$AMIGASIZE" -lt 10 ]
then
WB13=3840
WB20=4480
else
WB13=4096
WB20=12288
if [ "$HAVE13" = "n" ]
then
WB13=0
WBTOT=`expr $WB13 '+' $WB20`
echo "\nYour boot partition is $BOOTSIZE megabytes.\n"
ROOTLEN=`expr $REMAIN '-' '(' $MINSWAP '*' 2048 ')'`
ROOTSIZE=`expr $ROOTLEN '/' 2048`
unset ANS
while [ "$ANS" = "" ]
echo "Enter root filesystem size, in megabytes: [$ROOTSIZE] \c"
read ask || exec /bin/sh -i
case "$ask" in
"")
ANS="$ROOTSIZE"
;;
[0-9]* )
if [ "$ask" -gt "$ROOTSIZE" ]
then
echo "You must leave at least $MINSWAP megabytes free for swap space."
else
ANS="$ask"
fi
esac
done
ROOTSIZE="$ANS"
ROOTLEN=`expr $ROOTSIZE '*' 2048`
REMAIN=`expr $REMAIN '-' $ROOTLEN`
SWAPSIZE=`expr $REMAIN '/' 2048`
SWAPLEN=`expr $SWAPSIZE '*' 2048`
REMAIN=`expr $REMAIN '-' $SWAPLEN`
echo "\nThe remaining $SWAPSIZE megabytes are assigned to swap space."
createrdb ()
ROOTOFF=$OFFSET
SWAPOFF=`expr $ROOTOFF '+' $ROOTLEN`
BOOTOFF=`expr $SWAPOFF '+' $SWAPLEN`
if [ "$HAVE_AMIGADOS" = "y" ]
then
AMIGAOFF=`expr $BOOTOFF '+' $BOOTLEN`
AMIGAFOO=`expr $AMIGAOFF '+' $WB20`
AMIGABAR=`expr $AMIGAFOO '+' $WB13`
AMIGAREST=`expr $AMIGALEN '-' $WBTOT`
if [ "$HAVE13" = "y" ]
then
OTHER="WB_2.x $AMIGAOFF $WB20 \
WB_1.3 $AMIGAFOO $WB13 \
Work $AMIGABAR $AMIGAREST"
else
OTHER="WB_2.x $AMIGAOFF $WB20 \
Work $AMIGABAR $AMIGAREST"
fi
ROOTPART=1
SWAPPART=2
BOOTPART=3
UPART=/dev/dsk/c${SCSI}d0s1
SPART=/dev/dsk/c${SCSI}d0s2
BPART=/dev/dsk/c${SCSI}d0s3
/etc/rdb -c -s 64 -L 2 $DISK Unix_Root $ROOTOFF $ROOTLEN \
Unix_Swap $SWAPOFF $SWAPLEN \
Unix_Boot $BOOTOFF $BOOTLEN \
$OTHER
makebootable
echo "\nPartition table created:\n"
/etc/rdb -H $DISK ||
echo "Could not create disk partition table."
restart
# Beginning of real code
umount /mnt > /dev/null 2>&1
read KERN OLD_BOOT MEMORY JUNK < /dev/machid ||
echo "Can't determine which kernel you're running."
restart
case $MEMORY in
"00200000" ) KERNEL="A2500unix"
;;
"07000000" ) KERNEL="A3016unix"
;;
"07400000" ) KERNEL="A3008unix"
;;
"07800000" ) KERNEL="A3008unix"
;;
"07c00000" ) KERNEL="A3000unix"
;;
echo "unknown memory address from /dev/machid: $MEMORY"
restart
esac
PID=`sh -c 'cat /dev/noise > /dev/null 2>&1 &
echo $!'`
DEVS=`/etc/atdevs`
kill $PID
if [ "$DEVS" = "" ]
then
echo "\nNo hard disks are attached to this system."
restart
echo "\nHard disks attached to this system:\n"
for i in $DEVS
size=`/etc/ddsize /dev/rdsk/c${i}d0s0`
echo "SCSI id $i `expr $size '/' 2048` megabytes"
done
set -- $DEVS
if [ "$#" -gt 1 ]
then
while [ "$SCSI" = "" ]
echo "\nWhat is the SCSI id of the disk you want to install? \c"
read ask || exec /bin/sh -i
for i in $DEVS
do
if [ "$ask" = "$i" ]
then
SCSI=$i
break
fi
done
if [ "$SCSI" = "" ]
then
echo "Choose one of the following: $DEVS"
fi
done
else
SCSI=$DEVS
if [ "$OLD_BOOT" = "1" -a "$SCSI" != "0" ]
then
echo "\nWARNING: Unix cannot autoboot from a 2620/2630 ROM unless it"
echo " is installed on SCSI device 0."
DISK=/dev/dsk/c${SCSI}d0s0
rDISK=/dev/rdsk/c${SCSI}d0s0
/etc/rdb $DISK > /dev/null 2>&1
if [ "$?" = "0" ]
then
echo "\nA partition table already exists on this disk:\n"
/etc/rdb -H $DISK
while [ "$USE_EXIST" = "" ]
echo "\nDo you want to use this partition table? [y] \c"
read ask || exec /bin/sh -i
case $ask in
[yY]|[yY][eE][sS] )
USE_EXIST="yes"
;;
[nN]|[nN][oO] )
USE_EXIST="no"
;;
"" )
USE_EXIST="yes"
esac
done
else
USE_EXIST="no"
if [ "$USE_EXIST" = "yes" ]
then
readrdbinfo
else
getdisksize
getsizes
createrdb
set `swap -l`
if [ "$6" = "/dev/fakeswap" ]
then
swap -a $SPART 0 $SWAPLEN
swap -d /dev/fakeswap 0
until
echo "\nInsert Unix installation tape and press return: \c"
read nothing || exec /bin/sh -i
if [ "$FIRST_TIME" = "" ]
then
echo "\nMaking filesystems. This will take a few minutes.\n"
/etc/mkfs $UPART $ROOTLEN 1 4 >/dev/null ||
{
echo "failure: /etc/mkfs $UPART $ROOTLEN 1 4"
restart
/etc/mount $UPART /mnt 0 s5 2>/dev/null ||
echo "failure: /etc/mount $UPART /mnt 0 s5"
restart
for i in 0 1 2 3 4 5 6 7 8 9
do
for j in 0 1 2 3 4 5 6 7 8 9
do
> /mnt/lost+found/$i$j
done
done
rm /mnt/lost+found/*
chmod 755 /mnt ||
echo "failure: chmod 755 /mnt"
restart
FIRST_TIME="done"
echo "Reading tape. This will take about 45 minutes."
(cd /mnt && /bin/cpio -icdmuB < $TAPE)
echo "Read from tape failed."
done
echo "Done reading tape."
# Patch the kernel to boot on the appropriate partition, if necessary
# 480010
# |^-- scsi device #
# ^--- partition #
echo "rootdev ?W 4800${ROOTPART}${SCSI}
swapfile+18 ?W 2f633${SCSI}64
swapfile+1c ?W 30733${SWAPPART}00
swapfile+98 ?W 0t${SWAPLEN}" |
/mnt/usr/bin/adb - -w /mnt/stand/A2500unix > /dev/null ||
echo "Installation A2500 kernel patch failed."
restart
echo "rootdev ?W 4800${ROOTPART}${SCSI}
swapfile+18 ?W 2f633${SCSI}64
swapfile+1c ?W 30733${SWAPPART}00
swapfile+98 ?W 0t${SWAPLEN}" |
/mnt/usr/bin/adb - -w /mnt/stand/A3000unix > /dev/null ||
echo "Installation A3000 kernel patch failed."
restart
echo "rootdev ?W 4800${ROOTPART}${SCSI}
swapfile+18 ?W 2f633${SCSI}64
swapfile+1c ?W 30733${SWAPPART}00
swapfile+98 ?W 0t${SWAPLEN}" |
/mnt/usr/bin/adb - -w /mnt/stand/A3008unix > /dev/null ||
echo "Installation A3008 kernel patch failed."
restart
echo "rootdev ?W 4800${ROOTPART}${SCSI}
swapfile+18 ?W 2f633${SCSI}64
swapfile+1c ?W 30733${SWAPPART}00
swapfile+98 ?W 0t${SWAPLEN}" |
/mnt/usr/bin/adb - -w /mnt/stand/A3016unix > /dev/null ||
echo "Installation A3016 kernel patch failed."
restart
ln /mnt/stand/${KERNEL} /mnt/stand/unix
# Make disk bootable by Unix for old 2620/2630 ROMs, if necessary
if [ "$OLD_BOOT" = "1" ]
then
echo "\nPatching disk for booting on 2620/2630 ROMs...\n"
echo "?m 0 0x200 0
0x1f0 ?W 0x556e6978
0x1f4 ?W 0t$ROOTOFF" |
/mnt/usr/bin/adb -w $DISK > /dev/null 2>&1
ln /mnt/stand/unix /mnt/unix
else
ln -s /stand/unix /mnt/unix
echo "# file-system-table format:
# column 1: special- block special device or resource name
# column 2: fsckdev- char special device for fsck
# column 3: mountp- mount point
# column 4: fstype- File system type
# column 5: fsckpass- number if to be checked automatically
# column 6: automnt- yes/no for automatic mount
# column 7: mntopts- -o specific mount options
# White-space separates columns.
# Lines beginning with "#" are comments. Empty lines are ignored.
# a '-' in any field is a no-op.
/dev/dsk/c${SCSI}d0s${ROOTPART} /dev/rdsk/c${SCSI}d0s${ROOTPART} / s5 1 no -
proc proc /proc proc 1 no -
fd fd /dev/fd fd 1 no -
" > /mnt/etc/vfstab
cat /etc/coffboot /mnt/stand/unix > $BPART ||
echo "Installation of boot partition failed."
exit 99
sync
sync
/etc/umount $UPART
sleep 4
echo "Installation complete."
echo "Wait 10 seconds, remove floppy and tape, then reboot.\n"
sync
sync
exec /etc/uadmin 2 0 # halt system.