xref: /freebsd/usr.sbin/bsdinstall/scripts/mirrorselect (revision 19fae0f66023a97a9b464b3beeeabb2081f575b3)
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 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!" \
43    0 0 16 \
44	ftp://download.freebsd.org	"Main Site (GeoDNS)"\
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	ftp://ftp11.us.freebsd.org 	"USA #11 - IPv6"\
91	ftp://ftp14.us.freebsd.org 	"USA #14"\
92    2>&1 1>&3`
93MIRROR_BUTTON=$?
94exec 3>&-
95
96_UNAME_R=`uname -r`
97_UNAME_R=${_UNAME_R%-p*}
98
99case ${_UNAME_R} in
100	*-ALPHA*|*-CURRENT|*-STABLE|*-PRERELEASE)
101		RELDIR="snapshots"
102		;;
103	*)
104		RELDIR="releases"
105		;;
106esac
107
108BSDINSTALL_DISTSITE="$MIRROR/pub/FreeBSD/${RELDIR}/`uname -m`/`uname -p`/${_UNAME_R}"
109
110case $MIRROR_BUTTON in
111$BSDDIALOG_ERROR | $BSDDIALOG_CANCEL | $BSDDIALOG_ESC)
112	exit 1
113	;;
114$BSDDIALOG_OK)
115	;;
116$BSDDIALOG_EXTRA)
117	exec 3>&1
118	BSDINSTALL_DISTSITE=`bsddialog --backtitle "$OSNAME Installer" \
119	    --title "Mirror Selection" \
120	    --inputbox "Please enter the URL to an alternate $OSNAME mirror:" \
121	    0 74 "$BSDINSTALL_DISTSITE" 2>&1 1>&3`
122	MIRROR_BUTTON=$?
123	exec 3>&-
124	test $MIRROR_BUTTON -eq $BSDDIALOG_OK || exec $0 $@
125	;;
126esac
127
128export BSDINSTALL_DISTSITE
129echo $BSDINSTALL_DISTSITE >&2
130