17323adacSDevin Teskeif [ ! "$_MEDIA_ANY_SUBR" ]; then _MEDIA_ANY_SUBR=1 27323adacSDevin Teske# 37323adacSDevin Teske# Copyright (c) 2012-2013 Devin Teske 4f8ea072aSDevin Teske# All rights reserved. 57323adacSDevin Teske# 67323adacSDevin Teske# Redistribution and use in source and binary forms, with or without 77323adacSDevin Teske# modification, are permitted provided that the following conditions 87323adacSDevin Teske# are met: 97323adacSDevin Teske# 1. Redistributions of source code must retain the above copyright 107323adacSDevin Teske# notice, this list of conditions and the following disclaimer. 117323adacSDevin Teske# 2. Redistributions in binary form must reproduce the above copyright 127323adacSDevin Teske# notice, this list of conditions and the following disclaimer in the 137323adacSDevin Teske# documentation and/or other materials provided with the distribution. 147323adacSDevin Teske# 157323adacSDevin Teske# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 168e37a7c8SDevin Teske# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 177323adacSDevin Teske# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 187323adacSDevin Teske# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 197323adacSDevin Teske# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 208e37a7c8SDevin Teske# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 217323adacSDevin Teske# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 227323adacSDevin Teske# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 237323adacSDevin Teske# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 247323adacSDevin Teske# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 257323adacSDevin Teske# SUCH DAMAGE. 267323adacSDevin Teske# 277323adacSDevin Teske# 287323adacSDevin Teske############################################################ INCLUDES 297323adacSDevin Teske 307323adacSDevin TeskeBSDCFG_SHARE="/usr/share/bsdconfig" 317323adacSDevin Teske. $BSDCFG_SHARE/common.subr || exit 1 327323adacSDevin Teskef_dprintf "%s: loading includes..." media/any.subr 337323adacSDevin Teskef_include $BSDCFG_SHARE/dialog.subr 347323adacSDevin Teskef_include $BSDCFG_SHARE/media/cdrom.subr 357323adacSDevin Teskef_include $BSDCFG_SHARE/media/directory.subr 367323adacSDevin Teskef_include $BSDCFG_SHARE/media/dos.subr 3747b73aa2SDevin Teskef_include $BSDCFG_SHARE/media/http.subr 387323adacSDevin Teskef_include $BSDCFG_SHARE/media/httpproxy.subr 397323adacSDevin Teskef_include $BSDCFG_SHARE/media/nfs.subr 407323adacSDevin Teskef_include $BSDCFG_SHARE/media/options.subr 417323adacSDevin Teskef_include $BSDCFG_SHARE/media/ufs.subr 427323adacSDevin Teskef_include $BSDCFG_SHARE/media/usb.subr 431de60ff0SDevin Teskef_include $BSDCFG_SHARE/struct.subr 447323adacSDevin Teske 457323adacSDevin TeskeBSDCFG_LIBE="/usr/libexec/bsdconfig" 467323adacSDevin Teskef_include_lang $BSDCFG_LIBE/include/messages.subr 477323adacSDevin Teske 487323adacSDevin TeskeMEDIA_HELPFILE=$BSDCFG_LIBE/include/media.hlp 497323adacSDevin Teske 507323adacSDevin Teske############################################################ FUNCTIONS 517323adacSDevin Teske 527323adacSDevin Teske# f_media_get_type 537323adacSDevin Teske# 547323adacSDevin Teske# Prompt the user to select amongst the known media types (included above). 557323adacSDevin Teske# 567323adacSDevin Teske# If the user does not cancel or press Esc, invokes the f_media_set_* function 577323adacSDevin Teske# associated with the chosen media type. If after all that we have a struct 587323adacSDevin Teske# named `device_media' then success is returned, otherwise failure. 597323adacSDevin Teske# 607323adacSDevin Teske# NOTE: The f_media_set_* function should create the `device_media' struct. 617323adacSDevin Teske# See `struct.subr' and the above `media/*.subr' includes for more details. 627323adacSDevin Teske# 637323adacSDevin Teskef_media_get_type() 647323adacSDevin Teske{ 657323adacSDevin Teske f_dialog_title "$msg_choose_installation_media" 667323adacSDevin Teske local title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE" 677323adacSDevin Teske f_dialog_title_restore 687323adacSDevin Teske local prompt="$msg_choose_installation_media_description" 69052f8969SDevin Teske local menu_list=" 707323adacSDevin Teske '1 $msg_cd_dvd' '$msg_install_from_a_freebsd_cd_dvd' 71*5e7aa757SBaptiste Daroussin '2 $msg_http_proxy' 7247b73aa2SDevin Teske '$msg_install_from_an_ftp_server_thru_proxy' 73*5e7aa757SBaptiste Daroussin '3 $msg_http_direct' '$msg_install_from_an_http_server' 74*5e7aa757SBaptiste Daroussin '4 $msg_directory' '$msg_install_from_the_existing_filesystem' 757323adacSDevin Teske '6 $msg_nfs' '$msg_install_over_nfs' 76*5e7aa757SBaptiste Daroussin '6 $msg_dos' '$msg_install_from_a_dos_partition' 77*5e7aa757SBaptiste Daroussin '7 $msg_ufs' '$msg_install_from_a_ufs_partition' 78*5e7aa757SBaptiste Daroussin '8 $msg_usb' '$msg_install_from_a_usb_drive' 797323adacSDevin Teske 'X $msg_options' '$msg_view_set_various_media_options' 807323adacSDevin Teske " # END-QUOTE 81052f8969SDevin Teske local hline="$hline_choose_help_for_more_information_on_media_types" 827323adacSDevin Teske 8374036c4dSDevin Teske local height width rows 8474036c4dSDevin Teske eval f_dialog_menu_size height width rows \ 857323adacSDevin Teske \"\$title\" \ 867323adacSDevin Teske \"\$btitle\" \ 877323adacSDevin Teske \"\$prompt\" \ 887323adacSDevin Teske \"\$hline\" \ 8974036c4dSDevin Teske $menu_list 907323adacSDevin Teske 91fd962ac6SDevin Teske local mtag 927323adacSDevin Teske while :; do 93fd962ac6SDevin Teske mtag=$( eval $DIALOG \ 947323adacSDevin Teske --title \"\$title\" \ 957323adacSDevin Teske --backtitle \"\$btitle\" \ 967323adacSDevin Teske --hline \"\$hline\" \ 977323adacSDevin Teske --ok-label \"\$msg_ok\" \ 987323adacSDevin Teske --cancel-label \"\$msg_cancel\" \ 997323adacSDevin Teske --help-button \ 1007323adacSDevin Teske --help-label \"\$msg_help\" \ 1017323adacSDevin Teske ${USE_XDIALOG:+--help \"\"} \ 10274036c4dSDevin Teske --menu \"\$prompt\" \ 10374036c4dSDevin Teske $height $width $rows \ 10474036c4dSDevin Teske $menu_list \ 1057323adacSDevin Teske 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 1067323adacSDevin Teske ) 1077323adacSDevin Teske local retval=$? 108fd962ac6SDevin Teske f_dialog_data_sanitize mtag 1097323adacSDevin Teske f_dprintf "retval=%s mtag=[%s]" $retval "$mtag" 1107323adacSDevin Teske 111f677a9e2SDevin Teske if [ $retval -eq $DIALOG_HELP ]; then 1127323adacSDevin Teske f_show_help "$MEDIA_HELPFILE" 1137323adacSDevin Teske continue 114f677a9e2SDevin Teske elif [ $retval -ne $DIALOG_OK ]; then 1157323adacSDevin Teske return $FAILURE 1167323adacSDevin Teske fi 1177323adacSDevin Teske 1187323adacSDevin Teske case "$mtag" in 1197323adacSDevin Teske ?" $msg_cd_dvd") f_media_set_cdrom ;; 12047b73aa2SDevin Teske ?" $msg_http_proxy") f_media_set_http_proxy ;; 12147b73aa2SDevin Teske ?" $msg_http_direct") f_media_set_http ;; 1227323adacSDevin Teske ?" $msg_directory") f_media_set_directory ;; 1237323adacSDevin Teske ?" $msg_dos") f_media_set_dos ;; 1247323adacSDevin Teske ?" $msg_nfs") f_media_set_nfs ;; 1257323adacSDevin Teske ?" $msg_ufs") f_media_set_ufs ;; 1267323adacSDevin Teske ?" $msg_usb") f_media_set_usb ;; 1277323adacSDevin Teske ?" $msg_options") 1287323adacSDevin Teske f_media_options_menu 1297323adacSDevin Teske continue 1307323adacSDevin Teske ;; 1317323adacSDevin Teske esac 1327323adacSDevin Teske break 1337323adacSDevin Teske done 1347323adacSDevin Teske 1357323adacSDevin Teske f_struct device_media || return $FAILURE 1367323adacSDevin Teske} 1377323adacSDevin Teske 1387323adacSDevin Teske############################################################ MAIN 1397323adacSDevin Teske 1407323adacSDevin Teskef_dprintf "%s: Successfully loaded." media/any.subr 1417323adacSDevin Teske 1427323adacSDevin Teskefi # ! $_MEDIA_ANY_SUBR 143