summaryrefslogtreecommitdiffstats
path: root/release/bininst
blob: 9a16ea4b67beed923247c37f0ad1de1aa8556f02 (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
#!/stand/sh
#
# bininst - perform the last stage of installation by somehow getting
# a bindist onto the user's disk and unpacking it.  The name bininst
# is actually something of a misnomer, since this utility will install
# more than just the bindist set.
#
# November 11th, 1994
# Copyright (C) 1994 by Jordan K. Hubbard
#
# Permission to copy or use this software for any purpose is granted
# provided that this message stay intact, and at this location (no putting
# your name on top after doing something trivial like reindenting it, just
# to make it look like you wrote it!).
#

# Some useful constants.
PATH=/usr/bin:/usr/sbin:/bin:/sbin:/stand
export PATH
TAR=tar
TAR_FLAGS=xvf
TMP=/tmp

set_defaults() {
	media_type="" ;
	media_device="" ;
	tmp_dir="/usr/tmp" ;
	installing=1 ;
	mkdir -p ${TMP}
}

handle_rval() {
	case $1 in
	0)
		return 0
	;;
	255)
		echo "User aborted installation, invoking shell.";
		exec /stand/sh
	;;
	*)
		return 1
	;;
	esac
}

confirm() {
	dialog --title "Please Confirm" --msgbox "$*" 10 72
}

error() {
	dialog --title "Error!" --msgbox "$*" 10 72
}

not_supported() {
	dialog --title "Sorry!" \
        --msgbox "This feature is not supported in the current version of the \
installation tools but will be in the release, barring \
some sort of fatal accident.  Please press RETURN to go on." 10 60
}

welcome() {
	dialog --title "Welcome to FreeBSD" --clear \
--msgbox "Hi!  Nice to see you've made it this far.  We're now ready to
install one or more packed distribution sets onto your machine.
At the minimum, you need a bindist installation though a
secrdist is also useful if you want your system to have any kind
of effective security.  The secrdist is a bit of a special case
since it cannot be legally obtained from the U.S. due to export
restrictions, but non-U.S. versions are also available.  See the
release notes for more information on where to obtain a secrdist
for your part of the world." 15 72
	if ! handle_rval $?; then return 1; fi
}

choose_media() {
	while [ "$media_device" = "" ]; do

	dialog --clear --title "Chose installation media" \
--menu "Before we begin the installation, we need to chose and possibly \n\
configure your method of installation.  Please pick from one of \n\
the following options.  If your option isn't listed here, your \n\
best bet may be to simply select CANCEL to get a shell and proceed \n\
manually on your own. \n\n\
	Please choose one of the following:" 20 72 5 \
	"Tape" "Load installation from SCSI or QIC tape" \
	"CDROM" "Load installation from SCSI or Mitsumi CDROM" \
        "DOS" "Load from DOS floppies or a DOS hard disk partition" \
        "FTP" "Load the distribution over ftp" \
        "NFS" "Load the distribution over NFS" 2> ${TMP}/menu.tmp.$$

	retval=$?
	choice=`cat ${TMP}/menu.tmp.$$`
	rm -f ${TMP}/menu.tmp.$$
	if ! handle_rval $retval; then return 1; fi

	case $choice in
	Tape)
		dialog --clear --title "Chose tape type" \
--menu "Which type of tape drive do you have attached to your \n\
system?  FreeBSD supports the following types:\n\n\
		Choose one of the following:" 20 72 2 \
		"SCSI" "SCSI tape drive attached to standard SCSI controller" \
		"QIC" "QIC tape drive (Colorado Jumbo, etc)" \
			2> ${TMP}/menu.tmp.$$
		retval=$?
		choice=`cat ${TMP}/menu.tmp.$$`
		rm -f ${TMP}/menu.tmp.$$
		if ! handle_rval $retval; then continue; fi
		media_type=tape;
		case $choice in
			SCSI)
				media_device=/dev/rst0
			;;
			QIC)
				media_device=/dev/rwt0
			;;
		esac
	;;
	CDROM)
		dialog --clear --title "Chose CDROM type" \
--menu "Which type of CDROM drive do you have attached to your \n\
system?  FreeBSD supports the following types:\n\n\
		Choose one of the following:" 15 72 2 \
		"SCSI" "SCSI CDROM drive attached to standard SCSI controller" \
		"Mitsumi" "Mitsumi CDROM drive" \
			2> ${TMP}/menu.tmp.$$
		retval=$?
		choice=`cat ${TMP}/menu.tmp.$$`
		rm -f ${TMP}/menu.tmp.$$
		if ! handle_rval $retval; then continue; fi
		media_type=cdrom;
		case $choice in
			SCSI)
				media_device=/dev/cd0d
			;;
			Mitsumi)
				media_device=/dev/mcd0d
			;;
		esac
	;;
	DOS)
		not_supported
	;;
	FTP)
		dialog --title "FTP Installation Information" --clear \
--inputbox "Please specify the machine and directory location of the
distribution you wish to load.  This should be either a \"URL style\"
specification (e.g. something like ftp://ftp.freeBSD.org/pub/...) or
simply the name of a host to connect to.  If only a host name is
specified, the installation assumes that you will properly connect
and \"mget\" the files yourself.\n\n" \
16 72 "ftp://ftp.freebsd.org/pub/FreeBSD/2.0-ALPHA/bindist/" 2> ${TMP}/inputbox.tmp.$$
		if ! handle_rval $?; then continue; fi
		media_type=ftp
		media_device=`cat ${TMP}/inputbox.tmp.$$`
	;;
	NFS)
		not_supported
	;;
	esac
	done
}

set_tmpdir()
{
	dialog --title "Chose temporary directory" --clear \
--inputbox "Please specify the name of a directory containing enough
free space to hold the temporary files for this distribution.
At minimum, a binary distribution will require around 10MB.
At maximum, a srcdist may take 60MB or more.  If the directory
you specify does not exist, it will be created for you.\n\n" \
16 72 "/usr${TMP}" 2> ${TMP}/inputbox.tmp.$$
		if ! handle_rval $?; then continue; fi
	tmp_dir=`cat ${TMP}/inputbox.tmp.$$`
	mkdir -p $tmp_dir
	return 0
}

cd_tmpdir()
{
	if ! cd $tmp_dir 2> /dev/null; then
		error "No such file or directory for ${tmp_dir}, sorry!  Please fix this and try again."
		return
	fi
	return 0
}

rm_tmpdir()
{
	if dialog --title "Delete contents?" --clear \
        --yesno "Do you wish to delete the contents of ${tmp_dir}?" 5 72; then
		rm -rf $tmp_dir/*
	fi
}

install_set()
{
	case $media_type in
	tape)
		if ! set_tmpdir; then return 1; fi
		if ! cd_tmpdir; then return 1; fi
		confirm "Please mount tape for ${media_device}."
		dialog --title "Extract from tape" --clear \
			--prgbox "$TAR $TAR_FLAGS $media_device" 10 72
		if [ -f extract.sh ]; then
			sh ./extract.sh
		else
			error "This isn't a proper distribution.  No installation script found."
		fi
		rm_tmpdir
	;;

	cdrom)
		not_supported
		return
	;;

	dos)
		if ! set_tmpdir; then return 1; fi
		if ! cd_tmpdir; then return 1; fi
		not_supported
		return
	;;
	ftp)
		if ! set_tmpdir; then return 1; fi
		if ! cd_tmpdir; then return 1; fi
		if ! echo $media_device | grep -v 'ftp://'; then
			if ! ncftp $media_device/* 2>/dev/null; then
				error "Couldn't fetch distribution from ${media_device}!"
			else
				if [ -f extract.sh ]; then
					sh ./extract.sh
				else
					error "This isn't a proper distribution.  No installation script found."
				fi
			fi
		else
			ftp $media_device
			if [ -f extract.sh ]; then
				sh ./extract.sh
			else
				error "No installation script found.  Please grab the right bits."
			fi
		fi
		rm_tmpdir
		return
	;;

	nfs)
		not_supported
		return
	;;
	esac
}

welcome
set_defaults

while [ $installing -eq 1 ]; do
	if choose_media; then
		install_set
		media_device=""; media_type=""
	else
		confirm "Exiting per user request.";
		installing=0
	fi
done
OpenPOWER on IntegriCloud