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
29BSDCFG_SHARE="/usr/share/bsdconfig"
30. $BSDCFG_SHARE/common.subr || exit 1
31
32: ${BSDDIALOG_OK=0}
33: ${BSDDIALOG_CANCEL=1}
34: ${BSDDIALOG_HELP=2}
35: ${BSDDIALOG_EXTRA=3}
36: ${BSDDIALOG_ESC=5}
37: ${BSDDIALOG_ERROR=255}
38
39exec 3>&1
40MIRROR=`bsddialog --backtitle "$OSNAME Installer" \
41    --title "Mirror Selection" --extra-button --extra-label "Other" \
42    --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!" \
43    0 0 16 \
44	ftp://ftp.freebsd.org	"Main Site"\
45	ftp://ftp.freebsd.org 	"IPv6 Main Site"\
46	ftp://ftp3.ie.freebsd.org 	"IPv6 Ireland"\
47	ftp://ftp2.jp.freebsd.org 	"IPv6 Japan"\
48	ftp://ftp4.se.freebsd.org	"IPv6 Sweden"\
49	ftp://ftp4.us.freebsd.org 	"IPv6 USA"\
50	ftp://ftp1.freebsd.org 	"Primary"\
51	ftp://ftp2.freebsd.org 	"Primary #2"\
52	ftp://ftp3.freebsd.org 	"Primary #3"\
53	ftp://ftp4.freebsd.org 	"Primary #4"\
54	ftp://ftp5.freebsd.org 	"Primary #5"\
55	ftp://ftp6.freebsd.org 	"Primary #6"\
56	ftp://ftp7.freebsd.org 	"Primary #7"\
57	ftp://ftp10.freebsd.org 	"Primary #10"\
58	ftp://ftp11.freebsd.org 	"Primary #11"\
59	ftp://ftp12.freebsd.org 	"Primary #12"\
60	ftp://ftp13.freebsd.org 	"Primary #13"\
61	ftp://ftp14.freebsd.org 	"Primary #14"\
62	ftp://ftp.au.freebsd.org 	"Australia"\
63	ftp://ftp2.au.freebsd.org 	"Australia #2"\
64	ftp://ftp3.au.freebsd.org 	"Australia #3"\
65	ftp://ftp.at.freebsd.org 	"Austria"\
66	ftp://ftp2.br.freebsd.org 	"Brazil #2"\
67	ftp://ftp3.br.freebsd.org 	"Brazil #3"\
68	ftp://ftp4.br.freebsd.org 	"Brazil #4"\
69	ftp://ftp.bg.freebsd.org 	"Bulgaria"\
70	ftp://ftp.cn.freebsd.org 	"China"\
71	ftp://ftp.cz.freebsd.org 	"Czech Republic"\
72	ftp://ftp.dk.freebsd.org 	"Denmark"\
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://ftp7.de.freebsd.org 	"Germany #7"\
86	ftp://ftp8.de.freebsd.org 	"Germany #8"\
87	ftp://ftp.gr.freebsd.org 	"Greece"\
88	ftp://ftp2.gr.freebsd.org 	"Greece #2"\
89	ftp://ftp3.ie.freebsd.org 	"Ireland #3"\
90	ftp://ftp.jp.freebsd.org 	"Japan"\
91	ftp://ftp2.jp.freebsd.org 	"Japan #2"\
92	ftp://ftp3.jp.freebsd.org 	"Japan #3"\
93	ftp://ftp4.jp.freebsd.org 	"Japan #4"\
94	ftp://ftp5.jp.freebsd.org 	"Japan #5"\
95	ftp://ftp6.jp.freebsd.org 	"Japan #6"\
96	ftp://ftp7.jp.freebsd.org 	"Japan #7"\
97	ftp://ftp8.jp.freebsd.org 	"Japan #8"\
98	ftp://ftp9.jp.freebsd.org 	"Japan #9"\
99	ftp://ftp.kr.freebsd.org 	"Korea"\
100	ftp://ftp2.kr.freebsd.org 	"Korea #2"\
101	ftp://ftp.lv.freebsd.org 	"Latvia"\
102	ftp://ftp.nl.freebsd.org 	"Netherlands"\
103	ftp://ftp2.nl.freebsd.org 	"Netherlands #2"\
104	ftp://ftp.nz.freebsd.org 	"New Zealand"\
105	ftp://ftp.no.freebsd.org 	"Norway"\
106	ftp://ftp.pl.freebsd.org 	"Poland"\
107	ftp://ftp.ru.freebsd.org 	"Russia"\
108	ftp://ftp2.ru.freebsd.org 	"Russia #2"\
109	ftp://ftp5.ru.freebsd.org 	"Russia #5"\
110	ftp://ftp6.ru.freebsd.org 	"Russia #6"\
111	ftp://ftp.sk.freebsd.org 	"Slovak Republic"\
112	ftp://ftp2.sk.freebsd.org 	"Slovak Republic #2"\
113	ftp://ftp.si.freebsd.org 	"Slovenia"\
114	ftp://ftp.za.freebsd.org 	"South Africa"\
115	ftp://ftp2.za.freebsd.org 	"South Africa #2"\
116	ftp://ftp4.za.freebsd.org 	"South Africa #4"\
117	ftp://ftp.se.freebsd.org 	"Sweden"\
118	ftp://ftp4.se.freebsd.org 	"Sweden #4"\
119	ftp://ftp.ch.freebsd.org 	"Switzerland"\
120	ftp://ftp.tw.freebsd.org 	"Taiwan"\
121	ftp://ftp2.tw.freebsd.org 	"Taiwan #2"\
122	ftp://ftp3.tw.freebsd.org 	"Taiwan #3"\
123	ftp://ftp4.tw.freebsd.org 	"Taiwan #4"\
124	ftp://ftp6.tw.freebsd.org 	"Taiwan #6"\
125	ftp://ftp11.tw.freebsd.org 	"Taiwan #11"\
126	ftp://ftp.uk.freebsd.org 	"UK"\
127	ftp://ftp2.uk.freebsd.org 	"UK #2"\
128	ftp://ftp3.uk.freebsd.org 	"UK #3"\
129	ftp://ftp4.uk.freebsd.org 	"UK #4"\
130	ftp://ftp5.uk.freebsd.org 	"UK #5"\
131	ftp://ftp.ua.freebsd.org 	"Ukraine"\
132	ftp://ftp1.us.freebsd.org 	"USA #1"\
133	ftp://ftp2.us.freebsd.org 	"USA #2"\
134	ftp://ftp3.us.freebsd.org 	"USA #3"\
135	ftp://ftp4.us.freebsd.org 	"USA #4"\
136	ftp://ftp5.us.freebsd.org 	"USA #5"\
137	ftp://ftp6.us.freebsd.org 	"USA #6"\
138	ftp://ftp8.us.freebsd.org 	"USA #8"\
139	ftp://ftp10.us.freebsd.org 	"USA #10"\
140	ftp://ftp11.us.freebsd.org 	"USA #11"\
141	ftp://ftp13.us.freebsd.org 	"USA #13"\
142	ftp://ftp14.us.freebsd.org 	"USA #14"\
143	ftp://ftp15.us.freebsd.org 	"USA #15"\
144    2>&1 1>&3`
145MIRROR_BUTTON=$?
146exec 3>&-
147
148_UNAME_R=`uname -r`
149_UNAME_R=${_UNAME_R%-p*}
150
151case ${_UNAME_R} in
152	*-ALPHA*|*-CURRENT|*-STABLE|*-PRERELEASE)
153		RELDIR="snapshots"
154		;;
155	*)
156		RELDIR="releases"
157		;;
158esac
159
160BSDINSTALL_DISTSITE="$MIRROR/pub/FreeBSD/${RELDIR}/`uname -m`/`uname -p`/${_UNAME_R}"
161
162case $MIRROR_BUTTON in
163$BSDDIALOG_ERROR | $BSDDIALOG_CANCEL | $BSDDIALOG_ESC)
164	exit 1
165	;;
166$BSDDIALOG_OK)
167	;;
168$BSDDIALOG_EXTRA)
169	exec 3>&1
170	BSDINSTALL_DISTSITE=`bsddialog --backtitle "$OSNAME Installer" \
171	    --title "Mirror Selection" \
172	    --inputbox "Please enter the URL to an alternate $OSNAME mirror:" \
173	    0 74 "$BSDINSTALL_DISTSITE" 2>&1 1>&3`
174	MIRROR_BUTTON=$?
175	exec 3>&-
176	test $MIRROR_BUTTON -eq $BSDDIALOG_OK || exec $0 $@
177	;;
178esac
179
180export BSDINSTALL_DISTSITE
181echo $BSDINSTALL_DISTSITE >&2
182