17323adacSDevin Teskeif [ ! "$_MEDIA_OPTIONS_SUBR" ]; then _MEDIA_OPTIONS_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/options.subr 347323adacSDevin Teskef_include $BSDCFG_SHARE/dialog.subr 357323adacSDevin Teskef_include $BSDCFG_SHARE/struct.subr 367323adacSDevin Teskef_include $BSDCFG_SHARE/variable.subr 377323adacSDevin Teskef_include $BSDCFG_SHARE/media/any.subr 387323adacSDevin Teskef_include $BSDCFG_SHARE/media/ftp.subr 397323adacSDevin Teske 407323adacSDevin TeskeBSDCFG_LIBE="/usr/libexec/bsdconfig" 417323adacSDevin Teskef_include_lang $BSDCFG_LIBE/include/messages.subr 427323adacSDevin Teske 437323adacSDevin TeskeOPTIONS_HELPFILE=$BSDCFG_LIBE/include/options.hlp 447323adacSDevin Teske 457323adacSDevin Teske############################################################ FUNCTIONS 467323adacSDevin Teske 477323adacSDevin Teske# f_media_options_menu 487323adacSDevin Teske# 497323adacSDevin Teske# Prompt the user to confirm/edit various media settings. Returns success. 507323adacSDevin Teske# 517323adacSDevin Teskef_media_options_menu() 527323adacSDevin Teske{ 537323adacSDevin Teske f_dialog_title "$msg_options_editor" 547323adacSDevin Teske local title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE" 557323adacSDevin Teske f_dialog_title_restore 56052f8969SDevin Teske local prompt= 57052f8969SDevin Teske local menu_list # Calculated below 58052f8969SDevin Teske local defaultitem= 597323adacSDevin Teske local hline="$hline_arrows_tab_enter" 607323adacSDevin Teske 617323adacSDevin Teske # 627323adacSDevin Teske # A hack so that the dialogs below are always interactive in a script 637323adacSDevin Teske # 647323adacSDevin Teske local old_interactive= 657323adacSDevin Teske if ! f_interactive; then 667323adacSDevin Teske f_getvar $VAR_NONINTERACTIVE old_interactive 677323adacSDevin Teske unset $VAR_NONINTERACTIVE 687323adacSDevin Teske fi 697323adacSDevin Teske 70052f8969SDevin Teske local cp 717323adacSDevin Teske while :; do 72*51c41087SDevin Teske menu_list= 737323adacSDevin Teske 747323adacSDevin Teske f_getvar $VAR_NFS_SECURE cp 757323adacSDevin Teske if [ "$cp" = "YES" ]; then menu_list="$menu_list 767323adacSDevin Teske ' $msg_nfs_secure' 'YES' 777323adacSDevin Teske '$msg_nfs_server_talks_only_on_a_secure_port'" 787323adacSDevin Teske else menu_list="$menu_list 797323adacSDevin Teske ' $msg_nfs_secure' 'NO' 807323adacSDevin Teske '$msg_nfs_server_talks_only_on_a_secure_port'" 817323adacSDevin Teske fi 827323adacSDevin Teske 837323adacSDevin Teske f_getvar $VAR_SLOW_ETHER cp 847323adacSDevin Teske if [ "$cp" = "YES" ]; then menu_list="$menu_list 857323adacSDevin Teske ' $msg_nfs_slow' 'YES' 867323adacSDevin Teske '$msg_user_is_using_a_slow_pc_or_ethernet_card'" 877323adacSDevin Teske else menu_list="$menu_list 887323adacSDevin Teske ' $msg_nfs_slow' 'NO' 897323adacSDevin Teske '$msg_user_is_using_a_slow_pc_or_ethernet_card'" 907323adacSDevin Teske fi 917323adacSDevin Teske 927323adacSDevin Teske f_getvar $VAR_NFS_TCP cp 937323adacSDevin Teske if [ "$cp" = "YES" ]; then menu_list="$menu_list 947323adacSDevin Teske ' $msg_nfs_tcp' 'YES' '$msg_use_tcp_protocol_for_nfs'" 957323adacSDevin Teske else menu_list="$menu_list 967323adacSDevin Teske ' $msg_nfs_tcp' 'NO' '$msg_use_tcp_protocol_for_nfs'" 977323adacSDevin Teske fi 987323adacSDevin Teske 997323adacSDevin Teske f_getvar $VAR_NFS_V3 cp 1007323adacSDevin Teske if [ "$cp" = "YES" ]; then menu_list="$menu_list 1017323adacSDevin Teske ' $msg_nfs_version_3' 'YES' '$msg_use_nfs_version_3'" 1027323adacSDevin Teske else menu_list="$menu_list 1037323adacSDevin Teske ' $msg_nfs_version_3' 'NO' '$msg_use_nfs_version_3'" 1047323adacSDevin Teske fi 1057323adacSDevin Teske 1067323adacSDevin Teske f_getvar $VAR_DEBUG cp 1077323adacSDevin Teske if [ "$cp" ]; then menu_list="$menu_list 1087323adacSDevin Teske ' $msg_debugging' 'YES' 1097323adacSDevin Teske '$msg_emit_extra_debugging_output'" 1107323adacSDevin Teske else menu_list="$menu_list 1117323adacSDevin Teske ' $msg_debugging' 'NO' 1127323adacSDevin Teske '$msg_emit_extra_debugging_output'" 1137323adacSDevin Teske fi 1147323adacSDevin Teske 11587c16275SDevin Teske f_getvar $VAR_NO_CONFIRM cp 11687c16275SDevin Teske if [ "$cp" ]; then menu_list="$menu_list 11787c16275SDevin Teske ' $msg_yes_to_all' 'YES' 11887c16275SDevin Teske '$msg_assume_yes_to_all_non_critical_dialogs'" 11987c16275SDevin Teske else menu_list="$menu_list 12087c16275SDevin Teske ' $msg_yes_to_all' 'NO' 12187c16275SDevin Teske '$msg_assume_yes_to_all_non_critical_dialogs'" 12287c16275SDevin Teske fi 12387c16275SDevin Teske 1247323adacSDevin Teske f_getvar $VAR_TRY_DHCP cp 1257323adacSDevin Teske if [ "$cp" = "YES" ]; then menu_list="$menu_list 1267323adacSDevin Teske ' $msg_dhcp' 'YES' 1277323adacSDevin Teske '$msg_attempt_automatic_dhcp_configuration'" 1287323adacSDevin Teske else menu_list="$menu_list 1297323adacSDevin Teske ' $msg_dhcp' 'NO' 1307323adacSDevin Teske '$msg_attempt_automatic_dhcp_configuration'" 1317323adacSDevin Teske fi 1327323adacSDevin Teske 1337323adacSDevin Teske f_getvar $VAR_TRY_RTSOL cp 1347323adacSDevin Teske if [ "$cp" = "YES" ]; then menu_list="$menu_list 1357323adacSDevin Teske ' $msg_ipv6' 'YES' 1367323adacSDevin Teske '$msg_attempt_ipv6_configuration_of_interfaces'" 1377323adacSDevin Teske else menu_list="$menu_list 1387323adacSDevin Teske ' $msg_ipv6' 'NO' 1397323adacSDevin Teske '$msg_attempt_ipv6_configuration_of_interfaces'" 1407323adacSDevin Teske fi 1417323adacSDevin Teske 1427323adacSDevin Teske f_getvar $VAR_FTP_USER cp 1437323adacSDevin Teske menu_list="$menu_list 1447323adacSDevin Teske ' $msg_ftp_username' '$cp' 1457323adacSDevin Teske '$msg_username_and_password_to_use'" 1467323adacSDevin Teske 1477323adacSDevin Teske f_getvar $VAR_EDITOR cp 1487323adacSDevin Teske menu_list="$menu_list 1497323adacSDevin Teske ' $msg_editor' '$cp' '$msg_which_text_editor_to_use'" 1507323adacSDevin Teske 1517323adacSDevin Teske f_getvar $VAR_RELNAME cp 1527323adacSDevin Teske menu_list="$menu_list 1537323adacSDevin Teske ' $msg_release_name' '$cp' 1547323adacSDevin Teske '$msg_which_release_to_attempt_to_load'" 1557323adacSDevin Teske 1567323adacSDevin Teske if f_struct device_media; then 1577323adacSDevin Teske device_media get type cp 1587323adacSDevin Teske case "$cp" in 1597323adacSDevin Teske $DEVICE_TYPE_UFS|$DEVICE_TYPE_DISK) 1607323adacSDevin Teske cp="$msg_file_system";; 1617323adacSDevin Teske $DEVICE_TYPE_DIRECTORY) 1627323adacSDevin Teske cp="$msg_directory";; 1637323adacSDevin Teske $DEVICE_TYPE_FLOPPY) 1647323adacSDevin Teske cp="$msg_floppy";; 1657323adacSDevin Teske $DEVICE_TYPE_FTP) 1667323adacSDevin Teske cp="$msg_ftp";; 1677323adacSDevin Teske $DEVICE_TYPE_HTTP_PROXY) 1687323adacSDevin Teske cp="$msg_http_proxy";; 1697323adacSDevin Teske $DEVICE_TYPE_CDROM) 1707323adacSDevin Teske cp="$msg_cdrom";; 1717323adacSDevin Teske $DEVICE_TYPE_USB) 1727323adacSDevin Teske cp="$msg_usb";; 1737323adacSDevin Teske $DEVICE_TYPE_DOS) 1747323adacSDevin Teske cp="$msg_dos";; 1757323adacSDevin Teske $DEVICE_TYPE_NFS) 1767323adacSDevin Teske cp="$msg_nfs";; 1777323adacSDevin Teske *) 1787323adacSDevin Teske cp="<$msg_unknown>" 1797323adacSDevin Teske esac 1807323adacSDevin Teske else 1817323adacSDevin Teske cp="<$msg_not_yet_set>" 1827323adacSDevin Teske fi 1837323adacSDevin Teske menu_list="$menu_list 1847323adacSDevin Teske ' $msg_media_type' '$cp' 1857323adacSDevin Teske '$msg_the_current_installation_media_type'" 1867323adacSDevin Teske 1877323adacSDevin Teske f_getvar $VAR_MEDIA_TIMEOUT cp 1887323adacSDevin Teske menu_list="$menu_list 1897323adacSDevin Teske ' $msg_media_timeout' '$cp' 1907323adacSDevin Teske '$msg_timeout_value_in_seconds_for_slow_media'" 1917323adacSDevin Teske 19287c16275SDevin Teske f_getvar $VAR_PKG_TMPDIR cp 19387c16275SDevin Teske menu_list="$menu_list 19487c16275SDevin Teske ' $msg_package_temp' '$cp' 19587c16275SDevin Teske '$msg_directory_where_package_temporary_files_go'" 19687c16275SDevin Teske 1977323adacSDevin Teske menu_list="$menu_list 1987323adacSDevin Teske ' $msg_rescan_devices' '<*>' 1997323adacSDevin Teske '$msg_rerun_bsdconfig_initial_device_probe' 2007323adacSDevin Teske ' $msg_use_defaults' '[${msg_reset}]' 2017323adacSDevin Teske '$msg_reset_all_values_to_startup_defaults' 2027323adacSDevin Teske " # END-QUOTE 2037323adacSDevin Teske 20474036c4dSDevin Teske local height width rows 20574036c4dSDevin Teske eval f_dialog_menu_with_help_size height width rows \ 2067323adacSDevin Teske \"\$title\" \ 2077323adacSDevin Teske \"\$btitle\" \ 2087323adacSDevin Teske \"\$prompt\" \ 2097323adacSDevin Teske \"\$hline\" \ 21074036c4dSDevin Teske $menu_list 2117323adacSDevin Teske 212fd962ac6SDevin Teske local mtag 213fd962ac6SDevin Teske mtag=$( eval $DIALOG \ 2147323adacSDevin Teske --title \"\$title\" \ 2157323adacSDevin Teske --backtitle \"\$btitle\" \ 2167323adacSDevin Teske --hline \"\$hline\" \ 2177323adacSDevin Teske --item-help \ 2187323adacSDevin Teske --ok-label \"\$msg_ok\" \ 2197323adacSDevin Teske --cancel-label \"\$msg_done\" \ 2207323adacSDevin Teske --help-button \ 2217323adacSDevin Teske --help-label \"\$msg_help\" \ 222d3a0f918SDevin Teske --default-item \"\$defaultitem\" \ 2237323adacSDevin Teske ${USE_XDIALOG:+--help \"\"} \ 22474036c4dSDevin Teske --menu \"\$prompt\" \ 22574036c4dSDevin Teske $height $width $rows \ 22674036c4dSDevin Teske $menu_list \ 2277323adacSDevin Teske 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 2287323adacSDevin Teske ) 2297323adacSDevin Teske local retval=$? 230fd962ac6SDevin Teske f_dialog_data_sanitize mtag 231fd962ac6SDevin Teske defaultitem="$mtag" 2327323adacSDevin Teske f_dprintf "retval=%s mtag=[%s]" $retval "$mtag" 2337323adacSDevin Teske 2347323adacSDevin Teske if [ $retval -eq 2 ]; then 2357323adacSDevin Teske # The Help button was pressed 2367323adacSDevin Teske f_show_help "$OPTIONS_HELPFILE" 2377323adacSDevin Teske continue 2387323adacSDevin Teske elif [ $retval -ne 0 ]; then 2397323adacSDevin Teske break # to success 2407323adacSDevin Teske fi 2417323adacSDevin Teske 2427323adacSDevin Teske case "$mtag" in 2437323adacSDevin Teske " $msg_nfs_secure") 2447323adacSDevin Teske f_getvar $VAR_NFS_SECURE cp 2457323adacSDevin Teske if [ "$cp" = "YES" ]; then 2467323adacSDevin Teske export $VAR_NFS_SECURE="NO" 2477323adacSDevin Teske else 2487323adacSDevin Teske export $VAR_NFS_SECURE="YES" 2497323adacSDevin Teske fi ;; 2507323adacSDevin Teske " $msg_nfs_slow") 2517323adacSDevin Teske f_getvar $VAR_SLOW_ETHER cp 2527323adacSDevin Teske if [ "$cp" = "YES" ]; then 2537323adacSDevin Teske export $VAR_SLOW_ETHER="NO" 2547323adacSDevin Teske else 2557323adacSDevin Teske export $VAR_SLOW_ETHER="YES" 2567323adacSDevin Teske fi ;; 2577323adacSDevin Teske " $msg_nfs_tcp") 2587323adacSDevin Teske f_getvar $VAR_NFS_TCP cp 2597323adacSDevin Teske if [ "$cp" = "YES" ]; then 2607323adacSDevin Teske export $VAR_NFS_TCP="NO" 2617323adacSDevin Teske else 2627323adacSDevin Teske export $VAR_NFS_TCP="YES" 2637323adacSDevin Teske fi ;; 2647323adacSDevin Teske " $msg_nfs_version_3") 2657323adacSDevin Teske f_getvar $VAR_NFS_V3 cp 2667323adacSDevin Teske if [ "$cp" = "YES" ]; then 2677323adacSDevin Teske export $VAR_NFS_V3="NO" 2687323adacSDevin Teske else 2697323adacSDevin Teske export $VAR_NFS_V3="YES" 2707323adacSDevin Teske fi ;; 2717323adacSDevin Teske " $msg_debugging") 2727323adacSDevin Teske if f_getvar $VAR_DEBUG cp && [ "$cp" ]; then 2737323adacSDevin Teske unset $VAR_DEBUG 2747323adacSDevin Teske else 2757323adacSDevin Teske export $VAR_DEBUG=1 2767323adacSDevin Teske fi ;; 27787c16275SDevin Teske " $msg_yes_to_all") 27887c16275SDevin Teske if f_getvar $VAR_NO_CONFIRM cp && [ "$cp" ]; then 27987c16275SDevin Teske unset $VAR_NO_CONFIRM 28087c16275SDevin Teske else 28187c16275SDevin Teske export $VAR_NO_CONFIRM=1 28287c16275SDevin Teske fi ;; 2837323adacSDevin Teske " $msg_dhcp") 2847323adacSDevin Teske f_getvar $VAR_TRY_DHCP cp 2857323adacSDevin Teske if [ "$cp" = "YES" ]; then 2867323adacSDevin Teske export $VAR_TRY_DHCP="NO" 2877323adacSDevin Teske else 2887323adacSDevin Teske export $VAR_TRY_DHCP="YES" 2897323adacSDevin Teske fi ;; 2907323adacSDevin Teske " $msg_ipv6") 2917323adacSDevin Teske f_getvar $VAR_TRY_RTSOL cp 2927323adacSDevin Teske if [ "$cp" = "YES" ]; then 2937323adacSDevin Teske export $VAR_TRY_RTSOL="NO" 2947323adacSDevin Teske else 2957323adacSDevin Teske export $VAR_TRY_RTSOL="YES" 2967323adacSDevin Teske fi ;; 2977323adacSDevin Teske " $msg_ftp_username") 2987323adacSDevin Teske f_media_set_ftp_userpass ;; 2997323adacSDevin Teske " $msg_editor") 3007323adacSDevin Teske f_variable_get_value $VAR_EDITOR \ 3017323adacSDevin Teske "$msg_please_specify_the_name_of_the_text_editor" 3027323adacSDevin Teske ;; 3037323adacSDevin Teske " $msg_release_name") 3047323adacSDevin Teske f_variable_get_value $VAR_RELNAME \ 3057323adacSDevin Teske "$msg_please_specify_the_release_you_wish_to_load" 3067323adacSDevin Teske ;; 3077323adacSDevin Teske " $msg_media_type") 3087323adacSDevin Teske f_media_get_type ;; 3097323adacSDevin Teske " $msg_media_timeout") 3107323adacSDevin Teske f_variable_get_value $VAR_MEDIA_TIMEOUT \ 3117323adacSDevin Teske "$msg_please_specify_the_number_of_seconds_to_wait" 3127323adacSDevin Teske ;; 31387c16275SDevin Teske " $msg_package_temp") 31487c16275SDevin Teske f_variable_get_value $VAR_PKG_TMPDIR \ 31587c16275SDevin Teske "$msg_please_specify_a_temporary_directory" 31687c16275SDevin Teske ;; 3177323adacSDevin Teske " $msg_rescan_devices") 3187323adacSDevin Teske f_device_rescan ;; 3197323adacSDevin Teske " $msg_use_defaults") 3207323adacSDevin Teske f_variable_set_defaults ;; 3217323adacSDevin Teske esac 3227323adacSDevin Teske done 3237323adacSDevin Teske 3247323adacSDevin Teske # Restore old VAR_NONINTERACTIVE if needed. 3257323adacSDevin Teske [ "$old_interactive" ] && 3267323adacSDevin Teske setvar $VAR_NONINTERACTIVE "$old_interactive" 3277323adacSDevin Teske 3287323adacSDevin Teske return $SUCCESS 3297323adacSDevin Teske} 3307323adacSDevin Teske 3317323adacSDevin Teske############################################################ MAIN 3327323adacSDevin Teske 3337323adacSDevin Teskef_dprintf "%s: Successfully loaded." media/options.subr 3347323adacSDevin Teske 3357323adacSDevin Teskefi # ! $_MEDIA_OPTIONS_SUBR 336