summaryrefslogtreecommitdiff
path: root/scripts/download
blob: 142eb9931b433c042aa1a0dc569bcc611289233e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/sh - 

# Copyright 1996 Carlos Duarte
# Copyright 1997,2001,2002 Alain Knaff.
# This file is part of mtools.
#
# Mtools is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Mtools is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Mtools.  If not, see <http://www.gnu.org/licenses/>.


## (c) Carlos Duarte ## Created: 18-Dec-96 ## Updated: 18-Dec-96 ##

# main

FAKE=
DRIVE=a
TOGGLE=0
MDEL=:
while [ "$1" ]
do
	case `echo z$1|cut -c2-` in 
	-n) 	FAKE=echo ;; 
	-d)	DRIVE=`echo $1|cut -c3-`
		[ "$DRIVE" = "" ] && {
			shift
			DRIVE=$1
			[ "$DRIVE" = "" ] && break
		} ;; 
	-t)	TOGGLE=1 ;;
	-rm)	MDEL=mdel ;;
	*)	break ;;
	esac
	shift
done

if [ $# -ne 1 ] ; then
	echo "usage: $0 [-n] [-d drive] [-rm] [-t] <ndisks>"
	exit 1
fi

ndisks=$1
n=0
dir=1

while test $n -lt $ndisks
do

	while [ -d $dir ]
	do
		dir=`expr $dir + 1`
	done

	$FAKE mkdir $dir
	$FAKE mcopy $DRIVE:\* $dir && $FAKE $MDEL $DRIVE:\*

	if [ "$TOGGLE" = "1" ] ; then
		if [ "$DRIVE" = "a" ] ; then
			DRIVE=b
		else
			DRIVE=a
		fi
	else
		echo Replace disk and press return
		read ans
	fi

	n=`expr $n + 1`
	dir=`expr $dir + 1`
done

exit 0