11.8Stsutsui# $NetBSD: dot.commonutils,v 1.8 2022/08/28 12:44:01 tsutsui Exp $
21.1Sperry#
31.1Sperry# Copyright (c) 1994 Christopher G. Demetriou
41.1Sperry# All rights reserved.
51.1Sperry# 
61.1Sperry# Redistribution and use in source and binary forms, with or without
71.1Sperry# modification, are permitted provided that the following conditions
81.1Sperry# are met:
91.1Sperry# 1. Redistributions of source code must retain the above copyright
101.1Sperry#    notice, this list of conditions and the following disclaimer.
111.1Sperry# 2. Redistributions in binary form must reproduce the above copyright
121.1Sperry#    notice, this list of conditions and the following disclaimer in the
131.1Sperry#    documentation and/or other materials provided with the distribution.
141.1Sperry# 3. All advertising materials mentioning features or use of this software
151.1Sperry#    must display the following acknowledgement:
161.6Scgd#          This product includes software developed for the
171.7Ssalo#          NetBSD Project.  See http://www.NetBSD.org/ for
181.6Scgd#          information about NetBSD.
191.1Sperry# 4. The name of the author may not be used to endorse or promote products
201.6Scgd#    derived from this software without specific prior written permission.
211.6Scgd# 
221.1Sperry# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
231.1Sperry# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
241.1Sperry# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
251.1Sperry# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
261.1Sperry# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
271.1Sperry# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
281.1Sperry# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
291.1Sperry# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
301.1Sperry# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
311.1Sperry# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
321.6Scgd# 
331.6Scgd# <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
341.1Sperry
351.1Sperry# Installation utilites (functions), to get NetBSD installed on
361.1Sperry# the hard disk.  These are meant to be invoked from the shell prompt,
371.1Sperry# by people installing NetBSD.
381.1Sperry
391.1Sperry# we know that /etc/fstab is only generated on the hard drive
401.1Sperrydest_dir=/
411.1Sperryif [ ! -f /etc/fstab ]; then
421.1Sperry	dest_dir=/mnt/
431.1Sperryfi
441.1Sperry
451.1Sperry# counter for possible shared library confusion
461.3SminouraPAX=/bin/pax
471.1SperryGUNZIP=/usr/bin/gunzip
481.1Sperry
491.1SperrySet_tmp_dir()
501.1Sperry{
511.1Sperry	def_tmp_dir=`pwd`
521.8Stsutsui	if [ "$def_tmp_dir" = "/" ] || [ "$def_tmp_dir" = "/mnt" ]; then
531.1Sperry		def_tmp_dir="$dest_dir"usr/distrib
541.1Sperry	fi
551.1Sperry
561.1Sperry	echo -n	"What directory should be used to find and/or store "
571.1Sperry	echo	"installtion"
581.4Sminoura	echo -n	"files such as base.tgz and kern.tgz? [$def_tmp_dir] "
591.1Sperry	read tmp_dir
601.1Sperry	if [ "$tmp_dir" = "" ]; then
611.1Sperry		tmp_dir=$def_tmp_dir
621.1Sperry	fi
631.1Sperry	if [ ! -d "$tmp_dir" ]; then
641.1Sperry		/bin/rm -rf $tmp_dir
651.1Sperry		mkdir -p $tmp_dir
661.1Sperry	fi
671.1Sperry}
681.1Sperry
691.1SperryTmp_dir()
701.1Sperry{
711.1Sperry	if [ "$tmp_dir" = "" ]; then
721.1Sperry		Set_tmp_dir
731.1Sperry	fi
741.1Sperry	cd $tmp_dir
751.1Sperry}
761.1Sperry
771.1SperryLoad_fd()
781.1Sperry{
791.1Sperry	Tmp_dir
801.1Sperry	which=
811.1Sperry#	echo "Don't forget that you can't load from the drive you booted from."
821.1Sperry	echo ""
831.1Sperry
841.8Stsutsui	while [ "$which" != "0" ] && [ "$which" != "1" ]; do
851.1Sperry		echo -n	"Read from which floppy drive ('0' or '1')? [0] "
861.1Sperry		read which
871.1Sperry		if [ "X$which" = "X" ]; then
881.1Sperry			which=0
891.1Sperry		fi
901.1Sperry	done
911.1Sperry	echo	""
921.1Sperry	echo	"WARNING: during the floppy loading process, you should only"
931.1Sperry	echo	"use Control-C at the prompt."
941.1Sperry	echo	""
951.1Sperry	while echo -n \
961.1Sperry	    "Insert floppy (hit Control-C to terminate, enter to load): "
971.1Sperry	do
981.1Sperry		read foo
991.1Sperry		mount -r -t msdos /dev/fd${which}a /mnt2
1001.1Sperry		cp -rp /mnt2/* .
1011.1Sperry		umount /mnt2
1021.1Sperry	done
1031.1Sperry}
1041.1Sperry
1051.1SperryLoad_tape()
1061.1Sperry{
1071.1Sperry	Tmp_dir
1081.1Sperry	echo -n	"Which tape drive will you be using? [rst0] "
1091.1Sperry	read which
1101.1Sperry	if [ "X$which" = "X" ]; then
1111.1Sperry		which=rst0
1121.1Sperry	fi
1131.1Sperry	echo -n "Insert the tape into the tape drive and hit return to "
1141.1Sperry	echo -n "continue..."
1151.1Sperry	read foo
1161.1Sperry	echo	"Extracting files from the tape..."
1171.3Sminoura	$PAX -rvpe -f /dev/$which
1181.1Sperry	echo	"Done."
1191.1Sperry}
1201.1Sperry
1211.1SperryExtract()
1221.1Sperry{
1231.1Sperry	Tmp_dir
1241.1Sperry	echo -n "Would you like to list the files as they're extracted? [n] "
1251.1Sperry	read verbose
1261.1Sperry	case $verbose in
1271.1Sperry	y*|Y*)
1281.3Sminoura		tarverbose=-v
1291.1Sperry		;;
1301.1Sperry	*)
1311.1Sperry		tarverbose=
1321.1Sperry		;;
1331.1Sperry	esac
1341.3Sminoura	cat "$1"* | $GUNZIP | (cd $dest_dir ; $PAX -rpe $tarverbose )
1351.1Sperry}
136