Deleted Added
sdiff udiff text old ( 257788 ) new ( 257795 )
full compact
1if [ ! "$_MEDIA_HTTP_SUBR" ]; then _MEDIA_HTTP_SUBR=1
2#
3# Copyright (c) 2012-2013 Devin Teske
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:

--- 10 unchanged lines hidden (view full) ---

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: head/usr.sbin/bsdconfig/share/media/http.subr 257788 2013-11-07 10:40:19Z dteske $
28#
29############################################################ INCLUDES
30
31BSDCFG_SHARE="/usr/share/bsdconfig"
32. $BSDCFG_SHARE/common.subr || exit 1
33f_dprintf "%s: loading includes..." media/http.subr
34f_include $BSDCFG_SHARE/device.subr
35f_include $BSDCFG_SHARE/dialog.subr

--- 36 unchanged lines hidden (view full) ---

72#
73f_dialog_menu_media_http()
74{
75 f_dialog_title "$msg_please_select_a_freebsd_http_distribution_site"
76 local title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE"
77 f_dialog_title_restore
78 local prompt="$msg_please_select_the_site_closest_to_you_or_other"
79 local menu_list="
80 '$msg_main_site' 'ftp.freebsd.org'
81 'URL' '$msg_specify_some_other_http_site'
82 " # END-QUOTE
83 local hline="$msg_select_a_site_thats_close"
84
85 local height width rows
86 eval f_dialog_menu_size height width rows \
87 \"\$title\" \
88 \"\$btitle\" \

--- 227 unchanged lines hidden (view full) ---

316
317 setvar $VAR_HTTP_HOST "$hostname"
318 setvar $VAR_HTTP_PORT "$port"
319 setvar $VAR_HTTP_DIR "$dir"
320
321 device_http set type $DEVICE_TYPE_HTTP
322 device_http set init f_media_init_http
323 device_http set get f_media_get_http
324 device_http set shutdown :
325 device_http set private network
326 f_struct_copy device_http device_media
327 f_struct_free device_http
328
329 return $SUCCESS
330}
331
332# f_http_check_access [$connect_only]

--- 114 unchanged lines hidden (view full) ---

447# The [possibly] adjusted VAR_HTTP_PATH that was found to contain
448# a valid FreeBSD repository.
449#
450f_media_init_http()
451{
452 local dev="$1"
453 f_dprintf "Init routine called for HTTP device. dev=[%s]" "$dev"
454
455 #
456 # First verify access
457 #
458 local connect_only=1
459 f_http_check_access $connect_only
460
461 local http_host
462 f_getvar $VAR_HTTP_HOST http_host

--- 25 unchanged lines hidden (view full) ---

488 *)
489 #
490 # Ok, since we have a release variable, let's walk
491 # through the list of directories looking for a release
492 # directory. First successful path wins.
493 #
494 local fdir hp
495 f_getvar $VAR_HTTP_PATH%/ hp
496 for fdir in $HTTP_DIRS; do
497 setvar $VAR_HTTP_PATH "$hp/$fdir/$rel"
498 if f_http_check_access; then
499 http_found=$SUCCESS
500 break
501 fi
502 done
503 esac
504
505 [ $http_found -eq $SUCCESS ] && break
506
507 f_getvar $VAR_HTTP_PATH http_path
508 f_show_msg "$msg_please_check_the_url_and_try_again" \
509 "$http_path"
510
511 unset $VAR_HTTP_PATH
512 f_media_set_http || break
513 done
514
515 return $http_found
516}
517
518# f_media_get_http $device $file [$probe_type]
519#

--- 33 unchanged lines hidden (view full) ---

553
554 f_dprintf "f_media_get_http: dev=[%s] file=[%s] probe_type=%s" \
555 "$dev" "$file" "$probe_type"
556
557 local http_host http_port
558 f_getvar $VAR_HTTP_HOST http_host
559 f_getvar $VAR_HTTP_PORT http_port
560
561 if ! {
562 f_validate_ipaddr "$http_host" ||
563 f_validate_ipaddr6 "$http_host" ||
564 {
565 f_dprintf "%s: Looking up hostname, %s, using host(1)" \
566 "f_media_get_http" "$http_host"
567 f_host_lookup "$http_host" hosts
568 }

--- 77 unchanged lines hidden (view full) ---

646 5) f_show_msg "$msg_server_error_when_requesting_url" "$url" ;;
647 44) f_show_msg "$msg_url_was_not_found" "$url" ;;
648 4) f_show_msg "$msg_client_error" ;;
649 *) f_show_msg "$msg_error_when_requesting_url" "$url" ;;
650 esac
651 return $FAILURE
652}
653
654############################################################ MAIN
655
656f_dprintf "%s: Successfully loaded." media/http.subr
657
658fi # ! $_MEDIA_HTTP_SUBR