functions-ftp.sh revision 211730
1#!/bin/sh 2#- 3# Copyright (c) 2010 iXsystems, Inc. All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions 7# are met: 8# 1. Redistributions of source code must retain the above copyright 9# notice, this list of conditions and the following disclaimer. 10# 2. Redistributions in binary form must reproduce the above copyright 11# notice, this list of conditions and the following disclaimer in the 12# documentation and/or other materials provided with the distribution. 13# 14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24# SUCH DAMAGE. 25# 26# $FreeBSD: head/usr.sbin/pc-sysinstall/backend/functions-ftp.sh 211730 2010-08-24 06:11:46Z imp $ 27 28# Functions which runs commands on the system 29 30. ${BACKEND}/functions.sh 31. ${BACKEND}/functions-parse.sh 32 33DEFAULT_FTP_SERVER="ftp.freebsd.org" 34 35MAIN_FTP_SERVERS="\ 36Main Site: ftp.freebsd.org" 37 38IPV6_FTP_SERVERS="\ 39IPv6 Main Site: ftp.freebsd.org|\ 40IPv6 Ireland: ftp3.ie.freebsd.org|\ 41IPv6 Israel: ftp.il.freebsd.org|\ 42IPv6 Japan: ftp2.jp.freebsd.org|\ 43IPv6 USA: ftp4.us.freebsd.org|\ 44IPv6 Turkey: ftp2.tr.freebsd.org" 45 46PRIMARY_FTP_SERVERS="\ 47Primary: ftp1.freebsd.org|\ 48Primary #2: ftp2.freebsd.org|\ 49Primary #3: ftp3.freebsd.org|\ 50Primary #4: ftp4.freebsd.org|\ 51Primary #5: ftp5.freebsd.org|\ 52Primary #6: ftp6.freebsd.org|\ 53Primary #7: ftp7.freebsd.org|\ 54Primary #8: ftp8.freebsd.org|\ 55Primary #9: ftp9.freebsd.org|\ 56Primary #10: ftp10.freebsd.org|\ 57Primary #11: ftp11.freebsd.org|\ 58Primary #12: ftp12.freebsd.org|\ 59Primary #13: ftp13.freebsd.org|\ 60Primary #14: ftp14.freebsd.org" 61 62ARGENTINA_FTP_SERVERS="\ 63Argentina: ftp.ar.freebsd.org" 64 65AUSTRALIA_FTP_SERVERS="\ 66Australia: ftp.au.freebsd.org|\ 67Australia #2: ftp2.au.freebsd.org|\ 68Australia #3: ftp3.au.freebsd.org" 69 70AUSTRIA_FTP_SERVERS="\ 71Austria: ftp.at.freebsd.org|\ 72Austria #2: ftp2.at.freebsd.org" 73 74BRAZIL_FTP_SERVERS="\ 75Brazil: ftp.br.freebsd.org|\ 76Brazil #2: ftp2.br.freebsd.org|\ 77Brazil #3: ftp3.br.freebsd.org|\ 78Brazil #4: ftp4.br.freebsd.org|\ 79Brazil #5: ftp5.br.freebsd.org|\ 80Brazil #6: ftp6.br.freebsd.org|\ 81Brazil #7: ftp7.br.freebsd.org" 82 83CANADA_FTP_SERVERS="\ 84Canada: ftp.ca.freebsd.org" 85 86CHINA_FTP_SERVERS="\ 87China: ftp.cn.freebsd.org|\ 88China #2: ftp2.cn.freebsd.org" 89 90CROATIA_FTP_SERVERS="\ 91Croatia: ftp.hr.freebsd.org" 92 93CZECH_REPUBLIC_FTP_SERVERS="\ 94Czech Republic: ftp.cz.freebsd.org" 95 96DENMARK_FTP_SERVERS="\ 97Denmark: ftp.dk.freebsd.org|\ 98Denmark #2: ftp2.dk.freebsd.org" 99 100ESTONIA_FTP_SERVERS="\ 101Estonia: ftp.ee.freebsd.org" 102 103FINLAND_FTP_SERVERS="\ 104Finland: ftp.fi.freebsd.org" 105 106FRANCE_FTP_SERVERS="\ 107France: ftp.fr.freebsd.org|\ 108France #2: ftp2.fr.freebsd.org|\ 109France #3: ftp3.fr.freebsd.org|\ 110France #5: ftp5.fr.freebsd.org|\ 111France #6: ftp6.fr.freebsd.org|\ 112France #8: ftp8.fr.freebsd.org" 113 114GERMANY_FTP_SERVERS="\ 115Germany: ftp.de.freebsd.org|\ 116Germany #2: ftp2.de.freebsd.org|\ 117Germany #3: ftp3.de.freebsd.org|\ 118Germany #4: ftp4.de.freebsd.org|\ 119Germany #5: ftp5.de.freebsd.org|\ 120Germany #6: ftp6.de.freebsd.org|\ 121Germany #7: ftp7.de.freebsd.org|\ 122Germany #8: ftp8.de.freebsd.org" 123 124GREECE_FTP_SERVERS="\ 125Greece: ftp.gr.freebsd.org|\ 126Greece #2: ftp2.gr.freebsd.org" 127 128HUNGARY_FTP_SERVERS="\ 129Hungary: ftp.hu.freebsd.org" 130 131ICELAND_FTP_SERVERS="\ 132Iceland: ftp.is.freebsd.org" 133 134IRELAND_FTP_SERVERS="\ 135Ireland: ftp.ie.freebsd.org|\ 136Ireland #2: ftp2.ie.freebsd.org|\ 137Ireland #3: ftp3.ie.freebsd.org" 138 139ISRAEL_FTP_SERVERS="\ 140Israel: ftp.il.freebsd.org" 141 142ITALY_FTP_SERVERS="\ 143Italy: ftp.it.freebsd.org" 144 145JAPAN_FTP_SERVERS="\ 146Japan: ftp.jp.freebsd.org|\ 147Japan #2: ftp2.jp.freebsd.org|\ 148Japan #3: ftp3.jp.freebsd.org|\ 149Japan #4: ftp4.jp.freebsd.org|\ 150Japan #5: ftp5.jp.freebsd.org|\ 151Japan #6: ftp6.jp.freebsd.org|\ 152Japan #7: ftp7.jp.freebsd.org|\ 153Japan #8: ftp8.jp.freebsd.org|\ 154Japan #9: ftp9.jp.freebsd.org" 155 156KOREA_FTP_SERVERS="\ 157Korea: ftp.kr.freebsd.org|\ 158Korea #2: ftp2.kr.freebsd.org" 159 160LITHUANIA_FTP_SERVERS="\ 161Lithuania: ftp.lt.freebsd.org" 162 163NETHERLANDS_FTP_SERVERS="\ 164Netherlands: ftp.nl.freebsd.org|\ 165Netherlands #2: ftp2.nl.freebsd.org" 166 167NORWAY_FTP_SERVERS="\ 168Norway: ftp.no.freebsd.org|\ 169Norway #3: ftp3.no.freebsd.org" 170 171POLAND_FTP_SERVERS="\ 172Poland: ftp.pl.freebsd.org|\ 173Poland #2: ftp2.pl.freebsd.org|\ 174Poland #5: ftp5.pl.freebsd.org" 175 176PORTUGAL_FTP_SERVERS="\ 177Portugal: ftp.pt.freebsd.org|\ 178Portugal #2: ftp2.pt.freebsd.org|\ 179Portugal #4: ftp4.pt.freebsd.org" 180 181ROMANIA_FTP_SERVERS="\ 182Romania: ftp.ro.freebsd.org" 183 184RUSSIA_FTP_SERVERS="\ 185Russia: ftp.ru.freebsd.org|\ 186Russia #2: ftp2.ru.freebsd.org|\ 187Russia #3: ftp3.ru.freebsd.org|\ 188Russia #4: ftp4.ru.freebsd.org" 189 190SINGAPORE_FTP_SERVERS="\ 191Singapore: ftp.sg.freebsd.org" 192 193SLOVAK_REPUBLIC_FTP_SERVERS="\ 194Slovak Republic: ftp.sk.freebsd.org" 195 196SLOVENIA_FTP_SERVERS="\ 197Slovenia: ftp.si.freebsd.org|\ 198Slovenia #2: ftp2.si.freebsd.org" 199 200SOUTH_AFRICA_FTP_SERVERS="\ 201South Africa: ftp.za.freebsd.org|\ 202South Africa #2: ftp2.za.freebsd.org|\ 203South Africa #3: ftp3.za.freebsd.org|\ 204South Africa #4: ftp4.za.freebsd.org" 205 206SPAIN_FTP_SERVERS="\ 207Spain: ftp.es.freebsd.org|\ 208Spain #2: ftp2.es.freebsd.org|\ 209Spain #3: ftp3.es.freebsd.org" 210 211SWEDEN_FTP_SERVERS="\ 212Sweden: ftp.se.freebsd.org|\ 213Sweden #2: ftp2.se.freebsd.org|\ 214Sweden #3: ftp3.se.freebsd.org|\ 215Sweden #5: ftp5.se.freebsd.org" 216 217SWITZERLAND_FTP_SERVERS="\ 218Switzerland: ftp.ch.freebsd.org|\ 219Switzerland #2: ftp2.ch.freebsd.org" 220 221TAIWAN_FTP_SERVERS="\ 222Taiwan: ftp.tw.freebsd.org|\ 223Taiwan #2: ftp2.tw.freebsd.org|\ 224Taiwan #3: ftp3.tw.freebsd.org|\ 225Taiwan #4: ftp4.tw.freebsd.org|\ 226Taiwan #6: ftp6.tw.freebsd.org|\ 227Taiwan #11: ftp11.tw.freebsd.org" 228 229TURKEY_FTP_SERVERS="\ 230Turkey: ftp.tr.freebsd.org|\ 231Turkey #2: ftp2.tr.freebsd.org" 232 233UK_FTP_SERVERS="\ 234UK: ftp.uk.freebsd.org|\ 235UK #2: ftp2.uk.freebsd.org|\ 236UK #3: ftp3.uk.freebsd.org|\ 237UK #4: ftp4.uk.freebsd.org|\ 238UK #5: ftp5.uk.freebsd.org|\ 239UK #6: ftp6.uk.freebsd.org" 240 241UKRAINE_FTP_SERVERS="\ 242Ukraine: ftp.ua.freebsd.org|\ 243Ukraine #2: ftp2.ua.freebsd.org|\ 244Ukraine #5: ftp5.ua.freebsd.org|\ 245Ukraine #6: ftp6.ua.freebsd.org|\ 246Ukraine #7: ftp7.ua.freebsd.org|\ 247Ukraine #8: ftp8.ua.freebsd.org" 248 249USA_FTP_SERVERS="\ 250USA #1: ftp1.us.freebsd.org|\ 251USA #2: ftp2.us.freebsd.org|\ 252USA #3: ftp3.us.freebsd.org|\ 253USA #4: ftp4.us.freebsd.org|\ 254USA #5: ftp5.us.freebsd.org|\ 255USA #6: ftp6.us.freebsd.org|\ 256USA #7: ftp7.us.freebsd.org|\ 257USA #8: ftp8.us.freebsd.org|\ 258USA #9: ftp9.us.freebsd.org|\ 259USA #10: ftp10.us.freebsd.org|\ 260USA #11: ftp11.us.freebsd.org|\ 261USA #12: ftp12.us.freebsd.org|\ 262USA #13: ftp13.us.freebsd.org|\ 263USA #14: ftp14.us.freebsd.org|\ 264USA #15: ftp15.us.freebsd.org" 265 266show_mirrors() 267{ 268 MIRRORS="${1}" 269 if [ -n "${MIRRORS}" ] 270 then 271 SAVE_IFS="${IFS}" 272 IFS="|" 273 for m in ${MIRRORS} 274 do 275 echo "$m" 276 done 277 IFS="${SAVE_IFS}" 278 fi 279}; 280 281set_ftp_mirror() 282{ 283 MIRROR="${1}" 284 echo "${MIRROR}" > "${CONFDIR}/mirrors.conf" 285}; 286 287get_ftp_mirror() 288{ 289 MIRROR="${DEFAULT_FTP_SERVER}" 290 if [ -f "${CONFDIR}/mirrors.conf" ] 291 then 292 MIRROR=`cat "${CONFDIR}/mirrors.conf"` 293 fi 294 295 VAL="${MIRROR}" 296 export VAL 297}; 298 299 300get_ftpHost() 301{ 302 get_value_from_cfg ftpPath 303 ftpPath="$VAL" 304 305 ftpHost=`echo "${ftpPath}" | sed -E 's|^(ftp://)([^/]*)(.*)|\2|'` 306 VAL="${ftpHost}" 307 308 export VAL 309}; 310 311get_ftpDir() 312{ 313 get_value_from_cfg ftpPath 314 ftpPath="$VAL" 315 316 ftpDir=`echo "${ftpPath}" | sed -E 's|^(ftp://)([^/]*)(.*)|\3|'` 317 VAL="${ftpDir}" 318 319 export VAL 320}; 321 322get_ftp_mirrors() 323{ 324 COUNTRY="${1}" 325 if [ -n "$COUNTRY" ] 326 then 327 COUNTRY=`echo $COUNTRY|tr A-Z a-z` 328 case "${COUNTRY}" in 329 argentina*) VAL="${ARGENTINA_FTP_SERVERS}" ;; 330 australia*) VAL="${AUSTRALIA_FTP_SERVERS}" ;; 331 austria*) VAL="${AUSTRIA_FTP_SERVERS}" ;; 332 brazil*) VAL="${BRAZIL_FTP_SERVERS}" ;; 333 canada*) VAL="${CANADA_FTP_SERVERS}" ;; 334 china*) VAL="${CHINA_FTP_SERVERS}" ;; 335 croatia*) VAL="${CROATIA_FTP_SERVERS}" ;; 336 czech*) VAL="${CZECH_REPUBLIC_FTP_SERVERS}" ;; 337 denmark*) VAL="${DENMARK_FTP_SERVERS}" ;; 338 estonia*) VAL="${ESTONIA_FTP_SERVERS}" ;; 339 finland*) VAL="${FINLAND_FTP_SERVERS}" ;; 340 france*) VAL="${FRANCE_FTP_SERVERS}" ;; 341 germany*) VAL="${GERMANY_FTP_SERVERS}" ;; 342 greece*) VAL="${GREECE_FTP_SERVERS}" ;; 343 hungary*) VAL="${HUNGARY_FTP_SERVERS}" ;; 344 iceland*) VAL="${ICELAND_FTP_SERVERS}" ;; 345 ireland*) VAL="${IRELAND_FTP_SERVERS}" ;; 346 israel*) VAL="${ISRAEL_FTP_SERVERS}" ;; 347 italy*) VAL="${ITALY_FTP_SERVERS}" ;; 348 japan*) VAL="${JAPAN_FTP_SERVERS}" ;; 349 korea*) VAL="${KOREA_FTP_SERVERS}" ;; 350 lithuania*) VAL="${LITHUANIA_FTP_SERVERS}" ;; 351 netherlands*) VAL="${NETHERLANDS_FTP_SERVERS}" ;; 352 norway*) VAL="${NORWAY_FTP_SERVERS}" ;; 353 poland*) VAL="${POLAND_FTP_SERVERS}" ;; 354 portugal*) VAL="${PORTUGAL_FTP_SERVERS}" ;; 355 romania*) VAL="${ROMAINIA_FTP_SERVERS}" ;; 356 russia*) VAL="${RUSSIA_FTP_SERVERS}" ;; 357 singapore*) VAL="${SINGAPORE_FTP_SERVERS}" ;; 358 slovak*) VAL="${SLOVAK_REPUBLIC_FTP_SERVERS}" ;; 359 slovenia*) VAL="${SLOVENIA_FTP_SERVERS}" ;; 360 *africa*) VAL="${SOUTH_AFRICA_FTP_SERVERS}" ;; 361 spain*) VAL="${SPAIN_FTP_SERVERS}" ;; 362 sweden*) VAL="${SWEDEN_FTP_SERVERS}" ;; 363 switzerland*) VAL="${SWITZERLAND_FTP_SERVERS}" ;; 364 taiwan*) VAL="${TAIWAN_FTP_SERVERS}" ;; 365 turkey*) VAL="${TURKEY_FTP_SERVERS}" ;; 366 ukraine*) VAL="${UKRAINE_FTP_SERVERS}" ;; 367 uk*) VAL="${UK_FTP_SERVERS}" ;; 368 usa*) VAL="${USA_FTP_SERVERS}" ;; 369 esac 370 else 371 VAL="${MAIN_FTP_SERVERS}" 372 VAL="${VAL}|${IPV6_FTP_SERVERS}" 373 VAL="${VAL}|${PRIMARY_FTP_SERVERS}" 374 VAL="${VAL}|${ARGENTINA_FTP_SERVERS}" 375 VAL="${VAL}|${AUSTRALIA_FTP_SERVERS}" 376 VAL="${VAL}|${AUSTRIA_FTP_SERVERS}" 377 VAL="${VAL}|${BRAZIL_FTP_SERVERS}" 378 VAL="${VAL}|${CANADA_FTP_SERVERS}" 379 VAL="${VAL}|${CHINA_FTP_SERVERS}" 380 VAL="${VAL}|${CROATIA_FTP_SERVERS}" 381 VAL="${VAL}|${CZECH_REPUBLIC_FTP_SERVERS}" 382 VAL="${VAL}|${DENMARK_FTP_SERVERS}" 383 VAL="${VAL}|${ESTONIA_FTP_SERVERS}" 384 VAL="${VAL}|${FINLAND_FTP_SERVERS}" 385 VAL="${VAL}|${FRANCE_FTP_SERVERS}" 386 VAL="${VAL}|${GERMANY_FTP_SERVERS}" 387 VAL="${VAL}|${GREECE_FTP_SERVERS}" 388 VAL="${VAL}|${HUNGARY_FTP_SERVERS}" 389 VAL="${VAL}|${ICELAND_FTP_SERVERS}" 390 VAL="${VAL}|${IRELAND_FTP_SERVERS}" 391 VAL="${VAL}|${ISRAEL_FTP_SERVERS}" 392 VAL="${VAL}|${ITALY_FTP_SERVERS}" 393 VAL="${VAL}|${JAPAN_FTP_SERVERS}" 394 VAL="${VAL}|${KOREA_FTP_SERVERS}" 395 VAL="${VAL}|${LITHUANIA_FTP_SERVERS}" 396 VAL="${VAL}|${NETHERLANDS_FTP_SERVERS}" 397 VAL="${VAL}|${NORWAY_FTP_SERVERS}" 398 VAL="${VAL}|${POLAND_FTP_SERVERS}" 399 VAL="${VAL}|${PORTUGAL_FTP_SERVERS}" 400 VAL="${VAL}|${ROMANIA_FTP_SERVERS}" 401 VAL="${VAL}|${RUSSIA_FTP_SERVERS}" 402 VAL="${VAL}|${SINGAPORE_FTP_SERVERS}" 403 VAL="${VAL}|${SLOVAK_REPUBLIC_FTP_SERVERS}" 404 VAL="${VAL}|${SLOVENIA_FTP_SERVERS}" 405 VAL="${VAL}|${SOUTH_AFRICA_FTP_SERVERS}" 406 VAL="${VAL}|${SPAIN_FTP_SERVERS}" 407 VAL="${VAL}|${SWEDEN_FTP_SERVERS}" 408 VAL="${VAL}|${SWITZERLAND_FTP_SERVERS}" 409 VAL="${VAL}|${TAIWAN_FTP_SERVERS}" 410 VAL="${VAL}|${TURKEY_FTP_SERVERS}" 411 VAL="${VAL}|${UKRAINE_FTP_SERVERS}" 412 VAL="${VAL}|${UK_FTP_SERVERS}" 413 VAL="${VAL}|${USA_FTP_SERVERS}" 414 fi 415 416 export VAL 417}; 418