xref: /freebsd/usr.sbin/bsdinstall/scripts/mirrorselect (revision 6e5dcc6113da649a79e5bc2c3ea9329bcd1d85d5)
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
28BSDCFG_SHARE="/usr/share/bsdconfig"
29. $BSDCFG_SHARE/common.subr || exit 1
30
31: ${BSDDIALOG_OK=0}
32: ${BSDDIALOG_CANCEL=1}
33: ${BSDDIALOG_HELP=2}
34: ${BSDDIALOG_EXTRA=3}
35: ${BSDDIALOG_ESC=5}
36: ${BSDDIALOG_ERROR=255}
37
38exec 5>&1
39MIRROR=`bsddialog --backtitle "$OSNAME Installer" \
40    --title "Mirror Selection" --extra-button --extra-label "Other" \
41    --menu "Please select the best suitable site for you or \"other\" if you want to specify a different choice. The \"Main Site\" directs users to the nearest project managed mirror via GeoDNS (they carry the full range of possible distributions and support both IPv4 and IPv6). All other sites are known as \"Community Mirrors\"; not every site listed here carries more than the base distribution kits. Select a site!" \
42    0 0 16 \
43	ftp://download.freebsd.org	"Main Site (GeoDNS)"\
44	http://ftp.au.freebsd.org 	"Australia - IPv6"\
45	ftp://ftp3.au.freebsd.org 	"Australia #3"\
46	ftp://ftp.at.freebsd.org 	"Austria - IPv6"\
47	ftp://ftp2.br.freebsd.org 	"Brazil #2"\
48	ftp://ftp3.br.freebsd.org 	"Brazil #3"\
49	ftp://ftp.bg.freebsd.org 	"Bulgaria - IPv6"\
50	ftp://ftp.cz.freebsd.org 	"Czech Republic - IPv6"\
51	ftp://ftp.dk.freebsd.org 	"Denmark - IPv6"\
52	ftp://ftp.fi.freebsd.org 	"Finland"\
53	ftp://ftp.fr.freebsd.org 	"France - IPv6"\
54	ftp://ftp3.fr.freebsd.org 	"France #3"\
55	ftp://ftp6.fr.freebsd.org 	"France #6"\
56	ftp://ftp.de.freebsd.org 	"Germany - IPv6"\
57	ftp://ftp1.de.freebsd.org 	"Germany #1 - IPv6"\
58	ftp://ftp2.de.freebsd.org 	"Germany #2 - IPv6"\
59	ftp://ftp5.de.freebsd.org 	"Germany #5 - IPv6"\
60	ftp://ftp7.de.freebsd.org 	"Germany #7 - IPv6"\
61	ftp://ftp.gr.freebsd.org 	"Greece - IPv6"\
62	ftp://ftp2.gr.freebsd.org 	"Greece #2 - IPv6"\
63	ftp://ftp.jp.freebsd.org 	"Japan - IPv6"\
64	ftp://ftp2.jp.freebsd.org 	"Japan #2"\
65	ftp://ftp3.jp.freebsd.org 	"Japan #3"\
66	ftp://ftp4.jp.freebsd.org 	"Japan #4"\
67	ftp://ftp6.jp.freebsd.org 	"Japan #6 - IPv6"\
68	ftp://ftp.kr.freebsd.org 	"Korea"\
69	ftp://ftp2.kr.freebsd.org 	"Korea #2"\
70	ftp://ftp.lv.freebsd.org 	"Latvia"\
71	ftp://ftp.nl.freebsd.org 	"Netherlands - IPv6"\
72	ftp://ftp2.nl.freebsd.org 	"Netherlands #2"\
73	ftp://ftp.nz.freebsd.org 	"New Zealand"\
74	ftp://ftp.no.freebsd.org 	"Norway - IPv6"\
75	ftp://ftp.pl.freebsd.org 	"Poland - IPv6"\
76	ftp://ftp.ru.freebsd.org 	"Russia - IPv6"\
77	ftp://ftp2.ru.freebsd.org 	"Russia #2"\
78	ftp://ftp.si.freebsd.org 	"Slovenia - IPv6"\
79	ftp://ftp.za.freebsd.org 	"South Africa - IPv6"\
80	ftp://ftp2.za.freebsd.org 	"South Africa #2 - IPv6"\
81	ftp://ftp4.za.freebsd.org 	"South Africa #4"\
82	ftp://ftp.se.freebsd.org 	"Sweden - IPv6"\
83	ftp://ftp4.tw.freebsd.org 	"Taiwan #4"\
84	ftp://ftp5.tw.freebsd.org 	"Taiwan #5"\
85	ftp://ftp.uk.freebsd.org 	"UK - IPv6"\
86	ftp://ftp2.uk.freebsd.org 	"UK #2 - IPv6"\
87	ftp://ftp.ua.FreeBSD.org 	"Ukraine - IPv6"\
88	ftp://ftp5.us.freebsd.org 	"USA #5 - IPv6"\
89	ftp://ftp11.us.freebsd.org 	"USA #11 - IPv6"\
90	ftp://ftp14.us.freebsd.org 	"USA #14"\
91    2>&1 1>&5`
92MIRROR_BUTTON=$?
93exec 5>&-
94
95_UNAME_R=`uname -r`
96_UNAME_R=${_UNAME_R%-p*}
97
98case ${_UNAME_R} in
99	*-ALPHA*|*-CURRENT|*-STABLE|*-PRERELEASE)
100		RELDIR="snapshots"
101		;;
102	*)
103		RELDIR="releases"
104		;;
105esac
106
107BSDINSTALL_DISTSITE="$MIRROR/pub/FreeBSD/${RELDIR}/`uname -m`/`uname -p`/${_UNAME_R}"
108
109case $MIRROR_BUTTON in
110$BSDDIALOG_ERROR | $BSDDIALOG_CANCEL | $BSDDIALOG_ESC)
111	exit 1
112	;;
113$BSDDIALOG_OK)
114	;;
115$BSDDIALOG_EXTRA)
116	exec 5>&1
117	BSDINSTALL_DISTSITE=`bsddialog --backtitle "$OSNAME Installer" \
118	    --title "Mirror Selection" \
119	    --inputbox "Please enter the URL to an alternate $OSNAME mirror:" \
120	    0 74 "$BSDINSTALL_DISTSITE" 2>&1 1>&5`
121	MIRROR_BUTTON=$?
122	exec 5>&-
123	test $MIRROR_BUTTON -eq $BSDDIALOG_OK || exec $0 $@
124	;;
125esac
126
127export BSDINSTALL_DISTSITE
128echo $BSDINSTALL_DISTSITE >&2
129