xref: /aosp_15_r20/external/mtools/scripts/download (revision d5c9a868b113e0ec0db2f27bc2ce8a253e77c4b0)
1*d5c9a868SElliott Hughes#!/bin/sh -
2*d5c9a868SElliott Hughes
3*d5c9a868SElliott Hughes# Copyright 1996 Carlos Duarte
4*d5c9a868SElliott Hughes# Copyright 1997,2001,2002 Alain Knaff.
5*d5c9a868SElliott Hughes# This file is part of mtools.
6*d5c9a868SElliott Hughes#
7*d5c9a868SElliott Hughes# Mtools is free software: you can redistribute it and/or modify
8*d5c9a868SElliott Hughes# it under the terms of the GNU General Public License as published by
9*d5c9a868SElliott Hughes# the Free Software Foundation, either version 3 of the License, or
10*d5c9a868SElliott Hughes# (at your option) any later version.
11*d5c9a868SElliott Hughes#
12*d5c9a868SElliott Hughes# Mtools is distributed in the hope that it will be useful,
13*d5c9a868SElliott Hughes# but WITHOUT ANY WARRANTY; without even the implied warranty of
14*d5c9a868SElliott Hughes# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*d5c9a868SElliott Hughes# GNU General Public License for more details.
16*d5c9a868SElliott Hughes#
17*d5c9a868SElliott Hughes# You should have received a copy of the GNU General Public License
18*d5c9a868SElliott Hughes# along with Mtools.  If not, see <http://www.gnu.org/licenses/>.
19*d5c9a868SElliott Hughes
20*d5c9a868SElliott Hughes
21*d5c9a868SElliott Hughes## (c) Carlos Duarte ## Created: 18-Dec-96 ## Updated: 18-Dec-96 ##
22*d5c9a868SElliott Hughes
23*d5c9a868SElliott Hughes# main
24*d5c9a868SElliott Hughes
25*d5c9a868SElliott HughesFAKE=
26*d5c9a868SElliott HughesDRIVE=a
27*d5c9a868SElliott HughesTOGGLE=0
28*d5c9a868SElliott HughesMDEL=:
29*d5c9a868SElliott Hugheswhile [ "$1" ]
30*d5c9a868SElliott Hughesdo
31*d5c9a868SElliott Hughes	case `echo z$1|cut -c2-` in
32*d5c9a868SElliott Hughes	-n) 	FAKE=echo ;;
33*d5c9a868SElliott Hughes	-d)	DRIVE=`echo $1|cut -c3-`
34*d5c9a868SElliott Hughes		[ "$DRIVE" = "" ] && {
35*d5c9a868SElliott Hughes			shift
36*d5c9a868SElliott Hughes			DRIVE=$1
37*d5c9a868SElliott Hughes			[ "$DRIVE" = "" ] && break
38*d5c9a868SElliott Hughes		} ;;
39*d5c9a868SElliott Hughes	-t)	TOGGLE=1 ;;
40*d5c9a868SElliott Hughes	-rm)	MDEL=mdel ;;
41*d5c9a868SElliott Hughes	*)	break ;;
42*d5c9a868SElliott Hughes	esac
43*d5c9a868SElliott Hughes	shift
44*d5c9a868SElliott Hughesdone
45*d5c9a868SElliott Hughes
46*d5c9a868SElliott Hughesif [ $# -ne 1 ] ; then
47*d5c9a868SElliott Hughes	echo "usage: $0 [-n] [-d drive] [-rm] [-t] <ndisks>"
48*d5c9a868SElliott Hughes	exit 1
49*d5c9a868SElliott Hughesfi
50*d5c9a868SElliott Hughes
51*d5c9a868SElliott Hughesndisks=$1
52*d5c9a868SElliott Hughesn=0
53*d5c9a868SElliott Hughesdir=1
54*d5c9a868SElliott Hughes
55*d5c9a868SElliott Hugheswhile test $n -lt $ndisks
56*d5c9a868SElliott Hughesdo
57*d5c9a868SElliott Hughes
58*d5c9a868SElliott Hughes	while [ -d $dir ]
59*d5c9a868SElliott Hughes	do
60*d5c9a868SElliott Hughes		dir=`expr $dir + 1`
61*d5c9a868SElliott Hughes	done
62*d5c9a868SElliott Hughes
63*d5c9a868SElliott Hughes	$FAKE mkdir $dir
64*d5c9a868SElliott Hughes	$FAKE mcopy $DRIVE:\* $dir && $FAKE $MDEL $DRIVE:\*
65*d5c9a868SElliott Hughes
66*d5c9a868SElliott Hughes	if [ "$TOGGLE" = "1" ] ; then
67*d5c9a868SElliott Hughes		if [ "$DRIVE" = "a" ] ; then
68*d5c9a868SElliott Hughes			DRIVE=b
69*d5c9a868SElliott Hughes		else
70*d5c9a868SElliott Hughes			DRIVE=a
71*d5c9a868SElliott Hughes		fi
72*d5c9a868SElliott Hughes	else
73*d5c9a868SElliott Hughes		echo Replace disk and press return
74*d5c9a868SElliott Hughes		read ans
75*d5c9a868SElliott Hughes	fi
76*d5c9a868SElliott Hughes
77*d5c9a868SElliott Hughes	n=`expr $n + 1`
78*d5c9a868SElliott Hughes	dir=`expr $dir + 1`
79*d5c9a868SElliott Hughesdone
80*d5c9a868SElliott Hughes
81*d5c9a868SElliott Hughesexit 0
82