1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2026-03-04 15:54:48 +01:00

when asking for a CSR country code, give the user a list

This commit is contained in:
Joshua Tauberer
2014-08-21 17:19:22 +00:00
parent 7ea4d33e06
commit 7e8e104964
3 changed files with 273 additions and 9 deletions

253
setup/csr_country_codes.tsv Normal file
View File

@@ -0,0 +1,253 @@
# This list is derived from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2.
# The columns are ISO_3166-1_alpha-2 code, display name, Wikipedia page name.
# The top 20 countries by number of Internet users are grouped first, see
# https://en.wikipedia.org/wiki/List_of_countries_by_number_of_Internet_users.
BR Brazil
CA Canada
CN China
EG Egypt
FR France
DE Germany
IN India
ID Indonesia
IT Italy
JP Japan
MX Mexico
NG Nigeria
PH Philippines
RU Russian Federation Russia
ES Spain
KR South Korea
TR Turkey
GB United Kingdom
US United States
VN Vietnam
AD Andorra
AE United Arab Emirates
AF Afghanistan
AG Antigua and Barbuda
AI Anguilla
AL Albania
AM Armenia
AO Angola
AQ Antarctica
AR Argentina
AS American Samoa
AT Austria
AU Australia
AW Aruba
AX Åland Islands
AZ Azerbaijan
BA Bosnia and Herzegovina
BB Barbados
BD Bangladesh
BE Belgium
BF Burkina Faso
BG Bulgaria
BH Bahrain
BI Burundi
BJ Benin
BL Saint Barthélemy
BM Bermuda
BN Brunei
BO Bolivia
BQ Bonaire, Sint Eustatius and Saba Caribbean Netherlands
BS Bahamas The Bahamas
BT Bhutan
BV Bouvet Island
BW Botswana
BY Belarus
BZ Belize
CC Cocos (Keeling) Islands
CD Congo, the Democratic Republic of the Democratic Republic of the Congo
CF Central African Republic
CG Congo Republic of the Congo
CH Switzerland
CI Côte d'Ivoire
CK Cook Islands
CL Chile
CM Cameroon
CO Colombia
CR Costa Rica
CU Cuba
CV Cabo Verde
CW Curaçao
CX Christmas Island
CY Cyprus
CZ Czech Republic
DJ Djibouti
DK Denmark
DM Dominica
DO Dominican Republic
DZ Algeria
EC Ecuador
EE Estonia
EH Western Sahara
ER Eritrea
ET Ethiopia
FI Finland
FJ Fiji
FK Falkland Islands (Malvinas) Falkland Islands
FM Federated States of Micronesia
FO Faroe Islands
GA Gabon
GD Grenada
GE Georgia Georgia (country)
GF French Guiana
GG Guernsey
GH Ghana
GI Gibraltar
GL Greenland
GM Gambia The Gambia
GN Guinea
GP Guadeloupe
GQ Equatorial Guinea
GR Greece
GS South Georgia and the South Sandwich Islands
GT Guatemala
GU Guam
GW Guinea-Bissau
GY Guyana
HK Hong Kong
HM Heard Island and McDonald Islands
HN Honduras
HR Croatia
HT Haiti
HU Hungary
IE Ireland Republic of Ireland
IL Israel
IM Isle of Man
IO British Indian Ocean Territory
IQ Iraq
IR Iran
IS Iceland
JE Jersey
JM Jamaica
JO Jordan
KE Kenya
KG Kyrgyzstan
KH Cambodia
KI Kiribati
KM Comoros
KN Saint Kitts and Nevis
KP North Korea
KW Kuwait
KY Cayman Islands
KZ Kazakhstan
LA Laos
LB Lebanon
LC Saint Lucia
LI Liechtenstein
LK Sri Lanka
LR Liberia
LS Lesotho
LT Lithuania
LU Luxembourg
LV Latvia
LY Libya
MA Morocco
MC Monaco
MD Moldova
ME Montenegro
MF Saint Martin (French part) Collectivity of Saint Martin
MG Madagascar
MH Marshall Islands
MK Macedonia Republic of Macedonia
ML Mali
MM Myanmar
MN Mongolia
MO Macao Macau
MP Northern Mariana Islands
MQ Martinique
MR Mauritania
MS Montserrat
MT Malta
MU Mauritius
MV Maldives
MW Malawi
MY Malaysia
MZ Mozambique
NA Namibia
NC New Caledonia
NE Niger
NF Norfolk Island
NI Nicaragua
NL Netherlands
NO Norway
NP Nepal
NR Nauru
NU Niue
NZ New Zealand
OM Oman
PA Panama
PE Peru
PF French Polynesia
PG Papua New Guinea
PK Pakistan
PL Poland
PM Saint Pierre and Miquelon
PN Pitcairn Pitcairn Islands
PR Puerto Rico
PS Palestine State of Palestine
PT Portugal
PW Palau
PY Paraguay
QA Qatar
RE Réunion
RO Romania
RS Serbia
RW Rwanda
SA Saudi Arabia
SB Solomon Islands
SC Seychelles
SD Sudan
SE Sweden
SG Singapore
SH Saint Helena, Ascension and Tristan da Cunha
SI Slovenia
SJ Svalbard and Jan Mayen
SK Slovakia
SL Sierra Leone
SM San Marino
SN Senegal
SO Somalia
SR Suriname
SS South Sudan
ST Sao Tome and Principe
SV El Salvador
SX Sint Maarten (Dutch part) Sint Maarten
SY Syria
SZ Swaziland
TC Turks and Caicos Islands
TD Chad
TF French Southern Territories French Southern and Antarctic Lands
TG Togo
TH Thailand
TJ Tajikistan
TK Tokelau
TL Timor-Leste East Timor
TM Turkmenistan
TN Tunisia
TO Tonga
TT Trinidad and Tobago
TV Tuvalu
TW Taiwan
TZ Tanzania
UA Ukraine
UG Uganda
UM United States Minor Outlying Islands
UY Uruguay
UZ Uzbekistan
VA Vatican City
VC Saint Vincent and the Grenadines
VE Venezuela
VG Virgin Islands, British British Virgin Islands
VI Virgin Islands, U.S. United States Virgin Islands
VU Vanuatu
WF Wallis and Futuna
WS Samoa
YE Yemen
YT Mayotte
ZA South Africa
ZM Zambia
ZW Zimbabwe
1 # This list is derived from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2.
2 # The columns are ISO_3166-1_alpha-2 code, display name, Wikipedia page name.
3 # The top 20 countries by number of Internet users are grouped first, see
4 # https://en.wikipedia.org/wiki/List_of_countries_by_number_of_Internet_users.
5 BR Brazil
6 CA Canada
7 CN China
8 EG Egypt
9 FR France
10 DE Germany
11 IN India
12 ID Indonesia
13 IT Italy
14 JP Japan
15 MX Mexico
16 NG Nigeria
17 PH Philippines
18 RU Russian Federation Russia
19 ES Spain
20 KR South Korea
21 TR Turkey
22 GB United Kingdom
23 US United States
24 VN Vietnam
25 AD Andorra
26 AE United Arab Emirates
27 AF Afghanistan
28 AG Antigua and Barbuda
29 AI Anguilla
30 AL Albania
31 AM Armenia
32 AO Angola
33 AQ Antarctica
34 AR Argentina
35 AS American Samoa
36 AT Austria
37 AU Australia
38 AW Aruba
39 AX Åland Islands
40 AZ Azerbaijan
41 BA Bosnia and Herzegovina
42 BB Barbados
43 BD Bangladesh
44 BE Belgium
45 BF Burkina Faso
46 BG Bulgaria
47 BH Bahrain
48 BI Burundi
49 BJ Benin
50 BL Saint Barthélemy
51 BM Bermuda
52 BN Brunei
53 BO Bolivia
54 BQ Bonaire, Sint Eustatius and Saba Caribbean Netherlands
55 BS Bahamas The Bahamas
56 BT Bhutan
57 BV Bouvet Island
58 BW Botswana
59 BY Belarus
60 BZ Belize
61 CC Cocos (Keeling) Islands
62 CD Congo, the Democratic Republic of the Democratic Republic of the Congo
63 CF Central African Republic
64 CG Congo Republic of the Congo
65 CH Switzerland
66 CI Côte d'Ivoire
67 CK Cook Islands
68 CL Chile
69 CM Cameroon
70 CO Colombia
71 CR Costa Rica
72 CU Cuba
73 CV Cabo Verde
74 CW Curaçao
75 CX Christmas Island
76 CY Cyprus
77 CZ Czech Republic
78 DJ Djibouti
79 DK Denmark
80 DM Dominica
81 DO Dominican Republic
82 DZ Algeria
83 EC Ecuador
84 EE Estonia
85 EH Western Sahara
86 ER Eritrea
87 ET Ethiopia
88 FI Finland
89 FJ Fiji
90 FK Falkland Islands (Malvinas) Falkland Islands
91 FM Federated States of Micronesia
92 FO Faroe Islands
93 GA Gabon
94 GD Grenada
95 GE Georgia Georgia (country)
96 GF French Guiana
97 GG Guernsey
98 GH Ghana
99 GI Gibraltar
100 GL Greenland
101 GM Gambia The Gambia
102 GN Guinea
103 GP Guadeloupe
104 GQ Equatorial Guinea
105 GR Greece
106 GS South Georgia and the South Sandwich Islands
107 GT Guatemala
108 GU Guam
109 GW Guinea-Bissau
110 GY Guyana
111 HK Hong Kong
112 HM Heard Island and McDonald Islands
113 HN Honduras
114 HR Croatia
115 HT Haiti
116 HU Hungary
117 IE Ireland Republic of Ireland
118 IL Israel
119 IM Isle of Man
120 IO British Indian Ocean Territory
121 IQ Iraq
122 IR Iran
123 IS Iceland
124 JE Jersey
125 JM Jamaica
126 JO Jordan
127 KE Kenya
128 KG Kyrgyzstan
129 KH Cambodia
130 KI Kiribati
131 KM Comoros
132 KN Saint Kitts and Nevis
133 KP North Korea
134 KW Kuwait
135 KY Cayman Islands
136 KZ Kazakhstan
137 LA Laos
138 LB Lebanon
139 LC Saint Lucia
140 LI Liechtenstein
141 LK Sri Lanka
142 LR Liberia
143 LS Lesotho
144 LT Lithuania
145 LU Luxembourg
146 LV Latvia
147 LY Libya
148 MA Morocco
149 MC Monaco
150 MD Moldova
151 ME Montenegro
152 MF Saint Martin (French part) Collectivity of Saint Martin
153 MG Madagascar
154 MH Marshall Islands
155 MK Macedonia Republic of Macedonia
156 ML Mali
157 MM Myanmar
158 MN Mongolia
159 MO Macao Macau
160 MP Northern Mariana Islands
161 MQ Martinique
162 MR Mauritania
163 MS Montserrat
164 MT Malta
165 MU Mauritius
166 MV Maldives
167 MW Malawi
168 MY Malaysia
169 MZ Mozambique
170 NA Namibia
171 NC New Caledonia
172 NE Niger
173 NF Norfolk Island
174 NI Nicaragua
175 NL Netherlands
176 NO Norway
177 NP Nepal
178 NR Nauru
179 NU Niue
180 NZ New Zealand
181 OM Oman
182 PA Panama
183 PE Peru
184 PF French Polynesia
185 PG Papua New Guinea
186 PK Pakistan
187 PL Poland
188 PM Saint Pierre and Miquelon
189 PN Pitcairn Pitcairn Islands
190 PR Puerto Rico
191 PS Palestine State of Palestine
192 PT Portugal
193 PW Palau
194 PY Paraguay
195 QA Qatar
196 RE Réunion
197 RO Romania
198 RS Serbia
199 RW Rwanda
200 SA Saudi Arabia
201 SB Solomon Islands
202 SC Seychelles
203 SD Sudan
204 SE Sweden
205 SG Singapore
206 SH Saint Helena, Ascension and Tristan da Cunha
207 SI Slovenia
208 SJ Svalbard and Jan Mayen
209 SK Slovakia
210 SL Sierra Leone
211 SM San Marino
212 SN Senegal
213 SO Somalia
214 SR Suriname
215 SS South Sudan
216 ST Sao Tome and Principe
217 SV El Salvador
218 SX Sint Maarten (Dutch part) Sint Maarten
219 SY Syria
220 SZ Swaziland
221 TC Turks and Caicos Islands
222 TD Chad
223 TF French Southern Territories French Southern and Antarctic Lands
224 TG Togo
225 TH Thailand
226 TJ Tajikistan
227 TK Tokelau
228 TL Timor-Leste East Timor
229 TM Turkmenistan
230 TN Tunisia
231 TO Tonga
232 TT Trinidad and Tobago
233 TV Tuvalu
234 TW Taiwan
235 TZ Tanzania
236 UA Ukraine
237 UG Uganda
238 UM United States Minor Outlying Islands
239 UY Uruguay
240 UZ Uzbekistan
241 VA Vatican City
242 VC Saint Vincent and the Grenadines
243 VE Venezuela
244 VG Virgin Islands, British British Virgin Islands
245 VI Virgin Islands, U.S. United States Virgin Islands
246 VU Vanuatu
247 WF Wallis and Futuna
248 WS Samoa
249 YE Yemen
250 YT Mayotte
251 ZA South Africa
252 ZM Zambia
253 ZW Zimbabwe

View File

@@ -142,3 +142,14 @@ function input_box {
result=$(dialog --stdout --title "$1" --inputbox "$2" 0 0 "$3")
result_code=$?
}
function input_menu {
# input_menu "title" "prompt" "tag item tag item" VARIABLE
# The user's input will be stored in the variable VARIABLE.
# The exit code from dialog will be stored in VARIABLE_EXITCODE.
declare -n result=$4
declare -n result_code=$4_EXITCODE
local IFS=^$'\n'
result=$(dialog --stdout --title "$1" --menu "$2" 0 0 0 $3)
result_code=$?
}

View File

@@ -213,16 +213,16 @@ if [ ! -z "$DEFAULT_STORAGE_ROOT" ] && [ ! -z "$DEFAULT_CSR_COUNTRY" ] && [ -f $
fi
if [ -z "$CSR_COUNTRY" ]; then
#if [ -z "$DEFAULT_CSR_COUNTRY" ]; then
# # set a default on first run
# DEFAULT_CSR_COUNTRY=...?
#fi
# Get a list of country codes. Separate codes from country names with a ^.
# The input_menu function modifies shell word expansion to ignore spaces
# (since country names can have spaces) and use ^ instead.
country_code_list=$(grep -v "^#" setup/csr_country_codes.tsv | sed "s/\(..\)\t\([^\t]*\).*/\1^\2/")
input_box "Country Code" \
"Enter the two-letter, uppercase country code for where you live or where your
organization is based. (This is used to create an SSL certificate.)
\n\nCountry Code:" \
$DEFAULT_CSR_COUNTRY \
input_menu "Country Code" \
"Choose the country where you live or where your organization is based.
\n\n(This is used to create an SSL certificate.)
\n\nCountry Code:" \
"$country_code_list" \
CSR_COUNTRY
if [ -z "$CSR_COUNTRY" ]; then