dot.profile revision 1.18
11.18Spk# $NetBSD: dot.profile,v 1.18 2003/07/11 12:16:56 pk Exp $ 21.1Smrg# 31.11Spk# Copyright (c) 2000 The NetBSD Foundation, Inc. 41.1Smrg# All rights reserved. 51.11Spk# 61.11Spk# This code is derived from software contributed to The NetBSD Foundation 71.11Spk# by Paul Kranenburg. 81.11Spk# 91.1Smrg# Redistribution and use in source and binary forms, with or without 101.1Smrg# modification, are permitted provided that the following conditions 111.1Smrg# are met: 121.1Smrg# 1. Redistributions of source code must retain the above copyright 131.1Smrg# notice, this list of conditions and the following disclaimer. 141.1Smrg# 2. Redistributions in binary form must reproduce the above copyright 151.1Smrg# notice, this list of conditions and the following disclaimer in the 161.1Smrg# documentation and/or other materials provided with the distribution. 171.1Smrg# 3. All advertising materials mentioning features or use of this software 181.1Smrg# must display the following acknowledgement: 191.11Spk# This product includes software developed by the NetBSD 201.11Spk# Foundation, Inc. and its contributors. 211.11Spk# 4. Neither the name of The NetBSD Foundation nor the names of its 221.11Spk# contributors may be used to endorse or promote products derived 231.11Spk# from this software without specific prior written permission. 241.11Spk# 251.11Spk# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 261.11Spk# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 271.11Spk# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 281.11Spk# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 291.11Spk# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 301.11Spk# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 311.11Spk# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 321.11Spk# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 331.11Spk# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 341.11Spk# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 351.11Spk# POSSIBILITY OF SUCH DAMAGE. 361.11Spk# 371.1Smrg 381.1SmrgPATH=/sbin:/bin:/usr/bin:/usr/sbin:/ 391.1Smrgexport PATH 401.1SmrgHOME=/ 411.1Smrgexport HOME 421.1Smrg 431.1Smrgumask 022 441.1Smrg 451.15SpkMACHINE=sparc 461.12SpkINSTFS_MP=/instfs 471.12SpkMINIROOT_FSSIZE=10000 481.17SlukemMINIROOT_BPINODE=1024 491.12Spk 501.12Spkif [ "${BOOTFS_DONEPROFILE}" != "YES" ]; then 511.12Spk 521.12Spk BOOTFS_DONEPROFILE=YES 531.12Spk export BOOTFS_DONEPROFILE 541.12Spk 551.12Spk # mount root read-write 561.12Spk mount_ffs -o update /dev/md0a / 571.12Spk 581.12Spk # mount /instfs 591.17Slukem mount_mfs -s $MINIROOT_FSSIZE -i $MINIROOT_BPINODE swap $INSTFS_MP 601.1Smrgfi 611.11Spk 621.12Spk# A cat simulator 631.12Spkcat() 641.12Spk{ 651.12Spk local l 661.12Spk while read l; do 671.12Spk echo "$l" 681.12Spk done 691.12Spk} 701.12Spk 711.12Spk_resp="" 721.12Spkgetresp() { 731.12Spk read _resp 741.12Spk if [ "$_resp" = "" ]; then 751.12Spk _resp=$1 761.12Spk fi 771.12Spk} 781.11Spk 791.12Spk# Load instfs 801.11Spk 811.12Spkfloppy() 821.12Spk{ 831.14Spk local dev rval 841.14Spk 851.14Spk rval=0 861.18Spk dev="/dev/rfd0a" 871.14Spk 881.14Spk echo "Ejecting floppy disk" 891.18Spk eject $dev 901.14Spk 911.12Spk cat <<EOF 921.14SpkRemove the boot disk from the floppy station and insert the second disk of 931.14Spkthe floppy installation set into the disk drive. 941.12Spk 951.12SpkThe question below allows you to specify the device name of the floppy 961.12Spkdrive. Usually, the default device will do just fine. 971.12SpkEOF 981.12Spk echo -n "Floppy device to load the installation utilities from [$dev]: " 991.12Spk getresp "$dev"; dev="$_resp" 1001.12Spk 1011.12Spk echo "Extracting installation utilities... " 1021.14Spk (cd $INSTFS_MP && tar zxpf $dev) || rval=1 1031.14Spk 1041.14Spk echo "Ejecting floppy disk" 1051.18Spk eject $dev 1061.14Spk return $rval 1071.12Spk} 1081.12Spk 1091.12Spktape() 1101.12Spk{ 1111.13Spk local dev fn bsa 1121.12Spk cat <<EOF 1131.12SpkBy default, the installation utilities are located in the second tape file 1141.12Spkon the NetBSD/sparc installation tape. In case your tape layout is different, 1151.12Spkchoose the appropriate tape file number below. 1161.12Spk 1171.12SpkEOF 1181.12Spk dev="/dev/nrst0" 1191.12Spk echo -n "Tape device to load the installation utilities from [$dev]: " 1201.12Spk getresp "$dev"; dev="$_resp" 1211.12Spk 1221.12Spk fn=2 1231.12Spk echo -n "Tape file number [$fn]: " 1241.12Spk getresp "$fn"; fn="$_resp" 1251.12Spk 1261.13Spk echo -n "Tape block size (use only if you know you need it): " 1271.13Spk getresp ""; if [ "$_resp" != "" ]; then 1281.13Spk bsa="-b $_resp" 1291.13Spk fi 1301.12Spk 1311.12Spk echo "Positioning tape... " 1321.12Spk mt -f $dev asf $(($fn - 1)) 1331.12Spk [ $? = 0 ] || return 1 1341.12Spk 1351.12Spk echo "Extracting installation utilities... " 1361.13Spk (cd $INSTFS_MP && tar $bsa -z -x -p -f $dev) || return 1 1371.12Spk} 1381.12Spk 1391.12Spkcdrom() 1401.12Spk{ 1411.12Spk local dev tf rval 1421.12Spk cat <<EOF 1431.12SpkThe installation utilities are located on the ISO CD9660 filesystem on the 1441.12SpkNetBSD/sparc CD-ROM. We need to mount the filesystem from the CD-ROM device 1451.12Spkwhich you can specify below. Note: after the installation utilities are 1461.12Spkextracted this filesystem will be unmounted again. 1471.12Spk 1481.12SpkEOF 1491.12Spk 1501.12Spk rval=0 1511.12Spk dev="/dev/cd0a" 1521.12Spk echo -n "CD-ROM device to use [$dev]: " 1531.12Spk getresp "$dev"; dev="$_resp" 1541.12Spk 1551.12Spk mount_cd9660 -o rdonly $dev /cdrom || return 1 1561.12Spk 1571.15Spk # Look for instfs.tgz in MACHINE subdirectory first 1581.15Spk tf=/cdrom/$MACHINE/installation/bootfs/instfs.tgz 1591.15Spk [ -f $tf ] || tf=/cdrom/installation/bootfs/instfs.tgz 1601.16Spk [ -f $tf ] || { 1611.16Spk echo "Note: instfs.tgz image not found in default location" 1621.16Spk tf="" 1631.16Spk } 1641.16Spk 1651.16Spk while :; do 1661.16Spk echo -n "Path to instfs.tgz [$tf] " 1671.16Spk [ -z "$tf" ] && echo -n "(<return> to abort) " 1681.16Spk getresp "$tf"; tf="$_resp" 1691.16Spk [ -z "$tf" ] && { rval=1; break; } 1701.16Spk [ -f "$tf" ] && break; 1711.16Spk echo "$tf not found" 1721.16Spk tf="" 1731.16Spk done 1741.15Spk 1751.15Spk [ $rval = 0 ] && (cd $INSTFS_MP && tar zxpf $tf) || rval=1 1761.15Spk 1771.12Spk umount /cdrom 1781.12Spk return $rval 1791.12Spk} 1801.12Spk 1811.12Spkcat <<EOF 1821.12SpkWelcome to the NetBSD/sparc microroot setup utility. 1831.12Spk 1841.12SpkWe've just completed the first stage of a two-stage procedure to load a 1851.12Spkfully functional NetBSD installation environment on your machine. In the 1861.12Spksecond stage which is to follow now, a set of additional installation 1871.12Spkutilities must be load from your NetBSD/sparc installation medium. 1881.11Spk 1891.12SpkEOF 1901.11Spk 1911.11Spkwhile :; do 1921.12Spk cat <<EOF 1931.12SpkThis procedure supports one of the following media: 1941.12Spk 1951.12Spk 1) cdrom 1961.12Spk 2) tape 1971.12Spk 3) floppy 1981.12Spk 1991.12SpkEOF 2001.12Spk echo -n "Installation medium to load the additional utilities from: " 2011.12Spk read answer 2021.12Spk echo "" 2031.12Spk case "$answer" in 2041.12Spk 1|cdrom) _func=cdrom;; 2051.12Spk 2|tape) _func=tape;; 2061.12Spk 3|floppy) _func=floppy;; 2071.12Spk *) echo "option not supported"; continue;; 2081.12Spk esac 2091.12Spk $_func && break 2101.11Spkdone 2111.11Spk 2121.11Spk# switch to /instfs, and pretend we logged in there. 2131.12Spkchroot $INSTFS_MP /bin/sh /.profile 2141.12Spk 2151.12Spk# 2161.12Spkecho "Back in microroot; halting machine..." 2171.12Spkhalt 218