1 if [ ! "$_MEDIA_ANY_SUBR" ]; then _MEDIA_ANY_SUBR=1
3 # Copyright (c) 2012-2013 Devin Teske
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
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
29 ############################################################ INCLUDES
31 BSDCFG_SHARE="/usr/share/bsdconfig"
32 . $BSDCFG_SHARE/common.subr || exit 1
33 f_dprintf "%s: loading includes..." media/any.subr
34 f_include $BSDCFG_SHARE/dialog.subr
35 f_include $BSDCFG_SHARE/media/cdrom.subr
36 f_include $BSDCFG_SHARE/media/directory.subr
37 f_include $BSDCFG_SHARE/media/dos.subr
38 f_include $BSDCFG_SHARE/media/floppy.subr
39 f_include $BSDCFG_SHARE/media/ftp.subr
40 f_include $BSDCFG_SHARE/media/http.subr
41 f_include $BSDCFG_SHARE/media/httpproxy.subr
42 f_include $BSDCFG_SHARE/media/nfs.subr
43 f_include $BSDCFG_SHARE/media/options.subr
44 f_include $BSDCFG_SHARE/media/ufs.subr
45 f_include $BSDCFG_SHARE/media/usb.subr
46 f_include $BSDCFG_SHARE/struct.subr
48 BSDCFG_LIBE="/usr/libexec/bsdconfig"
49 f_include_lang $BSDCFG_LIBE/include/messages.subr
51 MEDIA_HELPFILE=$BSDCFG_LIBE/include/media.hlp
53 ############################################################ FUNCTIONS
57 # Prompt the user to select amongst the known media types (included above).
59 # If the user does not cancel or press Esc, invokes the f_media_set_* function
60 # associated with the chosen media type. If after all that we have a struct
61 # named `device_media' then success is returned, otherwise failure.
63 # NOTE: The f_media_set_* function should create the `device_media' struct.
64 # See `struct.subr' and the above `media/*.subr' includes for more details.
68 f_dialog_title "$msg_choose_installation_media"
69 local title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE"
70 f_dialog_title_restore
71 local prompt="$msg_choose_installation_media_description"
73 '1 $msg_cd_dvd' '$msg_install_from_a_freebsd_cd_dvd'
74 '2 $msg_ftp' '$msg_install_from_an_ftp_server'
76 '$msg_install_from_an_ftp_server_thru_proxy'
77 '4 $msg_http_direct' '$msg_install_from_an_http_server'
78 '5 $msg_directory' '$msg_install_from_the_existing_filesystem'
79 '6 $msg_nfs' '$msg_install_over_nfs'
80 '7 $msg_dos' '$msg_install_from_a_dos_partition'
81 '8 $msg_ufs' '$msg_install_from_a_ufs_partition'
82 '9 $msg_floppy' '$msg_install_from_a_floppy_disk_set'
83 'A $msg_usb' '$msg_install_from_a_usb_drive'
84 'X $msg_options' '$msg_view_set_various_media_options'
86 local hline="$hline_choose_help_for_more_information_on_media_types"
88 local height width rows
89 eval f_dialog_menu_size height width rows \
98 mtag=$( eval $DIALOG \
100 --backtitle \"\$btitle\" \
101 --hline \"\$hline\" \
102 --ok-label \"\$msg_ok\" \
103 --cancel-label \"\$msg_cancel\" \
105 --help-label \"\$msg_help\" \
106 ${USE_XDIALOG:+--help \"\"} \
107 --menu \"\$prompt\" \
108 $height $width $rows \
110 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
113 f_dialog_data_sanitize mtag
114 f_dprintf "retval=%s mtag=[%s]" $retval "$mtag"
116 if [ $retval -eq 2 ]; then
117 # The Help button was pressed
118 f_show_help "$MEDIA_HELPFILE"
120 elif [ $retval -ne 0 ]; then
125 ?" $msg_cd_dvd") f_media_set_cdrom ;;
126 ?" $msg_ftp") f_media_set_ftp ;;
127 ?" $msg_http_proxy") f_media_set_http_proxy ;;
128 ?" $msg_http_direct") f_media_set_http ;;
129 ?" $msg_directory") f_media_set_directory ;;
130 ?" $msg_dos") f_media_set_dos ;;
131 ?" $msg_nfs") f_media_set_nfs ;;
132 ?" $msg_ufs") f_media_set_ufs ;;
133 ?" $msg_floppy") f_media_set_floppy ;;
134 ?" $msg_usb") f_media_set_usb ;;
143 f_struct device_media || return $FAILURE
146 ############################################################ MAIN
148 f_dprintf "%s: Successfully loaded." media/any.subr
150 fi # ! $_MEDIA_ANY_SUBR