dot.commonutils revision 1.1
11.10Schristos#	$NetBSD: dot.commonutils,v 1.1 1997/06/14 18:56:08 perry Exp $
21.5Scgd#
31.1Scgd# Copyright (c) 1994 Christopher G. Demetriou
41.6Scgd# All rights reserved.
51.1Scgd# 
61.1Scgd# Redistribution and use in source and binary forms, with or without
71.1Scgd# modification, are permitted provided that the following conditions
81.1Scgd# are met:
91.1Scgd# 1. Redistributions of source code must retain the above copyright
101.1Scgd#    notice, this list of conditions and the following disclaimer.
111.1Scgd# 2. Redistributions in binary form must reproduce the above copyright
121.1Scgd#    notice, this list of conditions and the following disclaimer in the
131.1Scgd#    documentation and/or other materials provided with the distribution.
141.1Scgd# 3. All advertising materials mentioning features or use of this software
151.9Sagc#    must display the following acknowledgement:
161.1Scgd#	This product includes software developed by Christopher G. Demetriou.
171.1Scgd# 4. The name of the author may not be used to endorse or promote products
181.1Scgd#    derived from this software without specific prior written permission
191.1Scgd#
201.1Scgd# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
211.1Scgd# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
221.1Scgd# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
231.1Scgd# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
241.1Scgd# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
251.1Scgd# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
261.1Scgd# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
271.1Scgd# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
281.1Scgd# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
291.1Scgd# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
301.1Scgd#
311.6Scgd
321.1Scgd# Installation utilites (functions), to get NetBSD installed on
331.1Scgd# the hard disk.  These are meant to be invoked from the shell prompt,
341.7Schristos# by people installing NetBSD.
351.7Schristos
361.10Schristos# we know that /etc/fstab is only generated on the hard drive
371.10Schristosdest_dir=/
381.10Schristosif [ ! -f /etc/fstab ]; then
391.10Schristos	dest_dir=/mnt/
401.10Schristosfi
411.10Schristos
421.10Schristos# counter for possible shared library confusion
431.10SchristosTAR=/usr/bin/tar
441.10SchristosGUNZIP=/usr/bin/gunzip
451.10Schristos
461.10SchristosSet_tmp_dir()
471.10Schristos{
481.10Schristos	def_tmp_dir=`pwd`
491.10Schristos	if [ "$def_tmp_dir" = "/" -o "$def_tmp_dir" = "/mnt" ]; then
501.10Schristos		def_tmp_dir="$dest_dir"usr/distrib
511.10Schristos	fi
521.10Schristos
531.10Schristos	echo -n	"What directory should be used to find and/or store "
541.10Schristos	echo	"installtion"
551.10Schristos	echo -n	"files? [$def_tmp_dir] "
561.10Schristos	read tmp_dir
571.10Schristos	if [ "$tmp_dir" = "" ]; then
581.1Scgd		tmp_dir=$def_tmp_dir
591.10Schristos	fi
601.10Schristos	if [ ! -d "$tmp_dir" ]; then
611.10Schristos		/bin/rm -rf $tmp_dir
621.1Scgd		mkdir -p $tmp_dir
631.1Scgd	fi
641.10Schristos}
651.10Schristos
661.10SchristosTmp_dir()
671.10Schristos{
681.1Scgd	if [ "$tmp_dir" = "" ]; then
691.1Scgd		Set_tmp_dir
701.10Schristos	fi
711.1Scgd	cd $tmp_dir
721.7Schristos}
73
74Load_fd()
75{
76	Tmp_dir
77	which=
78#	echo "Don't forget that you can't load from the drive you booted from."
79	echo ""
80
81	while [ "$which" != "0" -a "$which" != "1" ]; do
82		echo -n	"Read from which floppy drive ('0' or '1')? [0] "
83		read which
84		if [ "X$which" = "X" ]; then
85			which=0
86		fi
87	done
88	echo	""
89	echo	"WARNING: during the floppy loading process, you should only"
90	echo	"use Control-C at the prompt."
91	echo	""
92	while echo -n \
93	    "Insert floppy (hit Control-C to terminate, enter to load): "
94	do
95		read foo
96		mount -r -t msdos /dev/fd${which}a /mnt2
97		cp -rp /mnt2/* .
98		umount /mnt2
99	done
100}
101
102Load_tape()
103{
104	Tmp_dir
105	echo -n	"Which tape drive will you be using? [rst0] "
106	read which
107	if [ "X$which" = "X" ]; then
108		which=rst0
109	fi
110	echo -n "Insert the tape into the tape drive and hit return to "
111	echo -n "continue..."
112	read foo
113	echo	"Extracting files from the tape..."
114	$TAR --unlink -xvpf /dev/$which
115	echo	"Done."
116}
117
118Extract()
119{
120	Tmp_dir
121	echo -n "Would you like to list the files as they're extracted? [n] "
122	read verbose
123	case $verbose in
124	y*|Y*)
125		tarverbose=v
126		;;
127	*)
128		tarverbose=
129		;;
130	esac
131	cat "$1"* | $GUNZIP | (cd $dest_dir ; $TAR  --unlink -xp"$tarverbose"f - )
132}
133