17323adacSDevin Teskeif [ ! "$_MEDIA_OPTIONS_SUBR" ]; then _MEDIA_OPTIONS_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/options.subr 337323adacSDevin Teskef_include $BSDCFG_SHARE/dialog.subr 347323adacSDevin Teskef_include $BSDCFG_SHARE/media/any.subr 351de60ff0SDevin Teskef_include $BSDCFG_SHARE/struct.subr 361de60ff0SDevin Teskef_include $BSDCFG_SHARE/variable.subr 377323adacSDevin Teske 387323adacSDevin TeskeBSDCFG_LIBE="/usr/libexec/bsdconfig" 397323adacSDevin Teskef_include_lang $BSDCFG_LIBE/include/messages.subr 407323adacSDevin Teske 417323adacSDevin TeskeOPTIONS_HELPFILE=$BSDCFG_LIBE/include/options.hlp 427323adacSDevin Teske 437323adacSDevin Teske############################################################ FUNCTIONS 447323adacSDevin Teske 457323adacSDevin Teske# f_media_options_menu 467323adacSDevin Teske# 477323adacSDevin Teske# Prompt the user to confirm/edit various media settings. Returns success. 487323adacSDevin Teske# 497323adacSDevin Teskef_media_options_menu() 507323adacSDevin Teske{ 517323adacSDevin Teske f_dialog_title "$msg_options_editor" 527323adacSDevin Teske local title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE" 537323adacSDevin Teske f_dialog_title_restore 54052f8969SDevin Teske local prompt= 55052f8969SDevin Teske local menu_list # Calculated below 56052f8969SDevin Teske local defaultitem= 577323adacSDevin Teske local hline="$hline_arrows_tab_enter" 587323adacSDevin Teske 597323adacSDevin Teske # 607323adacSDevin Teske # A hack so that the dialogs below are always interactive in a script 617323adacSDevin Teske # 627323adacSDevin Teske local old_interactive= 637323adacSDevin Teske if ! f_interactive; then 647323adacSDevin Teske f_getvar $VAR_NONINTERACTIVE old_interactive 657323adacSDevin Teske unset $VAR_NONINTERACTIVE 667323adacSDevin Teske fi 677323adacSDevin Teske 68052f8969SDevin Teske local cp 697323adacSDevin Teske while :; do 7051c41087SDevin Teske menu_list= 717323adacSDevin Teske 727323adacSDevin Teske f_getvar $VAR_NFS_SECURE cp 737323adacSDevin Teske if [ "$cp" = "YES" ]; then menu_list="$menu_list 747323adacSDevin Teske ' $msg_nfs_secure' 'YES' 757323adacSDevin Teske '$msg_nfs_server_talks_only_on_a_secure_port'" 767323adacSDevin Teske else menu_list="$menu_list 777323adacSDevin Teske ' $msg_nfs_secure' 'NO' 787323adacSDevin Teske '$msg_nfs_server_talks_only_on_a_secure_port'" 797323adacSDevin Teske fi 807323adacSDevin Teske 817323adacSDevin Teske f_getvar $VAR_SLOW_ETHER cp 827323adacSDevin Teske if [ "$cp" = "YES" ]; then menu_list="$menu_list 837323adacSDevin Teske ' $msg_nfs_slow' 'YES' 847323adacSDevin Teske '$msg_user_is_using_a_slow_pc_or_ethernet_card'" 857323adacSDevin Teske else menu_list="$menu_list 867323adacSDevin Teske ' $msg_nfs_slow' 'NO' 877323adacSDevin Teske '$msg_user_is_using_a_slow_pc_or_ethernet_card'" 887323adacSDevin Teske fi 897323adacSDevin Teske 907323adacSDevin Teske f_getvar $VAR_NFS_TCP cp 917323adacSDevin Teske if [ "$cp" = "YES" ]; then menu_list="$menu_list 927323adacSDevin Teske ' $msg_nfs_tcp' 'YES' '$msg_use_tcp_protocol_for_nfs'" 937323adacSDevin Teske else menu_list="$menu_list 947323adacSDevin Teske ' $msg_nfs_tcp' 'NO' '$msg_use_tcp_protocol_for_nfs'" 957323adacSDevin Teske fi 967323adacSDevin Teske 977323adacSDevin Teske f_getvar $VAR_NFS_V3 cp 987323adacSDevin Teske if [ "$cp" = "YES" ]; then menu_list="$menu_list 997323adacSDevin Teske ' $msg_nfs_version_3' 'YES' '$msg_use_nfs_version_3'" 1007323adacSDevin Teske else menu_list="$menu_list 1017323adacSDevin Teske ' $msg_nfs_version_3' 'NO' '$msg_use_nfs_version_3'" 1027323adacSDevin Teske fi 1037323adacSDevin Teske 1047323adacSDevin Teske f_getvar $VAR_DEBUG cp 1057323adacSDevin Teske if [ "$cp" ]; then menu_list="$menu_list 1067323adacSDevin Teske ' $msg_debugging' 'YES' 1077323adacSDevin Teske '$msg_emit_extra_debugging_output'" 1087323adacSDevin Teske else menu_list="$menu_list 1097323adacSDevin Teske ' $msg_debugging' 'NO' 1107323adacSDevin Teske '$msg_emit_extra_debugging_output'" 1117323adacSDevin Teske fi 1127323adacSDevin Teske 11387c16275SDevin Teske f_getvar $VAR_NO_CONFIRM cp 11487c16275SDevin Teske if [ "$cp" ]; then menu_list="$menu_list 11587c16275SDevin Teske ' $msg_yes_to_all' 'YES' 11687c16275SDevin Teske '$msg_assume_yes_to_all_non_critical_dialogs'" 11787c16275SDevin Teske else menu_list="$menu_list 11887c16275SDevin Teske ' $msg_yes_to_all' 'NO' 11987c16275SDevin Teske '$msg_assume_yes_to_all_non_critical_dialogs'" 12087c16275SDevin Teske fi 12187c16275SDevin Teske 1227323adacSDevin Teske f_getvar $VAR_TRY_DHCP cp 1237323adacSDevin Teske if [ "$cp" = "YES" ]; then menu_list="$menu_list 1247323adacSDevin Teske ' $msg_dhcp' 'YES' 1257323adacSDevin Teske '$msg_attempt_automatic_dhcp_configuration'" 1267323adacSDevin Teske else menu_list="$menu_list 1277323adacSDevin Teske ' $msg_dhcp' 'NO' 1287323adacSDevin Teske '$msg_attempt_automatic_dhcp_configuration'" 1297323adacSDevin Teske fi 1307323adacSDevin Teske 1317323adacSDevin Teske f_getvar $VAR_TRY_RTSOL cp 1327323adacSDevin Teske if [ "$cp" = "YES" ]; then menu_list="$menu_list 1337323adacSDevin Teske ' $msg_ipv6' 'YES' 1347323adacSDevin Teske '$msg_attempt_ipv6_configuration_of_interfaces'" 1357323adacSDevin Teske else menu_list="$menu_list 1367323adacSDevin Teske ' $msg_ipv6' 'NO' 1377323adacSDevin Teske '$msg_attempt_ipv6_configuration_of_interfaces'" 1387323adacSDevin Teske fi 1397323adacSDevin Teske 1407323adacSDevin Teske f_getvar $VAR_EDITOR cp 1417323adacSDevin Teske menu_list="$menu_list 1427323adacSDevin Teske ' $msg_editor' '$cp' '$msg_which_text_editor_to_use'" 1437323adacSDevin Teske 1447323adacSDevin Teske f_getvar $VAR_RELNAME cp 1457323adacSDevin Teske menu_list="$menu_list 1467323adacSDevin Teske ' $msg_release_name' '$cp' 1477323adacSDevin Teske '$msg_which_release_to_attempt_to_load'" 1487323adacSDevin Teske 1497323adacSDevin Teske if f_struct device_media; then 1507323adacSDevin Teske device_media get type cp 1517323adacSDevin Teske case "$cp" in 1527323adacSDevin Teske $DEVICE_TYPE_UFS|$DEVICE_TYPE_DISK) 1537323adacSDevin Teske cp="$msg_file_system" ;; 15466badff9SDevin Teske $DEVICE_TYPE_DIRECTORY) cp="$msg_directory" ;; 15566badff9SDevin Teske $DEVICE_TYPE_HTTP_PROXY) cp="$msg_http_proxy" ;; 15647b73aa2SDevin Teske $DEVICE_TYPE_HTTP) cp="$msg_http_direct" ;; 15766badff9SDevin Teske $DEVICE_TYPE_CDROM) cp="$msg_cdrom" ;; 15866badff9SDevin Teske $DEVICE_TYPE_USB) cp="$msg_usb" ;; 15966badff9SDevin Teske $DEVICE_TYPE_DOS) cp="$msg_dos" ;; 16066badff9SDevin Teske $DEVICE_TYPE_NFS) cp="$msg_nfs" ;; 1617323adacSDevin Teske *) 1627323adacSDevin Teske cp="<$msg_unknown>" 1637323adacSDevin Teske esac 1647323adacSDevin Teske else 1657323adacSDevin Teske cp="<$msg_not_yet_set>" 1667323adacSDevin Teske fi 1677323adacSDevin Teske menu_list="$menu_list 1687323adacSDevin Teske ' $msg_media_type' '$cp' 1697323adacSDevin Teske '$msg_the_current_installation_media_type'" 1707323adacSDevin Teske 1717323adacSDevin Teske f_getvar $VAR_MEDIA_TIMEOUT cp 1727323adacSDevin Teske menu_list="$menu_list 1737323adacSDevin Teske ' $msg_media_timeout' '$cp' 1747323adacSDevin Teske '$msg_timeout_value_in_seconds_for_slow_media'" 1757323adacSDevin Teske 17687c16275SDevin Teske f_getvar $VAR_PKG_TMPDIR cp 17787c16275SDevin Teske menu_list="$menu_list 17887c16275SDevin Teske ' $msg_package_temp' '$cp' 17987c16275SDevin Teske '$msg_directory_where_package_temporary_files_go'" 18087c16275SDevin Teske 1817323adacSDevin Teske menu_list="$menu_list 1827323adacSDevin Teske ' $msg_rescan_devices' '<*>' 1837323adacSDevin Teske '$msg_rerun_bsdconfig_initial_device_probe' 1847323adacSDevin Teske ' $msg_use_defaults' '[${msg_reset}]' 1857323adacSDevin Teske '$msg_reset_all_values_to_startup_defaults' 1867323adacSDevin Teske " # END-QUOTE 1877323adacSDevin Teske 18874036c4dSDevin Teske local height width rows 18974036c4dSDevin Teske eval f_dialog_menu_with_help_size height width rows \ 1907323adacSDevin Teske \"\$title\" \ 1917323adacSDevin Teske \"\$btitle\" \ 1927323adacSDevin Teske \"\$prompt\" \ 1937323adacSDevin Teske \"\$hline\" \ 19474036c4dSDevin Teske $menu_list 1957323adacSDevin Teske 196fd962ac6SDevin Teske local mtag 197fd962ac6SDevin Teske mtag=$( eval $DIALOG \ 1987323adacSDevin Teske --title \"\$title\" \ 1997323adacSDevin Teske --backtitle \"\$btitle\" \ 2007323adacSDevin Teske --hline \"\$hline\" \ 2017323adacSDevin Teske --item-help \ 2027323adacSDevin Teske --ok-label \"\$msg_ok\" \ 2037323adacSDevin Teske --cancel-label \"\$msg_done\" \ 2047323adacSDevin Teske --help-button \ 2057323adacSDevin Teske --help-label \"\$msg_help\" \ 206d3a0f918SDevin Teske --default-item \"\$defaultitem\" \ 2077323adacSDevin Teske ${USE_XDIALOG:+--help \"\"} \ 20874036c4dSDevin Teske --menu \"\$prompt\" \ 20974036c4dSDevin Teske $height $width $rows \ 21074036c4dSDevin Teske $menu_list \ 2117323adacSDevin Teske 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 2127323adacSDevin Teske ) 2137323adacSDevin Teske local retval=$? 214fd962ac6SDevin Teske f_dialog_data_sanitize mtag 215fd962ac6SDevin Teske defaultitem="$mtag" 2167323adacSDevin Teske f_dprintf "retval=%s mtag=[%s]" $retval "$mtag" 2177323adacSDevin Teske 218*f677a9e2SDevin Teske if [ $retval -eq $DIALOG_HELP ]; then 2197323adacSDevin Teske f_show_help "$OPTIONS_HELPFILE" 2207323adacSDevin Teske continue 221*f677a9e2SDevin Teske elif [ $retval -ne $DIALOG_OK ]; then 2227323adacSDevin Teske break # to success 2237323adacSDevin Teske fi 2247323adacSDevin Teske 2257323adacSDevin Teske case "$mtag" in 2267323adacSDevin Teske " $msg_nfs_secure") 2277323adacSDevin Teske f_getvar $VAR_NFS_SECURE cp 2287323adacSDevin Teske if [ "$cp" = "YES" ]; then 2297323adacSDevin Teske export $VAR_NFS_SECURE="NO" 2307323adacSDevin Teske else 2317323adacSDevin Teske export $VAR_NFS_SECURE="YES" 2327323adacSDevin Teske fi ;; 2337323adacSDevin Teske " $msg_nfs_slow") 2347323adacSDevin Teske f_getvar $VAR_SLOW_ETHER cp 2357323adacSDevin Teske if [ "$cp" = "YES" ]; then 2367323adacSDevin Teske export $VAR_SLOW_ETHER="NO" 2377323adacSDevin Teske else 2387323adacSDevin Teske export $VAR_SLOW_ETHER="YES" 2397323adacSDevin Teske fi ;; 2407323adacSDevin Teske " $msg_nfs_tcp") 2417323adacSDevin Teske f_getvar $VAR_NFS_TCP cp 2427323adacSDevin Teske if [ "$cp" = "YES" ]; then 2437323adacSDevin Teske export $VAR_NFS_TCP="NO" 2447323adacSDevin Teske else 2457323adacSDevin Teske export $VAR_NFS_TCP="YES" 2467323adacSDevin Teske fi ;; 2477323adacSDevin Teske " $msg_nfs_version_3") 2487323adacSDevin Teske f_getvar $VAR_NFS_V3 cp 2497323adacSDevin Teske if [ "$cp" = "YES" ]; then 2507323adacSDevin Teske export $VAR_NFS_V3="NO" 2517323adacSDevin Teske else 2527323adacSDevin Teske export $VAR_NFS_V3="YES" 2537323adacSDevin Teske fi ;; 2547323adacSDevin Teske " $msg_debugging") 2557323adacSDevin Teske if f_getvar $VAR_DEBUG cp && [ "$cp" ]; then 2567323adacSDevin Teske unset $VAR_DEBUG 2577323adacSDevin Teske else 2587323adacSDevin Teske export $VAR_DEBUG=1 2597323adacSDevin Teske fi ;; 26087c16275SDevin Teske " $msg_yes_to_all") 26187c16275SDevin Teske if f_getvar $VAR_NO_CONFIRM cp && [ "$cp" ]; then 26287c16275SDevin Teske unset $VAR_NO_CONFIRM 26387c16275SDevin Teske else 26487c16275SDevin Teske export $VAR_NO_CONFIRM=1 26587c16275SDevin Teske fi ;; 2667323adacSDevin Teske " $msg_dhcp") 2677323adacSDevin Teske f_getvar $VAR_TRY_DHCP cp 2687323adacSDevin Teske if [ "$cp" = "YES" ]; then 2697323adacSDevin Teske export $VAR_TRY_DHCP="NO" 2707323adacSDevin Teske else 2717323adacSDevin Teske export $VAR_TRY_DHCP="YES" 2727323adacSDevin Teske fi ;; 2737323adacSDevin Teske " $msg_ipv6") 2747323adacSDevin Teske f_getvar $VAR_TRY_RTSOL cp 2757323adacSDevin Teske if [ "$cp" = "YES" ]; then 2767323adacSDevin Teske export $VAR_TRY_RTSOL="NO" 2777323adacSDevin Teske else 2787323adacSDevin Teske export $VAR_TRY_RTSOL="YES" 2797323adacSDevin Teske fi ;; 2807323adacSDevin Teske " $msg_editor") 2817323adacSDevin Teske f_variable_get_value $VAR_EDITOR \ 2827323adacSDevin Teske "$msg_please_specify_the_name_of_the_text_editor" 2837323adacSDevin Teske ;; 2847323adacSDevin Teske " $msg_release_name") 2857323adacSDevin Teske f_variable_get_value $VAR_RELNAME \ 2867323adacSDevin Teske "$msg_please_specify_the_release_you_wish_to_load" 2877323adacSDevin Teske ;; 2887323adacSDevin Teske " $msg_media_type") 2897323adacSDevin Teske f_media_get_type ;; 2907323adacSDevin Teske " $msg_media_timeout") 2917323adacSDevin Teske f_variable_get_value $VAR_MEDIA_TIMEOUT \ 2927323adacSDevin Teske "$msg_please_specify_the_number_of_seconds_to_wait" 2937323adacSDevin Teske ;; 29487c16275SDevin Teske " $msg_package_temp") 29587c16275SDevin Teske f_variable_get_value $VAR_PKG_TMPDIR \ 29687c16275SDevin Teske "$msg_please_specify_a_temporary_directory" 29787c16275SDevin Teske ;; 2987323adacSDevin Teske " $msg_rescan_devices") 2997323adacSDevin Teske f_device_rescan ;; 3007323adacSDevin Teske " $msg_use_defaults") 3017323adacSDevin Teske f_variable_set_defaults ;; 3027323adacSDevin Teske esac 3037323adacSDevin Teske done 3047323adacSDevin Teske 3057323adacSDevin Teske # Restore old VAR_NONINTERACTIVE if needed. 3067323adacSDevin Teske [ "$old_interactive" ] && 3077323adacSDevin Teske setvar $VAR_NONINTERACTIVE "$old_interactive" 3087323adacSDevin Teske 3097323adacSDevin Teske return $SUCCESS 3107323adacSDevin Teske} 3117323adacSDevin Teske 3127323adacSDevin Teske############################################################ MAIN 3137323adacSDevin Teske 3147323adacSDevin Teskef_dprintf "%s: Successfully loaded." media/options.subr 3157323adacSDevin Teske 3167323adacSDevin Teskefi # ! $_MEDIA_OPTIONS_SUBR 317