17323adacSDevin Teskeif [ ! "$_MEDIA_ANY_SUBR" ]; then _MEDIA_ANY_SUBR=1 27323adacSDevin Teske# 37323adacSDevin Teske# Copyright (c) 2012-2013 Devin Teske 47323adacSDevin 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 167323adacSDevin 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 207323adacSDevin Teske# DAMAGES (INLUDING, 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# $FreeBSD$ 287323adacSDevin Teske# 297323adacSDevin Teske############################################################ INCLUDES 307323adacSDevin Teske 317323adacSDevin TeskeBSDCFG_SHARE="/usr/share/bsdconfig" 327323adacSDevin Teske. $BSDCFG_SHARE/common.subr || exit 1 337323adacSDevin Teskef_dprintf "%s: loading includes..." media/any.subr 347323adacSDevin Teskef_include $BSDCFG_SHARE/dialog.subr 357323adacSDevin Teskef_include $BSDCFG_SHARE/media/cdrom.subr 367323adacSDevin Teskef_include $BSDCFG_SHARE/media/directory.subr 377323adacSDevin Teskef_include $BSDCFG_SHARE/media/dos.subr 387323adacSDevin Teskef_include $BSDCFG_SHARE/media/floppy.subr 397323adacSDevin Teskef_include $BSDCFG_SHARE/media/ftp.subr 407323adacSDevin Teskef_include $BSDCFG_SHARE/media/httpproxy.subr 417323adacSDevin Teskef_include $BSDCFG_SHARE/media/nfs.subr 427323adacSDevin Teskef_include $BSDCFG_SHARE/media/options.subr 437323adacSDevin Teskef_include $BSDCFG_SHARE/media/ufs.subr 447323adacSDevin Teskef_include $BSDCFG_SHARE/media/usb.subr 45*1de60ff0SDevin Teskef_include $BSDCFG_SHARE/struct.subr 467323adacSDevin Teske 477323adacSDevin TeskeBSDCFG_LIBE="/usr/libexec/bsdconfig" 487323adacSDevin Teskef_include_lang $BSDCFG_LIBE/include/messages.subr 497323adacSDevin Teske 507323adacSDevin TeskeMEDIA_HELPFILE=$BSDCFG_LIBE/include/media.hlp 517323adacSDevin Teske 527323adacSDevin Teske############################################################ FUNCTIONS 537323adacSDevin Teske 547323adacSDevin Teske# f_media_get_type 557323adacSDevin Teske# 567323adacSDevin Teske# Prompt the user to select amongst the known media types (included above). 577323adacSDevin Teske# 587323adacSDevin Teske# If the user does not cancel or press Esc, invokes the f_media_set_* function 597323adacSDevin Teske# associated with the chosen media type. If after all that we have a struct 607323adacSDevin Teske# named `device_media' then success is returned, otherwise failure. 617323adacSDevin Teske# 627323adacSDevin Teske# NOTE: The f_media_set_* function should create the `device_media' struct. 637323adacSDevin Teske# See `struct.subr' and the above `media/*.subr' includes for more details. 647323adacSDevin Teske# 657323adacSDevin Teskef_media_get_type() 667323adacSDevin Teske{ 677323adacSDevin Teske f_dialog_title "$msg_choose_installation_media" 687323adacSDevin Teske local title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE" 697323adacSDevin Teske f_dialog_title_restore 707323adacSDevin Teske local prompt="$msg_choose_installation_media_description" 71052f8969SDevin Teske local menu_list=" 727323adacSDevin Teske '1 $msg_cd_dvd' '$msg_install_from_a_freebsd_cd_dvd' 737323adacSDevin Teske '2 $msg_ftp' '$msg_install_from_an_ftp_server' 747323adacSDevin Teske '3 $msg_ftp_passive' 757323adacSDevin Teske '$msg_install_from_an_ftp_server_thru_firewall' 767323adacSDevin Teske '4 $msg_http' '$msg_install_from_an_ftp_server_thru_proxy' 777323adacSDevin Teske '5 $msg_directory' '$msg_install_from_the_existing_filesystem' 787323adacSDevin Teske '6 $msg_nfs' '$msg_install_over_nfs' 797323adacSDevin Teske '7 $msg_dos' '$msg_install_from_a_dos_partition' 807323adacSDevin Teske '8 $msg_ufs' '$msg_install_from_a_ufs_partition' 817323adacSDevin Teske '9 $msg_floppy' '$msg_install_from_a_floppy_disk_set' 827323adacSDevin Teske 'A $msg_usb' '$msg_install_from_a_usb_drive' 837323adacSDevin Teske 'X $msg_options' '$msg_view_set_various_media_options' 847323adacSDevin Teske " # END-QUOTE 85052f8969SDevin Teske local hline="$hline_choose_help_for_more_information_on_media_types" 867323adacSDevin Teske 8774036c4dSDevin Teske local height width rows 8874036c4dSDevin Teske eval f_dialog_menu_size height width rows \ 897323adacSDevin Teske \"\$title\" \ 907323adacSDevin Teske \"\$btitle\" \ 917323adacSDevin Teske \"\$prompt\" \ 927323adacSDevin Teske \"\$hline\" \ 9374036c4dSDevin Teske $menu_list 947323adacSDevin Teske 95fd962ac6SDevin Teske local mtag 967323adacSDevin Teske while :; do 97fd962ac6SDevin Teske mtag=$( eval $DIALOG \ 987323adacSDevin Teske --title \"\$title\" \ 997323adacSDevin Teske --backtitle \"\$btitle\" \ 1007323adacSDevin Teske --hline \"\$hline\" \ 1017323adacSDevin Teske --ok-label \"\$msg_ok\" \ 1027323adacSDevin Teske --cancel-label \"\$msg_cancel\" \ 1037323adacSDevin Teske --help-button \ 1047323adacSDevin Teske --help-label \"\$msg_help\" \ 1057323adacSDevin Teske ${USE_XDIALOG:+--help \"\"} \ 10674036c4dSDevin Teske --menu \"\$prompt\" \ 10774036c4dSDevin Teske $height $width $rows \ 10874036c4dSDevin Teske $menu_list \ 1097323adacSDevin Teske 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 1107323adacSDevin Teske ) 1117323adacSDevin Teske local retval=$? 112fd962ac6SDevin Teske f_dialog_data_sanitize mtag 1137323adacSDevin Teske f_dprintf "retval=%s mtag=[%s]" $retval "$mtag" 1147323adacSDevin Teske 1157323adacSDevin Teske if [ $retval -eq 2 ]; then 1167323adacSDevin Teske # The Help button was pressed 1177323adacSDevin Teske f_show_help "$MEDIA_HELPFILE" 1187323adacSDevin Teske continue 1197323adacSDevin Teske elif [ $retval -ne 0 ]; then 1207323adacSDevin Teske return $FAILURE 1217323adacSDevin Teske fi 1227323adacSDevin Teske 1237323adacSDevin Teske case "$mtag" in 1247323adacSDevin Teske ?" $msg_cd_dvd") f_media_set_cdrom ;; 125f184cec5SDevin Teske ?" $msg_ftp") f_media_set_ftp ;; 1267323adacSDevin Teske ?" $msg_ftp_passive") f_media_set_ftp_passive ;; 1277323adacSDevin Teske ?" $msg_http") f_media_set_http_proxy ;; 1287323adacSDevin Teske ?" $msg_directory") f_media_set_directory ;; 1297323adacSDevin Teske ?" $msg_dos") f_media_set_dos ;; 1307323adacSDevin Teske ?" $msg_nfs") f_media_set_nfs ;; 1317323adacSDevin Teske ?" $msg_ufs") f_media_set_ufs ;; 1327323adacSDevin Teske ?" $msg_floppy") f_media_set_floppy ;; 1337323adacSDevin Teske ?" $msg_usb") f_media_set_usb ;; 1347323adacSDevin Teske ?" $msg_options") 1357323adacSDevin Teske f_media_options_menu 1367323adacSDevin Teske continue 1377323adacSDevin Teske ;; 1387323adacSDevin Teske esac 1397323adacSDevin Teske break 1407323adacSDevin Teske done 1417323adacSDevin Teske 1427323adacSDevin Teske f_struct device_media || return $FAILURE 1437323adacSDevin Teske} 1447323adacSDevin Teske 1457323adacSDevin Teske############################################################ MAIN 1467323adacSDevin Teske 1477323adacSDevin Teskef_dprintf "%s: Successfully loaded." media/any.subr 1487323adacSDevin Teske 1497323adacSDevin Teskefi # ! $_MEDIA_ANY_SUBR 150