1if [ ! "$_MEDIA_OPTIONS_SUBR" ]; then _MEDIA_OPTIONS_SUBR=1 2# 3# Copyright (c) 2012-2013 Devin Teske 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 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. 14# 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 25# SUCH DAMAGE. 26# 27# 28############################################################ INCLUDES 29 30BSDCFG_SHARE="/usr/share/bsdconfig" 31. $BSDCFG_SHARE/common.subr || exit 1 32f_dprintf "%s: loading includes..." media/options.subr 33f_include $BSDCFG_SHARE/dialog.subr 34f_include $BSDCFG_SHARE/media/any.subr 35f_include $BSDCFG_SHARE/media/ftp.subr 36f_include $BSDCFG_SHARE/struct.subr 37f_include $BSDCFG_SHARE/variable.subr 38 39BSDCFG_LIBE="/usr/libexec/bsdconfig" 40f_include_lang $BSDCFG_LIBE/include/messages.subr 41 42OPTIONS_HELPFILE=$BSDCFG_LIBE/include/options.hlp 43 44############################################################ FUNCTIONS 45 46# f_media_options_menu 47# 48# Prompt the user to confirm/edit various media settings. Returns success. 49# 50f_media_options_menu() 51{ 52 f_dialog_title "$msg_options_editor" 53 local title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE" 54 f_dialog_title_restore 55 local prompt= 56 local menu_list # Calculated below 57 local defaultitem= 58 local hline="$hline_arrows_tab_enter" 59 60 # 61 # A hack so that the dialogs below are always interactive in a script 62 # 63 local old_interactive= 64 if ! f_interactive; then 65 f_getvar $VAR_NONINTERACTIVE old_interactive 66 unset $VAR_NONINTERACTIVE 67 fi 68 69 local cp 70 while :; do 71 menu_list= 72 73 f_getvar $VAR_NFS_SECURE cp 74 if [ "$cp" = "YES" ]; then menu_list="$menu_list 75 ' $msg_nfs_secure' 'YES' 76 '$msg_nfs_server_talks_only_on_a_secure_port'" 77 else menu_list="$menu_list 78 ' $msg_nfs_secure' 'NO' 79 '$msg_nfs_server_talks_only_on_a_secure_port'" 80 fi 81 82 f_getvar $VAR_SLOW_ETHER cp 83 if [ "$cp" = "YES" ]; then menu_list="$menu_list 84 ' $msg_nfs_slow' 'YES' 85 '$msg_user_is_using_a_slow_pc_or_ethernet_card'" 86 else menu_list="$menu_list 87 ' $msg_nfs_slow' 'NO' 88 '$msg_user_is_using_a_slow_pc_or_ethernet_card'" 89 fi 90 91 f_getvar $VAR_NFS_TCP cp 92 if [ "$cp" = "YES" ]; then menu_list="$menu_list 93 ' $msg_nfs_tcp' 'YES' '$msg_use_tcp_protocol_for_nfs'" 94 else menu_list="$menu_list 95 ' $msg_nfs_tcp' 'NO' '$msg_use_tcp_protocol_for_nfs'" 96 fi 97 98 f_getvar $VAR_NFS_V3 cp 99 if [ "$cp" = "YES" ]; then menu_list="$menu_list 100 ' $msg_nfs_version_3' 'YES' '$msg_use_nfs_version_3'" 101 else menu_list="$menu_list 102 ' $msg_nfs_version_3' 'NO' '$msg_use_nfs_version_3'" 103 fi 104 105 f_getvar $VAR_DEBUG cp 106 if [ "$cp" ]; then menu_list="$menu_list 107 ' $msg_debugging' 'YES' 108 '$msg_emit_extra_debugging_output'" 109 else menu_list="$menu_list 110 ' $msg_debugging' 'NO' 111 '$msg_emit_extra_debugging_output'" 112 fi 113 114 f_getvar $VAR_NO_CONFIRM cp 115 if [ "$cp" ]; then menu_list="$menu_list 116 ' $msg_yes_to_all' 'YES' 117 '$msg_assume_yes_to_all_non_critical_dialogs'" 118 else menu_list="$menu_list 119 ' $msg_yes_to_all' 'NO' 120 '$msg_assume_yes_to_all_non_critical_dialogs'" 121 fi 122 123 f_getvar $VAR_TRY_DHCP cp 124 if [ "$cp" = "YES" ]; then menu_list="$menu_list 125 ' $msg_dhcp' 'YES' 126 '$msg_attempt_automatic_dhcp_configuration'" 127 else menu_list="$menu_list 128 ' $msg_dhcp' 'NO' 129 '$msg_attempt_automatic_dhcp_configuration'" 130 fi 131 132 f_getvar $VAR_TRY_RTSOL cp 133 if [ "$cp" = "YES" ]; then menu_list="$menu_list 134 ' $msg_ipv6' 'YES' 135 '$msg_attempt_ipv6_configuration_of_interfaces'" 136 else menu_list="$menu_list 137 ' $msg_ipv6' 'NO' 138 '$msg_attempt_ipv6_configuration_of_interfaces'" 139 fi 140 141 f_getvar $VAR_FTP_USER cp 142 menu_list="$menu_list 143 ' $msg_ftp_username' '$cp' 144 '$msg_username_and_password_to_use'" 145 146 f_getvar $VAR_EDITOR cp 147 menu_list="$menu_list 148 ' $msg_editor' '$cp' '$msg_which_text_editor_to_use'" 149 150 f_getvar $VAR_RELNAME cp 151 menu_list="$menu_list 152 ' $msg_release_name' '$cp' 153 '$msg_which_release_to_attempt_to_load'" 154 155 if f_struct device_media; then 156 device_media get type cp 157 case "$cp" in 158 $DEVICE_TYPE_UFS|$DEVICE_TYPE_DISK) 159 cp="$msg_file_system" ;; 160 $DEVICE_TYPE_DIRECTORY) cp="$msg_directory" ;; 161 $DEVICE_TYPE_FLOPPY) cp="$msg_floppy" ;; 162 $DEVICE_TYPE_FTP) cp="$msg_ftp" ;; 163 $DEVICE_TYPE_HTTP_PROXY) cp="$msg_http_proxy" ;; 164 $DEVICE_TYPE_HTTP) cp="$msg_http_direct" ;; 165 $DEVICE_TYPE_CDROM) cp="$msg_cdrom" ;; 166 $DEVICE_TYPE_USB) cp="$msg_usb" ;; 167 $DEVICE_TYPE_DOS) cp="$msg_dos" ;; 168 $DEVICE_TYPE_NFS) cp="$msg_nfs" ;; 169 *) 170 cp="<$msg_unknown>" 171 esac 172 else 173 cp="<$msg_not_yet_set>" 174 fi 175 menu_list="$menu_list 176 ' $msg_media_type' '$cp' 177 '$msg_the_current_installation_media_type'" 178 179 f_getvar $VAR_MEDIA_TIMEOUT cp 180 menu_list="$menu_list 181 ' $msg_media_timeout' '$cp' 182 '$msg_timeout_value_in_seconds_for_slow_media'" 183 184 f_getvar $VAR_PKG_TMPDIR cp 185 menu_list="$menu_list 186 ' $msg_package_temp' '$cp' 187 '$msg_directory_where_package_temporary_files_go'" 188 189 menu_list="$menu_list 190 ' $msg_rescan_devices' '<*>' 191 '$msg_rerun_bsdconfig_initial_device_probe' 192 ' $msg_use_defaults' '[${msg_reset}]' 193 '$msg_reset_all_values_to_startup_defaults' 194 " # END-QUOTE 195 196 local height width rows 197 eval f_dialog_menu_with_help_size height width rows \ 198 \"\$title\" \ 199 \"\$btitle\" \ 200 \"\$prompt\" \ 201 \"\$hline\" \ 202 $menu_list 203 204 local mtag 205 mtag=$( eval $DIALOG \ 206 --title \"\$title\" \ 207 --backtitle \"\$btitle\" \ 208 --hline \"\$hline\" \ 209 --item-help \ 210 --ok-label \"\$msg_ok\" \ 211 --cancel-label \"\$msg_done\" \ 212 --help-button \ 213 --help-label \"\$msg_help\" \ 214 --default-item \"\$defaultitem\" \ 215 ${USE_XDIALOG:+--help \"\"} \ 216 --menu \"\$prompt\" \ 217 $height $width $rows \ 218 $menu_list \ 219 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 220 ) 221 local retval=$? 222 f_dialog_data_sanitize mtag 223 defaultitem="$mtag" 224 f_dprintf "retval=%s mtag=[%s]" $retval "$mtag" 225 226 if [ $retval -eq $DIALOG_HELP ]; then 227 f_show_help "$OPTIONS_HELPFILE" 228 continue 229 elif [ $retval -ne $DIALOG_OK ]; then 230 break # to success 231 fi 232 233 case "$mtag" in 234 " $msg_nfs_secure") 235 f_getvar $VAR_NFS_SECURE cp 236 if [ "$cp" = "YES" ]; then 237 export $VAR_NFS_SECURE="NO" 238 else 239 export $VAR_NFS_SECURE="YES" 240 fi ;; 241 " $msg_nfs_slow") 242 f_getvar $VAR_SLOW_ETHER cp 243 if [ "$cp" = "YES" ]; then 244 export $VAR_SLOW_ETHER="NO" 245 else 246 export $VAR_SLOW_ETHER="YES" 247 fi ;; 248 " $msg_nfs_tcp") 249 f_getvar $VAR_NFS_TCP cp 250 if [ "$cp" = "YES" ]; then 251 export $VAR_NFS_TCP="NO" 252 else 253 export $VAR_NFS_TCP="YES" 254 fi ;; 255 " $msg_nfs_version_3") 256 f_getvar $VAR_NFS_V3 cp 257 if [ "$cp" = "YES" ]; then 258 export $VAR_NFS_V3="NO" 259 else 260 export $VAR_NFS_V3="YES" 261 fi ;; 262 " $msg_debugging") 263 if f_getvar $VAR_DEBUG cp && [ "$cp" ]; then 264 unset $VAR_DEBUG 265 else 266 export $VAR_DEBUG=1 267 fi ;; 268 " $msg_yes_to_all") 269 if f_getvar $VAR_NO_CONFIRM cp && [ "$cp" ]; then 270 unset $VAR_NO_CONFIRM 271 else 272 export $VAR_NO_CONFIRM=1 273 fi ;; 274 " $msg_dhcp") 275 f_getvar $VAR_TRY_DHCP cp 276 if [ "$cp" = "YES" ]; then 277 export $VAR_TRY_DHCP="NO" 278 else 279 export $VAR_TRY_DHCP="YES" 280 fi ;; 281 " $msg_ipv6") 282 f_getvar $VAR_TRY_RTSOL cp 283 if [ "$cp" = "YES" ]; then 284 export $VAR_TRY_RTSOL="NO" 285 else 286 export $VAR_TRY_RTSOL="YES" 287 fi ;; 288 " $msg_ftp_username") 289 f_media_set_ftp_userpass ;; 290 " $msg_editor") 291 f_variable_get_value $VAR_EDITOR \ 292 "$msg_please_specify_the_name_of_the_text_editor" 293 ;; 294 " $msg_release_name") 295 f_variable_get_value $VAR_RELNAME \ 296 "$msg_please_specify_the_release_you_wish_to_load" 297 ;; 298 " $msg_media_type") 299 f_media_get_type ;; 300 " $msg_media_timeout") 301 f_variable_get_value $VAR_MEDIA_TIMEOUT \ 302 "$msg_please_specify_the_number_of_seconds_to_wait" 303 ;; 304 " $msg_package_temp") 305 f_variable_get_value $VAR_PKG_TMPDIR \ 306 "$msg_please_specify_a_temporary_directory" 307 ;; 308 " $msg_rescan_devices") 309 f_device_rescan ;; 310 " $msg_use_defaults") 311 f_variable_set_defaults ;; 312 esac 313 done 314 315 # Restore old VAR_NONINTERACTIVE if needed. 316 [ "$old_interactive" ] && 317 setvar $VAR_NONINTERACTIVE "$old_interactive" 318 319 return $SUCCESS 320} 321 322############################################################ MAIN 323 324f_dprintf "%s: Successfully loaded." media/options.subr 325 326fi # ! $_MEDIA_OPTIONS_SUBR 327