xref: /freebsd/usr.sbin/bsdinstall/scripts/mirrorselect (revision ca987d4641cdcd7f27e153db17c5bf064934faf5)
1#!/bin/sh
2#-
3# Copyright (c) 2011 Nathan Whitehorn
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9# 1. Redistributions of source code must retain the above copyright
10#    notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright
12#    notice, this list of conditions and the following disclaimer in the
13#    documentation and/or other materials provided with the distribution.
14#
15# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25# SUCH DAMAGE.
26#
27# $FreeBSD$
28
29: ${DIALOG_OK=0}
30: ${DIALOG_CANCEL=1}
31: ${DIALOG_HELP=2}
32: ${DIALOG_EXTRA=3}
33: ${DIALOG_ITEM_HELP=4}
34: ${DIALOG_ESC=255}
35
36exec 3>&1
37MIRROR=`dialog --backtitle "FreeBSD Installer" \
38    --title "Mirror Selection" --extra-button --extra-label "Other" \
39    --menu "Please select the site closest to you or \"other\" if you'd like to specify a different choice.  Also note that not every site listed here carries more than the base distribution kits. Only Primary sites are guaranteed to carry the full range of possible distributions. Select a site that's close!" \
40    0 0 0 \
41	ftp://ftp.freebsd.org	"Main Site"\
42	ftp://ftp.freebsd.org 	"IPv6 Main Site"\
43	ftp://ftp3.ie.freebsd.org 	"IPv6 Ireland"\
44	ftp://ftp2.jp.freebsd.org 	"IPv6 Japan"\
45	ftp://ftp4.se.freebsd.org	"IPv6 Sweden"\
46	ftp://ftp4.us.freebsd.org 	"IPv6 USA"\
47	ftp://ftp2.tr.freebsd.org 	"IPv6 Turkey"\
48	ftp://ftp1.freebsd.org 	"Primary"\
49	ftp://ftp2.freebsd.org 	"Primary #2"\
50	ftp://ftp3.freebsd.org 	"Primary #3"\
51	ftp://ftp4.freebsd.org 	"Primary #4"\
52	ftp://ftp5.freebsd.org 	"Primary #5"\
53	ftp://ftp6.freebsd.org 	"Primary #6"\
54	ftp://ftp7.freebsd.org 	"Primary #7"\
55	ftp://ftp10.freebsd.org 	"Primary #10"\
56	ftp://ftp11.freebsd.org 	"Primary #11"\
57	ftp://ftp12.freebsd.org 	"Primary #12"\
58	ftp://ftp13.freebsd.org 	"Primary #13"\
59	ftp://ftp14.freebsd.org 	"Primary #14"\
60	ftp://ftp1.am.freebsd.org 	"Armenia"\
61	ftp://ftp.au.freebsd.org 	"Australia"\
62	ftp://ftp2.au.freebsd.org 	"Australia #2"\
63	ftp://ftp3.au.freebsd.org 	"Australia #3"\
64	ftp://ftp.at.freebsd.org 	"Austria"\
65	ftp://ftp2.br.freebsd.org 	"Brazil #2"\
66	ftp://ftp3.br.freebsd.org 	"Brazil #3"\
67	ftp://ftp4.br.freebsd.org 	"Brazil #4"\
68	ftp://ftp.ca.freebsd.org 	"Canada"\
69	ftp://ftp.cn.freebsd.org 	"China"\
70	ftp://ftp.cz.freebsd.org 	"Czech Republic"\
71	ftp://ftp.dk.freebsd.org 	"Denmark"\
72	ftp://ftp.ee.freebsd.org 	"Estonia"\
73	ftp://ftp.fi.freebsd.org 	"Finland"\
74	ftp://ftp.fr.freebsd.org 	"France"\
75	ftp://ftp3.fr.freebsd.org 	"France #3"\
76	ftp://ftp4.fr.freebsd.org 	"IPv6 France #4"\
77	ftp://ftp5.fr.freebsd.org 	"France #5"\
78	ftp://ftp6.fr.freebsd.org 	"France #6"\
79	ftp://ftp7.fr.freebsd.org 	"France #7"\
80	ftp://ftp8.fr.freebsd.org 	"IPv6 France #8"\
81	ftp://ftp.de.freebsd.org 	"Germany"\
82	ftp://ftp2.de.freebsd.org 	"Germany #2"\
83	ftp://ftp4.de.freebsd.org 	"Germany #4"\
84	ftp://ftp5.de.freebsd.org 	"Germany #5"\
85	ftp://ftp6.de.freebsd.org 	"Germany #6"\
86	ftp://ftp7.de.freebsd.org 	"Germany #7"\
87	ftp://ftp8.de.freebsd.org 	"Germany #8"\
88	ftp://ftp.gr.freebsd.org 	"Greece"\
89	ftp://ftp2.gr.freebsd.org 	"Greece #2"\
90	ftp://ftp3.ie.freebsd.org 	"Ireland #3"\
91	ftp://ftp.il.freebsd.org 	"Israel"\
92	ftp://ftp.it.freebsd.org 	"Italy"\
93	ftp://ftp.jp.freebsd.org 	"Japan"\
94	ftp://ftp2.jp.freebsd.org 	"Japan #2"\
95	ftp://ftp3.jp.freebsd.org 	"Japan #3"\
96	ftp://ftp4.jp.freebsd.org 	"Japan #4"\
97	ftp://ftp5.jp.freebsd.org 	"Japan #5"\
98	ftp://ftp6.jp.freebsd.org 	"Japan #6"\
99	ftp://ftp7.jp.freebsd.org 	"Japan #7"\
100	ftp://ftp8.jp.freebsd.org 	"Japan #8"\
101	ftp://ftp9.jp.freebsd.org 	"Japan #9"\
102	ftp://ftp.kr.freebsd.org 	"Korea"\
103	ftp://ftp2.kr.freebsd.org 	"Korea #2"\
104	ftp://ftp.lv.freebsd.org 	"Latvia"\
105	ftp://ftp.lt.freebsd.org 	"Lithuania"\
106	ftp://ftp.nl.freebsd.org 	"Netherlands"\
107	ftp://ftp2.nl.freebsd.org 	"Netherlands #2"\
108	ftp://ftp.nz.freebsd.org 	"New Zealand"\
109	ftp://ftp.no.freebsd.org 	"Norway"\
110	ftp://ftp.pl.freebsd.org 	"Poland"\
111	ftp://ftp2.pl.freebsd.org 	"Poland #2"\
112	ftp://ftp.ru.freebsd.org 	"Russia"\
113	ftp://ftp2.ru.freebsd.org 	"Russia #2"\
114	ftp://ftp4.ru.freebsd.org 	"Russia #4"\
115	ftp://ftp5.ru.freebsd.org 	"Russia #5"\
116	ftp://ftp6.ru.freebsd.org 	"Russia #6"\
117	ftp://ftp.sk.freebsd.org 	"Slovak Republic"\
118	ftp://ftp2.sk.freebsd.org 	"Slovak Republic #2"\
119	ftp://ftp.si.freebsd.org 	"Slovenia"\
120	ftp://ftp.za.freebsd.org 	"South Africa"\
121	ftp://ftp2.za.freebsd.org 	"South Africa #2"\
122	ftp://ftp4.za.freebsd.org 	"South Africa #4"\
123	ftp://ftp.es.freebsd.org 	"Spain"\
124	ftp://ftp3.es.freebsd.org 	"Spain #3"\
125	ftp://ftp.se.freebsd.org 	"Sweden"\
126	ftp://ftp2.se.freebsd.org 	"Sweden #2"\
127	ftp://ftp3.se.freebsd.org 	"Sweden #3"\
128	ftp://ftp4.se.freebsd.org 	"Sweden #4"\
129	ftp://ftp6.se.freebsd.org 	"Sweden #6"\
130	ftp://ftp.ch.freebsd.org 	"Switzerland"\
131	ftp://ftp.tw.freebsd.org 	"Taiwan"\
132	ftp://ftp2.tw.freebsd.org 	"Taiwan #2"\
133	ftp://ftp3.tw.freebsd.org 	"Taiwan #3"\
134	ftp://ftp4.tw.freebsd.org 	"Taiwan #4"\
135	ftp://ftp6.tw.freebsd.org 	"Taiwan #6"\
136	ftp://ftp11.tw.freebsd.org 	"Taiwan #11"\
137	ftp://ftp.uk.freebsd.org 	"UK"\
138	ftp://ftp2.uk.freebsd.org 	"UK #2"\
139	ftp://ftp3.uk.freebsd.org 	"UK #3"\
140	ftp://ftp4.uk.freebsd.org 	"UK #4"\
141	ftp://ftp5.uk.freebsd.org 	"UK #5"\
142	ftp://ftp.ua.freebsd.org 	"Ukraine"\
143	ftp://ftp7.ua.freebsd.org 	"Ukraine #7"\
144	ftp://ftp1.us.freebsd.org 	"USA #1"\
145	ftp://ftp2.us.freebsd.org 	"USA #2"\
146	ftp://ftp3.us.freebsd.org 	"USA #3"\
147	ftp://ftp4.us.freebsd.org 	"USA #4"\
148	ftp://ftp5.us.freebsd.org 	"USA #5"\
149	ftp://ftp6.us.freebsd.org 	"USA #6"\
150	ftp://ftp8.us.freebsd.org 	"USA #8"\
151	ftp://ftp10.us.freebsd.org 	"USA #10"\
152	ftp://ftp11.us.freebsd.org 	"USA #11"\
153	ftp://ftp13.us.freebsd.org 	"USA #13"\
154	ftp://ftp14.us.freebsd.org 	"USA #14"\
155	ftp://ftp15.us.freebsd.org 	"USA #15"\
156    2>&1 1>&3`
157MIRROR_BUTTON=$?
158exec 3>&-
159
160_UNAME_R=`uname -r`
161_UNAME_R=${_UNAME_R%-p*}
162
163case ${_UNAME_R} in
164	*-CURRENT|*-STABLE|*-PRERELEASE)
165		RELDIR="snapshots"
166		;;
167	*)
168		RELDIR="releases"
169		;;
170esac
171
172BSDINSTALL_DISTSITE="$MIRROR/pub/FreeBSD/${RELDIR}/`uname -m`/`uname -p`/${_UNAME_R}"
173
174case $MIRROR_BUTTON in
175$DIALOG_CANCEL)
176	exit 1
177	;;
178$DIALOG_OK)
179	;;
180$DIALOG_EXTRA)
181	exec 3>&1
182	BSDINSTALL_DISTSITE=`dialog --backtitle "FreeBSD Installer" \
183	    --title "Mirror Selection" \
184	    --inputbox "Please enter the URL to an alternate FreeBSD mirror:" \
185	    0 0 "$BSDINSTALL_DISTSITE" 2>&1 1>&3`
186	MIRROR_BUTTON=$?
187	exec 3>&-
188	test $MIRROR_BUTTON -eq 0 || exec $0 $@
189	;;
190esac
191
192export BSDINSTALL_DISTSITE
193echo $BSDINSTALL_DISTSITE >&2
194