dot.commonutils revision 1.3
11.3Sminoura#	$NetBSD: dot.commonutils,v 1.3 1999/03/26 09:24:27 minoura 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.1Sperry#	This product includes software developed by Christopher G. Demetriou.
171.1Sperry# 4. The name of the author may not be used to endorse or promote products
181.1Sperry#    derived from this software without specific prior written permission
191.1Sperry#
201.1Sperry# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
211.1Sperry# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
221.1Sperry# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
231.1Sperry# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
241.1Sperry# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
251.1Sperry# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
261.1Sperry# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
271.1Sperry# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
281.1Sperry# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
291.1Sperry# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
301.1Sperry#
311.1Sperry
321.1Sperry# Installation utilites (functions), to get NetBSD installed on
331.1Sperry# the hard disk.  These are meant to be invoked from the shell prompt,
341.1Sperry# by people installing NetBSD.
351.1Sperry
361.1Sperry# we know that /etc/fstab is only generated on the hard drive
371.1Sperrydest_dir=/
381.1Sperryif [ ! -f /etc/fstab ]; then
391.1Sperry	dest_dir=/mnt/
401.1Sperryfi
411.1Sperry
421.1Sperry# counter for possible shared library confusion
431.3SminouraPAX=/bin/pax
441.1SperryGUNZIP=/usr/bin/gunzip
451.1Sperry
461.1SperrySet_tmp_dir()
471.1Sperry{
481.1Sperry	def_tmp_dir=`pwd`
491.1Sperry	if [ "$def_tmp_dir" = "/" -o "$def_tmp_dir" = "/mnt" ]; then
501.1Sperry		def_tmp_dir="$dest_dir"usr/distrib
511.1Sperry	fi
521.1Sperry
531.1Sperry	echo -n	"What directory should be used to find and/or store "
541.1Sperry	echo	"installtion"
551.1Sperry	echo -n	"files? [$def_tmp_dir] "
561.1Sperry	read tmp_dir
571.1Sperry	if [ "$tmp_dir" = "" ]; then
581.1Sperry		tmp_dir=$def_tmp_dir
591.1Sperry	fi
601.1Sperry	if [ ! -d "$tmp_dir" ]; then
611.1Sperry		/bin/rm -rf $tmp_dir
621.1Sperry		mkdir -p $tmp_dir
631.1Sperry	fi
641.1Sperry}
651.1Sperry
661.1SperryTmp_dir()
671.1Sperry{
681.1Sperry	if [ "$tmp_dir" = "" ]; then
691.1Sperry		Set_tmp_dir
701.1Sperry	fi
711.1Sperry	cd $tmp_dir
721.1Sperry}
731.1Sperry
741.1SperryLoad_fd()
751.1Sperry{
761.1Sperry	Tmp_dir
771.1Sperry	which=
781.1Sperry#	echo "Don't forget that you can't load from the drive you booted from."
791.1Sperry	echo ""
801.1Sperry
811.1Sperry	while [ "$which" != "0" -a "$which" != "1" ]; do
821.1Sperry		echo -n	"Read from which floppy drive ('0' or '1')? [0] "
831.1Sperry		read which
841.1Sperry		if [ "X$which" = "X" ]; then
851.1Sperry			which=0
861.1Sperry		fi
871.1Sperry	done
881.1Sperry	echo	""
891.1Sperry	echo	"WARNING: during the floppy loading process, you should only"
901.1Sperry	echo	"use Control-C at the prompt."
911.1Sperry	echo	""
921.1Sperry	while echo -n \
931.1Sperry	    "Insert floppy (hit Control-C to terminate, enter to load): "
941.1Sperry	do
951.1Sperry		read foo
961.1Sperry		mount -r -t msdos /dev/fd${which}a /mnt2
971.1Sperry		cp -rp /mnt2/* .
981.1Sperry		umount /mnt2
991.1Sperry	done
1001.1Sperry}
1011.1Sperry
1021.1SperryLoad_tape()
1031.1Sperry{
1041.1Sperry	Tmp_dir
1051.1Sperry	echo -n	"Which tape drive will you be using? [rst0] "
1061.1Sperry	read which
1071.1Sperry	if [ "X$which" = "X" ]; then
1081.1Sperry		which=rst0
1091.1Sperry	fi
1101.1Sperry	echo -n "Insert the tape into the tape drive and hit return to "
1111.1Sperry	echo -n "continue..."
1121.1Sperry	read foo
1131.1Sperry	echo	"Extracting files from the tape..."
1141.3Sminoura	$PAX -rvpe -f /dev/$which
1151.1Sperry	echo	"Done."
1161.1Sperry}
1171.1Sperry
1181.1SperryExtract()
1191.1Sperry{
1201.1Sperry	Tmp_dir
1211.1Sperry	echo -n "Would you like to list the files as they're extracted? [n] "
1221.1Sperry	read verbose
1231.1Sperry	case $verbose in
1241.1Sperry	y*|Y*)
1251.3Sminoura		tarverbose=-v
1261.1Sperry		;;
1271.1Sperry	*)
1281.1Sperry		tarverbose=
1291.1Sperry		;;
1301.1Sperry	esac
1311.3Sminoura	cat "$1"* | $GUNZIP | (cd $dest_dir ; $PAX -rpe $tarverbose )
1321.1Sperry}
133