xref: /freebsd/usr.sbin/bsdinstall/scripts/mirrorselect (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
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	http://ftp.freebsd.org		"Main Site (GeoDNS, HTTP)"\
44	ftp://ftp.freebsd.org		"Main Site (GeoDNS, FTP)"\
45	http://ftp.au.freebsd.org 	"Australia - IPv6"\
46	ftp://ftp3.au.freebsd.org 	"Australia #3"\
47	ftp://ftp.at.freebsd.org 	"Austria - IPv6"\
48	ftp://ftp2.br.freebsd.org 	"Brazil #2"\
49	ftp://ftp3.br.freebsd.org 	"Brazil #3"\
50	ftp://ftp.bg.freebsd.org 	"Bulgaria - IPv6"\
51	ftp://ftp.cz.freebsd.org 	"Czech Republic - IPv6"\
52	ftp://ftp.dk.freebsd.org 	"Denmark - IPv6"\
53	ftp://ftp.fi.freebsd.org 	"Finland"\
54	ftp://ftp.fr.freebsd.org 	"France - IPv6"\
55	ftp://ftp3.fr.freebsd.org 	"France #3"\
56	ftp://ftp6.fr.freebsd.org 	"France #6"\
57	ftp://ftp.de.freebsd.org 	"Germany - IPv6"\
58	ftp://ftp1.de.freebsd.org 	"Germany #1 - IPv6"\
59	ftp://ftp2.de.freebsd.org 	"Germany #2 - IPv6"\
60	ftp://ftp5.de.freebsd.org 	"Germany #5 - IPv6"\
61	ftp://ftp7.de.freebsd.org 	"Germany #7 - IPv6"\
62	ftp://ftp.gr.freebsd.org 	"Greece - IPv6"\
63	ftp://ftp2.gr.freebsd.org 	"Greece #2 - IPv6"\
64	ftp://ftp.jp.freebsd.org 	"Japan - IPv6"\
65	ftp://ftp2.jp.freebsd.org 	"Japan #2"\
66	ftp://ftp3.jp.freebsd.org 	"Japan #3"\
67	ftp://ftp4.jp.freebsd.org 	"Japan #4"\
68	ftp://ftp6.jp.freebsd.org 	"Japan #6 - IPv6"\
69	ftp://ftp.kr.freebsd.org 	"Korea"\
70	ftp://ftp2.kr.freebsd.org 	"Korea #2"\
71	ftp://ftp.lv.freebsd.org 	"Latvia"\
72	ftp://ftp.nl.freebsd.org 	"Netherlands - IPv6"\
73	ftp://ftp2.nl.freebsd.org 	"Netherlands #2"\
74	ftp://ftp.nz.freebsd.org 	"New Zealand"\
75	ftp://ftp.no.freebsd.org 	"Norway - IPv6"\
76	ftp://ftp.pl.freebsd.org 	"Poland - IPv6"\
77	ftp://ftp.ru.freebsd.org 	"Russia - IPv6"\
78	ftp://ftp2.ru.freebsd.org 	"Russia #2"\
79	ftp://ftp.si.freebsd.org 	"Slovenia - IPv6"\
80	ftp://ftp.za.freebsd.org 	"South Africa - IPv6"\
81	ftp://ftp2.za.freebsd.org 	"South Africa #2 - IPv6"\
82	ftp://ftp4.za.freebsd.org 	"South Africa #4"\
83	ftp://ftp.se.freebsd.org 	"Sweden - IPv6"\
84	ftp://ftp4.tw.freebsd.org 	"Taiwan #4"\
85	ftp://ftp5.tw.freebsd.org 	"Taiwan #5"\
86	ftp://ftp.uk.freebsd.org 	"UK - IPv6"\
87	ftp://ftp2.uk.freebsd.org 	"UK #2 - IPv6"\
88	ftp://ftp.ua.FreeBSD.org 	"Ukraine - IPv6"\
89	ftp://ftp5.us.freebsd.org 	"USA #5 - IPv6"\
90    2>&1 1>&5`
91MIRROR_BUTTON=$?
92exec 5>&-
93
94_UNAME_R=`uname -r`
95_UNAME_R=${_UNAME_R%-p*}
96
97case ${_UNAME_R} in
98	*-ALPHA*|*-CURRENT|*-STABLE|*-PRERELEASE)
99		RELDIR="snapshots"
100		;;
101	*)
102		RELDIR="releases"
103		;;
104esac
105
106BSDINSTALL_DISTSITE="$MIRROR/pub/FreeBSD/${RELDIR}/`uname -m`/`uname -p`/${_UNAME_R}"
107
108case $MIRROR_BUTTON in
109$BSDDIALOG_ERROR | $BSDDIALOG_CANCEL | $BSDDIALOG_ESC)
110	exit 1
111	;;
112$BSDDIALOG_OK)
113	;;
114$BSDDIALOG_EXTRA)
115	exec 5>&1
116	BSDINSTALL_DISTSITE=`bsddialog --backtitle "$OSNAME Installer" \
117	    --title "Mirror Selection" \
118	    --inputbox "Please enter the URL to an alternate $OSNAME mirror:" \
119	    0 74 "$BSDINSTALL_DISTSITE" 2>&1 1>&5`
120	MIRROR_BUTTON=$?
121	exec 5>&-
122	test $MIRROR_BUTTON -eq $BSDDIALOG_OK || exec $0 $@
123	;;
124esac
125
126export BSDINSTALL_DISTSITE
127echo $BSDINSTALL_DISTSITE >&2
128