diff --git a/usr.sbin/bsdconfig/include/media.hlp b/usr.sbin/bsdconfig/include/media.hlp index 6fd609473810..1f07789ec0a4 100644 --- a/usr.sbin/bsdconfig/include/media.hlp +++ b/usr.sbin/bsdconfig/include/media.hlp @@ -1,54 +1,47 @@ You can install from the following types of media: CDROM requires one of the following supported CDROM drives: ATAPI - Any standard ATAPI CDROM drive hooked to a supported controller (see Hardware Guide). SCSI - Any standard SCSI CDROM drive hooked to a supported controller (see Hardware Guide). DOS A DOS primary partition with the required FreeBSD distribution files copied onto it (e.g. C:\FREEBSD\) UFS Assuming a disk or partition with an existing FreeBSD file system and distribution set on it, get the distribution files from there. - Floppy Get distribution files from one or more DOS or UFS - formatted floppies. Such floppies are assumed to - contain the appropriate distribution pieces - see - ABOUT.TXT for more information about making floppy - distribution media. - - FTP Get the distribution files from an anonymous ftp server (you will be presented with a list). Please note that you may invoke FTP in "Active"/"Passive" auto-mode, or via an HTTP proxy. By default, ftp(1) will automatically use the best mode for the server. Using an HTTP proxy is sometimes necessary for firewalls which block all FTP connections. If you chose to enter your own URL in the FTP menu, please note that all paths are *relative* to the home directory of the user being logged in as. By default, this is the user "ftp" (anonymous ftp) but you may change this in the Options screen. HTTP Direct Get the distribution files directly from an HTTP server. If you chose to enter your own URL in the HTTP Direct menu, please note that all paths are *relative* to the root directory of the web server. NFS Get the distribution files from an NFS server somewhere (make sure that permissions on the server allow this!). If this install method hangs on you or refuses to work properly, you may need to set some special options for your NFS server. See the Options screen for more details. diff --git a/usr.sbin/bsdconfig/include/messages.subr b/usr.sbin/bsdconfig/include/messages.subr index 63c8f4925c0f..b9ddd8e2f466 100644 --- a/usr.sbin/bsdconfig/include/messages.subr +++ b/usr.sbin/bsdconfig/include/messages.subr @@ -1,459 +1,450 @@ # Copyright (c) 2012 Ron McDowell # Copyright (c) 2012-2016 Devin Teske # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # field_password="Password:" field_username="Username:" hline_alnum_arrows_punc_tab_enter="Use alnum, arrows, punctuation, TAB or ENTER" hline_alnum_punc_tab_enter="Use alpha-numeric, punctuation, TAB or ENTER" hline_arrows_tab_enter="Press arrows, TAB or ENTER" hline_arrows_tab_punc_enter="Use arrows, TAB, punctuation, ENTER" hline_choose_help_for_more_information_on_media_types="Choose Help for more information on the various media types" msg_accept_continue="Accept/Continue" msg_accessibility_desc="Ports to help disabled users." msg_adding_package_as_a_dependency_from_media="Adding %s (as a dependency) from %s" msg_adding_package_from_media="Adding %s from %s" msg_afterstep_desc="Ports to support the AfterStep window manager." msg_all="All" msg_all_desc="All available packages in all categories." msg_always_try_sudo_when_run_as="Always try sudo(8) when run as %s" msg_an_unknown_error_occurred="An unknown error occurred" msg_arabic_desc="Ported software for Arab countries." msg_archivers_desc="Utilities for archiving and unarchiving data." msg_armenia="Armenia" msg_assume_network_is_already_configured="Running multi-user, assume that the network is already configured?" msg_assume_yes_to_all_non_critical_dialogs="Assume \"Yes\" answers to all non-critical dialogs" msg_astro_desc="Applications related to astronomy." msg_attempt_automatic_dhcp_configuration="Attempt automatic DHCP configuration of interfaces" msg_attempt_ipv6_configuration_of_interfaces="Attempt IPv6 configuration of interfaces" msg_attempting_to_update_repository_catalogue="Attempting to update repository catalogue from selected media." msg_audio_desc="Audio utilities - most require a supported sound card." msg_australia="Australia" msg_austria="Austria" msg_back="Back" msg_becoming_root_via_sudo="Becoming root via sudo(8)..." msg_benchmarks_desc="Utilities for measuring system performance." msg_biology_desc="Software related to biology." msg_bootstrapping_pkg="Bootstrapping pkg(8)..." msg_brazil="Brazil" msg_building_package_menus="Building package menu(s)..." msg_building_package_main_menu="Building package main menu..." msg_bulgaria="Bulgaria" msg_cad_desc="Computer Aided Design utilities." msg_canada="Canada" msg_cancel="Cancel" msg_cancel_exit="Cancel/Exit" msg_cannot_create_permission_denied="%s: cannot create %s: Permission denied" msg_cannot_edit_wireless_ssid="Cannot edit wireless configuration; no matches for\nSSID \`%s' in wpa_supplicant.conf(5)" msg_cannot_resolve_hostname="Cannot resolve \`%s'! Are you sure that your\nname server, gateway and network interface are correctly configured?" msg_cant_find_distribution="Warning: Can't find the \`%s' distribution on this\nFTP server. You may need to visit a different server for\nthe release you are trying to fetch or go to the Options\nmenu and set the release name to explicitly match what's\navailable on %s (or set to \"any\").\n\nWould you like to select another FTP server?" msg_cant_seem_to_write_out_resolv_conf="Can't seem to write out %s. Net cannot be used." msg_cant_start_wpa_supplicant="Can't start wpa_supplicant(8). Please create a wlan(4)\ninterface from the \`wlans' option after selecting your\nfavorite wireless adapter (i.e., %s)." msg_cd_dvd="CD/DVD" msg_cdrom="CDROM" msg_checking_access_to="Checking access to\n %s" msg_chinese_desc="Ported software for the Chinese market." msg_choose_a_cd_dvd_type="Choose a CD/DVD type" msg_choose_a_dos_partition="Choose a DOS partition" -msg_choose_a_floppy_drive="Choose a Floppy drive" msg_choose_a_ufs_partition="Choose a UFS partition" msg_choose_a_usb_drive="Choose a USB drive" msg_choose_installation_media="Choose Installation Media" msg_choose_installation_media_description="FreeBSD can be installed from a variety of different installation\nmedia, ranging from floppies to an Internet FTP server. If you're\ninstalling FreeBSD from a supported CD/DVD drive then this is generally\nthe best media to use if you have no overriding reason for using other\nmedia." msg_client_error="Client error, you could try an other server" msg_command_failed_rest_of_script_aborted="Command \`%s' failed - rest of script aborted." msg_comms_desc="Communications utilities." msg_configuration_for_interface="Configuration for Interface" msg_configured="Configured" msg_configured_lc="configured" msg_configured_ssids="Configured SSIDs" msg_converters_desc="Format conversion utilities." msg_could_not_unmount_the_cdrom_dvd="Could not unmount the CDROM/DVD from %s: %s" msg_could_not_unmount_the_dos_partition="Could not unmount the DOS partition from %s: %s" msg_could_not_unmount_the_nfs_partition="Could not unmount the NFS partition from %s: %s" msg_could_not_unmount_the_ufs_partition="Could not unmount the UFS partition from %s: %s" msg_couldnt_connect_to_ftp_server="Couldn't connect to FTP server" msg_couldnt_connect_to_proxy="Couldn't connect to proxy" msg_couldnt_connect_to_server="Couldn't connect to server" msg_couldnt_open_ftp_connection="Couldn't open FTP connection to %s:\n %s." msg_create_new="Create New" msg_created_path="Created %s" msg_czech_republic="Czech Republic" msg_databases_desc="Database software." msg_debugging="Debugging" msg_denmark="Denmark" msg_deskutils_desc="Various Desktop utilities." msg_destroy="Destroy" msg_details="Details" msg_devel_desc="Software development utilities and libraries." msg_device_is_not_configured="The %s device is not configured. You will need to do so\nin the Networking configuration menu before proceeding." msg_dhcp="DHCP" msg_dialog_mixedform_navigation_help="Use / arrows to navigate between fields, TAB to focus buttons, and Enter for OK/Cancel." msg_directory="Directory" msg_directory_not_found="%s: Directory not found." msg_directory_where_package_temporary_files_go="The directory where package temporary files should go" msg_discovered_ssids="Discovered SSIDs" msg_dns_desc="Domain Name Service tools." msg_docs_desc="Meta-ports for FreeBSD documentation." msg_done="Done" msg_dos="DOS" msg_editor="Editor" msg_editors_desc="Editors." msg_elisp_desc="Things related to Emacs Lisp." msg_emit_extra_debugging_output="Emit extra debugging output" msg_emulators_desc="Utilities for emulating other operating systems." msg_enlightenment_desc="Software for the Enlightenment Desktop Environment." msg_enter_a_fully_qualified_pathname_for_the_directory="Enter a fully qualified pathname for the directory\ncontaining the FreeBSD distribution files:" msg_enter_the_device_name_of_a_ufs_formatted_partition="Enter the device-name of a UFS formatted partition" msg_error="Error" msg_error_mounting_device="Error mounting %s on %s: %s" -msg_error_mounting_floppy_device="Error mounting floppy %s (%s) on %s: %s" msg_error_mounting_usb_drive="Error mounting USB drive %s on %s: %s" msg_error_when_requesting_url="Error when requesting %s, you could try an other server" msg_estonia="Estonia" msg_exit="Exit" msg_exit_bsdconfig="Exit bsdconfig" msg_extra_options_to_ifconfig="Extra options to ifconfig (usually empty):" msg_failed_to_add_default_route="Failed to add a default route; please check your network configuration" msg_failed_to_reach_wpa_supplicant="Failed to reach wpa_supplicant: %s" msg_file_system="File System" msg_finance_desc="Monetary, financial and related applications." msg_finland="Finland" -msg_floppy="Floppy" msg_forget_all="Forget All" msg_forget_all_confirm="WARNING! Are you really sure you want to forget all known networks\nby re-initializing wpa_supplicant.conf(5)? This cannot be undone." msg_forget_all_help="Reset wpa_supplicant(8) configuration, forgetting all known networks" msg_found="found" msg_france="France" msg_french_desc="Ported software for French countries." msg_ftp="FTP" msg_ftp_desc="FTP client and server utilities." msg_ftp_passive="FTP Passive" msg_ftp_username="FTP username" msg_generating_index_from_pkg_database="Generating INDEX from pkg(8) database\n(this can take a while)..." msg_geography_desc="Geography-related software." msg_german_desc="Ported software for Germanic countries." msg_germany="Germany" msg_gnome_desc="Components of the Gnome Desktop environment." msg_gnustep_desc="Software for GNUstep desktop environment." msg_graphics_desc="Graphics libraries and utilities." msg_greece="Greece" msg_hamradio_desc="Software for amateur radio." msg_haskell_desc="Software related to the Haskell language." msg_hebrew_desc="Ported software for Hebrew language." msg_help="Help" msg_host_name_including_domain="Host name (including domain)" msg_hostname_variable_not_set="WARNING: hostname variable not set and is a non-optional\nparameter. Please add this to your installation script\nor set the netInteractive variable (see bsdconfig man page)" msg_http_direct="HTTP Direct" msg_http_proxy="HTTP Proxy" msg_hungarian_desc="Ported software for the Hungarian market." msg_iceland="Iceland" msg_install_from_a_dos_partition="Install from a DOS partition" -msg_install_from_a_floppy_disk_set="Install from a floppy disk set" msg_install_from_a_freebsd_cd_dvd="Install from a FreeBSD CD/DVD" msg_install_from_a_ufs_partition="Install from a UFS partition" msg_install_from_a_usb_drive="Install from a USB drive" msg_install_from_an_ftp_server="Install from an FTP server" msg_install_from_an_ftp_server_thru_firewall="Install from an FTP server through a firewall" msg_install_from_an_ftp_server_thru_proxy="Install from an FTP server through an HTTP proxy" msg_install_from_an_http_server="Install from an HTTP server" msg_install_from_the_existing_filesystem="Install from the existing filesystem" msg_install_over_nfs="Install over NFS" msg_installed="Installed" msg_installed_desc="Leave package as-is, installed" msg_installed_lc="installed" msg_invalid_gateway_ipv4_address_specified="Invalid gateway IPv4 address specified" msg_invalid_hostname_value="Invalid hostname value" msg_invalid_ipv4_address="Invalid IPv4 address" msg_invalid_name_server_ip_address_specified="Invalid name server IP address specified" msg_invalid_netmask_value="Invalid netmask value" msg_invalid_nfs_path_specification="Invalid NFS path specification. Must be of the form:\nhost:/full/pathname/to/FreeBSD/distdir" msg_io_error_while_reading_in_the_package="I/O error while reading in the %s package." msg_io_or_format_error_on_index_file="I/O or format error on INDEX file.\nPlease verify media (or path to media) and try again." msg_ipv4_address="IPv4 Address" msg_ipv4_gateway="IPv4 Gateway" msg_ipv6="IPv6" msg_ipv6_desc="IPv6-related software." msg_ipv6_ready="IPv6 ready" msg_irc_desc="Internet Relay Chat utilities." msg_israel="Israel" msg_japan="Japan" msg_japanese_desc="Ported software for the Japanese market." msg_java_desc="Java language support." msg_kde_desc="Software for the K Desktop Environment." msg_kld_desc="Kernel loadable modules." msg_korea="Korea" msg_korean_desc="Ported software for the Korean market." msg_lang_desc="Computer languages." msg_latvia="Latvia" msg_length_of_specified_url_is_too_long="Length of specified URL is %u characters. Allowable maximum is %u." msg_linux_desc="Linux programs that can run under binary compatibility." msg_lisp_desc="Software related to the Lisp language." msg_lithuania="Lithuania" msg_loading_of_dependent_package_failed="Loading of dependent package %s failed" msg_loading_wireless_menu="Loading Wireless Menu..." msg_logging_in_to_user_at_host="Logging in to %s@%s.." msg_looking_for_keymap_files="Looking for keymap files..." msg_looking_up_host="Looking up host %s" msg_mail_desc="Electronic mail packages and utilities." msg_main_menu="Main Menu" msg_main_site="Main Site (GeoDNS)" msg_manually_connect="Manually Connect" msg_manually_connect_help="Connect to a wireless network that may be unlisted" msg_math_desc="Mathematical computation software." msg_mbone_desc="Applications and utilities for the MBONE." msg_media_timeout="Media Timeout" msg_media_type="Media Type" msg_menu_text="If you've already installed FreeBSD, you may use\nthis menu to customize it somewhat to suit your\nparticular configuration. Most importantly, you\ncan use the Packages utility to load extra '3rd\nparty' software not provided in the base\ndistributions." msg_misc_desc="Miscellaneous utilities." msg_missing_ftp_host_or_directory="Missing FTP host or directory specification. FTP media not initialized." msg_multimedia_desc="Multimedia software." msg_must_be_root_to_execute="%s: must be root to execute" msg_must_have_pkg_to_execute="%s: must have pkg(8) to execute" msg_must_specify_a_host_name_of_some_sort="Must specify a host name of some sort!" msg_name_server="Name server" msg_net_desc="Networking utilities." msg_net_device_init_failed="Net device init failed." msg_net_im_desc="Instant messaging software." msg_net_mgmt_desc="Network management tools." msg_net_p2p_desc="Peer to peer network applications." msg_netherlands="Netherlands" msg_netmask="Netmask" msg_network_configuration="Network Configuration" msg_network_interface_information_required="Network interface information required" msg_new_zealand="New Zealand" msg_news_desc="USENET News support software." msg_next_page="Next page" msg_nfailed_attempts="%u incorrect password attempts" msg_nfs="NFS" msg_nfs_secure="NFS Secure" msg_nfs_server_talks_only_on_a_secure_port="NFS server talks only on a secure port" msg_nfs_slow="NFS Slow" msg_nfs_tcp="NFS TCP" msg_nfs_version_3="NFS version 3" msg_no="No" msg_no_cd_dvd_devices_found="No CD/DVD devices found! Please check that your system's\nconfiguration is correct and that the CD/DVD drive is of a\nsupported type. For more information, consult the hardware\nguide in the Doc menu." msg_no_description_provided="No description provided" msg_no_dos_primary_partitions_found="No DOS primary partitions found! This installation method is unavailable" -msg_no_floppy_devices_found="No floppy devices found! Please check that your system's configuration\nis correct. For more information, consult the hardware guide in the Doc\nmenu." msg_no_gateway_has_been_set="No gateway has been set. You will be unable to access hosts\nnot on your local network" msg_no_network_devices="No network devices available!" msg_no_package_name_passed_in_package_variable="No package name passed in package variable" msg_no_packages_were_selected_for_extraction="No packages were selected for extraction." msg_no_pkg_database_found="No pkg(8) database found!" msg_no_such_file_or_directory="%s: %s: No such file or directory" msg_no_usb_devices_found="No USB devices found (try Options/Re-scan Devices)" msg_no_username="No username provided!" msg_norway="Norway" msg_not_a_directory="%s: %s: Not a directory" msg_not_found="not found" msg_not_yet_set="not yet set" msg_ok="OK" msg_options="Options" msg_options_editor="Options Editor" msg_other="other" msg_package_is_needed_by_other_installed_packages="Warning: Package %s is needed by\n %d other installed package%s." msg_package_not_installed_cannot_delete="Warning: package %s not installed\n No package can be deleted." msg_package_temp="Package Temp" msg_package_was_added_successfully="Package %s was added successfully" msg_packages="packages" msg_page_of_npages="(Page %s of %s)" msg_palm_desc="Software support for the Palm(tm) series." msg_parallel_desc="Applications dealing with parallelism in computing." msg_pear_desc="Software related to the Pear PHP framework." msg_perl5_desc="Utilities/modules for the PERL5 language." msg_permission_denied="%s: %s: Permission denied" msg_pick_an_interface_to_destroy="Pick an interface to destroy" msg_pkg_delete_failed="Warning: pkg-delete(8) of %s failed.\n Run with debugging for details." msg_pkg_install_apparently_did_not_like_the_package="pkg-install(8) apparently did not like the %s package." msg_pkg_not_yet_installed_install_now="pkg(8) not yet installed. Install now?" msg_plan9_desc="Software from the Plan9 operating system." msg_please_check_the_url_and_try_again="No such directory: %s\nplease check the URL and try again.\n" msg_please_enter_password="Please enter your password for sudo(8):" msg_please_enter_the_address_of_the_http_proxy="Please enter the address of the HTTP proxy in this format:\n hostname:port (the ':port' is optional, default is 3128)" msg_please_enter_the_full_nfs_file_specification="Please enter the full NFS file specification for the remote\nhost and directory containing the FreeBSD distribution files.\nThis should be in the format: hostname:/some/freebsd/dir" msg_please_enter_the_password_for_this_user="Please enter the password for this user:" msg_please_enter_the_username_you_wish_to_login_as="Please enter the username you wish to login as:" msg_please_enter_username_password="Please enter a username and password for sudo(8):" -msg_please_insert_floppy_containing="Please insert floppy containing %s in %s" -msg_please_insert_floppy_in_drive="Please insert floppy in %s" msg_please_select_a_category_to_display="Please select a category to display." msg_please_select_a_cd_dvd_drive="FreeBSD can be installed directly from a CD/DVD containing a valid\nFreeBSD distribution. If you are seeing this menu it is because\nmore than one CD/DVD drive was found on your system. Please select\none of the following CD/DVD drives as your installation drive." -msg_please_select_a_floppy_drive="You have more than one floppy drive. Please choose which drive\nyou would like to use." msg_please_select_a_freebsd_ftp_distribution_site="Please select a FreeBSD FTP distribution site" msg_please_select_a_freebsd_http_distribution_site="Please select a FreeBSD HTTP distribution site" msg_please_select_a_usb_drive="You have more than one USB drive. Please choose which drive\nyou would like to use." msg_please_select_dos_partition="FreeBSD can be installed directly from a DOS partition assuming,\nof course, that you have copied the relevant distributions into\nyour DOS partition before starting this installation. If this is\nnot the case then you should reboot DOS at this time and copy the\ndistributions you wish to install into a \"FREEBSD\" subdirectory\non one of your DOS partitions. Otherwise, please select the DOS\npartition containing the FreeBSD distribution files." msg_please_select_ethernet_device_to_configure="Please select the ethernet or PLIP device to configure." msg_please_select_the_site_closest_to_you_or_other="Please select the best suitable site for you or \"other\" if you want to\nspecify a different choice. The \"Main Site\" directs users to the nearest\nproject managed mirror via GeoDNS (they carry the full range of possible\ndistributions and support both IPv4 and IPv6). All other sites are known\nas \"Community Mirrors\"; not every site listed here carries more than the\nbase distribution kits. Select a site!" msg_please_select_ufs_partition="FreeBSD can be installed directly from another FreeBSD partition\nthat is UFS formatted assuming, of course, that you have copied\nthe relevant distributions into said partition before starting\ninstallation." msg_please_specify_a_temporary_directory="Please specify a temporary directory with lots of free space:" msg_please_specify_the_name_of_the_text_editor="Please specify the name of the text editor you wish to use:" msg_please_specify_the_number_of_seconds_to_wait="Please specify the number of seconds to wait for slow media:" msg_please_specify_the_release_you_wish_to_load="Please specify the release you wish to load or\n\"any\" for a generic release install:" msg_please_specify_url_of_a_freebsd_distribution="Please specify the URL of a FreeBSD distribution on a\nremote ftp site. This site must accept either anonymous\nftp or you should have set an ftp username and password\nin the Options screen.\n\nA URL looks like this: ftp:///\nWhere is relative to the anonymous ftp directory or the\nhome directory of the user being logged in as." msg_please_specify_url_of_freebsd_http_distribution="Please specify the URL of a FreeBSD distribution on a\nremote http site.\nA URL looks like this: http:///" msg_poland="Poland" msg_polish_desc="Ported software for the Polish market." msg_ports_mgmt_desc="Utilities for managing ports and packages." msg_portuguese_desc="Ported software for the Portuguese market." msg_previous_page="Previous page" msg_previous_syntax_errors="%s: Not overwriting \`%s' due to previous syntax errors" msg_print_desc="Utilities for dealing with printing." msg_probing_devices_please_wait_this_can_take_a_while="Probing devices, please wait (this can take a while)..." msg_proceed="Proceed" msg_processing_selection="Processing selection..." msg_python_desc="Software related to the Python language." msg_quick_start_how_to_use_this_menu_system="Quick start - How to use this menu system" msg_reading_package_index_data="Reading package index data" msg_reinstall="Reinstall" msg_reinstall_desc="Mark this package for reinstall" msg_release_name="Release Name" msg_required_package_not_found="Warning: %s is a required package but was not found." msg_rerun_bsdconfig_initial_device_probe="Re-run bsdconfig initial device probe" msg_rescan_wireless="Rescan Wireless" msg_rescan_wireless_help="Scan for new wireless networks" msg_rescan_devices="Re-scan Devices" msg_reset="RESET!" msg_reset_all_values_to_startup_defaults="Reset all values to startup defaults" msg_return_to_previous_menu="Return to previous menu" msg_reuse_old_ftp_site_selection_values="Re-use old FTP site selection values?" msg_reuse_old_http_site_settings="Re-use old HTTP site settings?" msg_review="Review" msg_review_desc="Review/perform pending actions" msg_review_help="Install, Re-Install, or Un-install selected packages and dependencies" msg_reviewing_selected_packages="Reviewing %u selected packages:" msg_ruby_desc="Software related to the Ruby language." msg_rubygems_desc="Ports of RubyGems packages." msg_russia="Russia" msg_russian_desc="Ported software for the Russian market." msg_scanning_for_dhcp_servers="Scanning for DHCP servers..." msg_scanning_for_ra_servers="Scanning for RA servers..." msg_scanning_wireless_pausing="Scanning Wireless... (pausing for %i seconds)" msg_scheme_desc="Software related to the Scheme language." msg_science_desc="Scientific software." msg_secure_mode_requires_root="Secure-mode requires root-access!" msg_secure_mode_requires_x11="Secure-mode requires X11 (use \`-X')!" msg_security_desc="System security software." msg_select="Select" msg_select_a_site_thats_close="Select a site!" msg_select_the_configuration_you_would_like="Select the configuration you would like to edit:\nAddional network information displayed in help line." msg_select_wlan_interfaces_for="Select wlan interfaces for %s:" msg_selected="selected" msg_server_error_when_requesting_url="Server error when requesting %s, you could try an other server" msg_shells_desc="Various shells (tcsh, bash, etc)." msg_show_all="Show All" msg_show_all_help="Show wireless networks without an SSID and all BSSIDs" msg_show_configured="Show Configured" msg_show_configured_help="Show networks configured in wpa_supplicant.conf(5)" msg_show_scan_results="Show Scan Results" msg_show_scan_results_help="Show wpa_cli(8) scan results" msg_skip="Skip" msg_slovenia="Slovenia" msg_sorry_invalid_url="Sorry, %s is an invalid URL!" msg_sorry_package_was_not_found_in_the_index="Sorry, package %s was not found in the INDEX." msg_sorry_try_again="Sorry, try again." msg_south_africa="South Africa" msg_spain="Spain" msg_spanish_desc="Ported software for the Spanish market." msg_specify_some_other_ftp_site="Specify some other ftp site by URL" msg_specify_some_other_http_site="Specify some other http site by URL" msg_sweden="Sweden" msg_sysutils_desc="Various system utilities." msg_taiwan="Taiwan" msg_tcl_desc="TCL and packages that depend on it." msg_textproc_desc="Text processing/search utilities." msg_the_current_installation_media_type="The current installation media type." msg_timeout_value_in_seconds_for_slow_media="Timeout value in seconds for slow media." msg_tk_desc="Tk and packages that depend on it." msg_try_dhcp_configuration="Do you want to try DHCP configuration of the interface?" msg_try_ipv6_configuration="Do you want to try IPv6 configuration of the interface?" msg_try_sudo_only_this_once="Try sudo(8) only this once" msg_ufs="UFS" msg_uk="UK" msg_ukraine="Ukraine" msg_ukrainian_desc="Ported software for the Ukrainian market." msg_unable_to_configure_device="Unable to configure the %s interface!\nThis installation method cannot be used." msg_unable_to_fetch_package_from_selected_media="Unable to fetch package %s from selected media.\nNo package add will be done." msg_unable_to_get_file_from_selected_media="Unable to get %s file from selected media.\n\nThis may be because the packages collection is not available\non the distribution media you've chosen, most likely an FTP site\nwithout the packages collection mirrored. Please verify that\nyour media, or your path to the media, is correct and try again." msg_unable_to_get_proper_ftp_path="Unable to get proper FTP path. FTP media not initialized." msg_unable_to_initialize_media_type_for_package_extract="Unable to initialize media type for package extract." msg_unable_to_make_directory_mountpoint="Unable to make %s directory mountpoint for %s!" msg_unable_to_open="Unable to open %s" msg_unable_to_update_pkg_from_selected_media="Unable to update pkg(8) from selected media." msg_unconfigured="Unconfigured" msg_uninstall="Uninstall" msg_uninstall_desc="Mark this package for deletion" msg_uninstalling_package_waiting_for_pkg_delete="Uninstalling %s package - waiting for pkg-delete(8)" msg_unknown="unknown" msg_unknown_user="Unknown user: %s" msg_url_was_not_found="%s was not found,\nmaybe directory or release-version are wrong?" msg_usa="USA" msg_usage="Usage" msg_usb="USB" msg_use_defaults="Use Defaults" msg_use_nfs_version_3="Use NFS version 3" msg_use_tcp_protocol_for_nfs="Use TCP protocol for NFS" msg_user_disallowed="User disallowed: %s" msg_user_is_using_a_slow_pc_or_ethernet_card="User is using a slow PC or Ethernet card" msg_username_and_password_to_use="Username and password to use instead of anonymous" msg_using_interface="Using interface %s" msg_using_usb_device="Using USB device: %s" msg_v6="- IPv6" msg_vietnamese_desc="Ported software for the Vietnamese market." msg_view_set_various_media_options="View/Set various media options" msg_warning_no_wireless_devices="WARNING! No wireless devices found." msg_what_would_you_like_to_do_with="What would you like to do with %s?" msg_which_release_to_attempt_to_load="Which release to attempt to load from installation media" msg_which_text_editor_to_use="Which text editor to use during installation" msg_wireless_networks_text="Select an unmarked ([ ]) entry to join that network.\nSelect a marked ([X]) entry to edit that configuration." msg_windowmaker_desc="Ports to support the WindowMaker window manager." msg_wireless_network_configuration_for="Wireless network configuration for SSID \`%s'" msg_would_you_like_to_bring_interface_up="Would you like to bring the %s interface up right now?" msg_wpa_cli_ping_failed="wpa_cli(8) ping failed" msg_www_desc="Web utilities (browsers, HTTP servers, etc)." msg_x11_clocks_desc="X Window System based clocks." msg_x11_desc="X Window System based utilities." msg_x11_drivers_desc="X Window System drivers." msg_x11_fm_desc="X Window System based file managers." msg_x11_fonts_desc="X Window System fonts and font utilities." msg_x11_servers_desc="X Window System servers." msg_x11_themes_desc="X Window System themes." msg_x11_toolkits_desc="X Window System based development toolkits." msg_x11_wm_desc="X Window System window managers." msg_xfce_desc="Software related to the Xfce Desktop Environment." msg_yes="Yes" msg_yes_to_all="Yes to All" msg_you_are_not_root_but="You are not root but %s can use sudo(8).\nWhat would you like to do?" -msg_you_may_remove_the_floppy="You may remove the floppy from %s" msg_youve_already_done_the_network_configuration="You've already done the network configuration once,\nwould you like to skip over it now?" msg_zope_desc="Software related to the Zope platform." tcplayout_extras_help="Any interface-specific options to ifconfig you would like to add" tcplayout_extras_help_for_plip="For PLIP configuration, you must enter the peer's IP address here." tcplayout_gateway_help="IPv4 address of host forwarding packets to non-local destinations" tcplayout_hostname_help="Your fully-qualified hostname, e.g. foo.example.com" tcplayout_ipaddr_help="The IPv4 address to be used for this interface" tcplayout_nameserver_help="IPv4 or IPv6 address of your local DNS server" tcplayout_netmask_help="The netmask for this interface, e.g. 255.255.255.0 for a class C network" diff --git a/usr.sbin/bsdconfig/include/options.hlp b/usr.sbin/bsdconfig/include/options.hlp index f47df27a6b88..257c5011fb9e 100644 --- a/usr.sbin/bsdconfig/include/options.hlp +++ b/usr.sbin/bsdconfig/include/options.hlp @@ -1,115 +1,113 @@ The following options may be set from this screen. NFS Secure: NFS server talks only on a secure port This is most commonly used when talking to Sun workstations, which will not talk NFS over "non privileged" ports. NFS Slow: User is using a slow PC or Ethernet card Use this option if you have a slow PC (386) or an Ethernet card with poor performance being "fed" by NFS on a higher-performance workstation. This will throttle the workstation back to prevent the PC from becoming swamped with data. NFS TCP: Use TCP for the NFS mount This option can be used if your NFS server supports TCP connections; not all do! This may be useful if your NFS server is at a remote site in which case it may offer some additional stability. NFS version 3: Use NFS version 3 This option forces the use of NFS version 3 and is on by default. If your NFS server only supports NFS version 2, disable this option. Debugging: Turn on the extra debugging flag This turns on a lot of extra noise in between dialogs (unless debugFile has been set, sending the data to a logfile instead). Optionally, if debugFile begins with a plus sign (`+'), output will occur both on standard output and to debugFile (minus leading plus). If your installation should fail for any reason, PLEASE turn this flag on when attempting to reproduce the problem. It will provide a lot of extra debugging at the failure point and may be very helpful to the developers in tracking such problems down! Yes To All: Assume "Yes" answers to all non-critical dialogs This flag should be used with caution. It will essentially decide NOT to ask the user about any "boundary" conditions that might not constitute actual errors but may be warnings indicative of other problems. It's most useful to those who are doing unattended installs. DHCP: Enable DHCP configuration of interfaces This option specifies whether DHCP configuration of interfaces may be attempted. The default setting is to interactively ask the user. IPv6: Enable IPv6 router solicitation configuration This option specifies whether automatic configuration of IPv6 interfaces may be attempted. This uses the router solicitation method of automatic configuration. The default setting is to interactively ask the user. FTP username: Specify username and password instead of anonymous. By default, the installation attempts to log in as the anonymous user. If you wish to log in as someone else, specify the username and password with this option. Editor: Specify which screen editor to use. At various points during the installation it may be necessary to customize some text file, at which point the user will be thrown unceremoniously into a screen editor. A relatively simplistic editor which shows its command set on-screen is selected by default, but UNIX purists may wish to change this setting to `/usr/bin/vi'. Release Name: Which release to attempt to load from installation media. You should only change this option if you're really sure you know what you are doing! This will change the release name used by - bsdconfig when fetching components of any distributions, and - is a useful way of using a more recent installation boot floppy - with an older release (say, on CDROM). + bsdconfig when fetching components of any distributions. Media Type: Which media type is being used. This is mostly informational and indicates which media type (if any) was last selected in the Media menu. It's also a convenient short-cut to the media menu itself. Package Temp: Where package temporary files should go Some packages, like emacs, can use a LOT of temporary space - up to 20 or 30MB. If you are going to configure a small / directory and no separate /var (and hence a small /var/tmp), then you may wish to set this to point at another location (say, /usr/tmp). Re-scan Devices: Reprobe the system for devices. Use Defaults: Use default values. Reset all options back to their default values. diff --git a/usr.sbin/bsdconfig/share/device.subr b/usr.sbin/bsdconfig/share/device.subr index c60ad303acfc..4ca2a80c69a5 100644 --- a/usr.sbin/bsdconfig/share/device.subr +++ b/usr.sbin/bsdconfig/share/device.subr @@ -1,1392 +1,1380 @@ if [ ! "$_DEVICE_SUBR" ]; then _DEVICE_SUBR=1 # # Copyright (c) 2012-2016 Devin Teske # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # ############################################################ INCLUDES BSDCFG_SHARE="/usr/share/bsdconfig" . $BSDCFG_SHARE/common.subr || exit 1 f_dprintf "%s: loading includes..." device.subr f_include $BSDCFG_SHARE/dialog.subr f_include $BSDCFG_SHARE/geom.subr f_include $BSDCFG_SHARE/strings.subr f_include $BSDCFG_SHARE/struct.subr BSDCFG_LIBE="/usr/libexec/bsdconfig" f_include_lang $BSDCFG_LIBE/include/messages.subr ############################################################ GLOBALS NDEVICES=0 # Set by f_device_register(), used by f_device_*() # # A "device" from legacy sysinstall's point of view (mostly) # # NB: Disk devices have their `private' property set to GEOM ident # NB: USB devices have their `private' property set to USB disk device name # f_struct_define DEVICE \ capacity \ desc \ devname \ enabled \ flags \ get \ init \ name \ private \ shutdown \ type \ volume # Network devices have their `private' property set to this f_struct_define DEVICE_INFO \ extras \ ipaddr \ ipv6addr \ netmask \ use_dhcp \ use_rtsol # # Device types for f_device_register(), f_device_find(), et al. # setvar DEVICE_TYPE_ANY "any" # Any setvar DEVICE_TYPE_NONE "NONE" # Unknown setvar DEVICE_TYPE_DISK "DISK" # GEOM `DISK' -setvar DEVICE_TYPE_FLOPPY "FD" # GEOM `FD' setvar DEVICE_TYPE_FTP "FTP" # Dynamic network device setvar DEVICE_TYPE_NETWORK "NETWORK" # See f_device_get_all_network setvar DEVICE_TYPE_CDROM "CDROM" # GEOM `DISK' setvar DEVICE_TYPE_USB "USB" # GEOM `PART' setvar DEVICE_TYPE_DOS "DOS" # GEOM `DISK' `PART' or `LABEL' setvar DEVICE_TYPE_UFS "UFS" # GEOM `DISK' `PART' or `LABEL' setvar DEVICE_TYPE_NFS "NFS" # Dynamic network device setvar DEVICE_TYPE_HTTP_PROXY "HTTP_PROXY" # Dynamic network device setvar DEVICE_TYPE_HTTP "HTTP" # Dynamic network device # Network devices have the following flags available setvar IF_ETHERNET 1 setvar IF_WIRELESS 2 setvar IF_ACTIVE 4 # # Default behavior is to call f_device_get_all() automatically when loaded. # : ${DEVICE_SELF_SCAN_ALL=1} # # Device Catalog variables # DEVICE_CATALOG_APPEND_ONLY= # Used by f_device_catalog_set() NCATALOG_DEVICES=0 # Used by f_device_catalog_*() and MAIN # # A ``catalog'' device is for mapping GEOM devices to media devices (for # example, determining if a $GEOM_CLASS_DISK geom is $DEVICE_TYPE_CDROM or # $DEVICE_TYPE_DISK) and also getting default descriptions for devices that # either lack a GEOM provided description or lack a presence in GEOM) # f_struct_define CATALOG_DEVICE \ desc \ name \ type ############################################################ FUNCTIONS # f_device_register $var_to_set $name $desc $devname $type $enabled # $init_function $get_function $shutdown_function # $private $capacity # # Register a device. A `structure' (see struct.subr) is created and if # $var_to_set is non-NULL, upon success holds the name of the struct created. # The remaining positional arguments correspond to the properties of the # `DEVICE' structure-type to be assigned (defined above). # # If not already registered (based on $name and $type), a new device is created # and $NDEVICES is incremented. # f_device_register() { local __var_to_set="$1" __name="$2" __desc="$3" __devname="$4" local __type="$5" __enabled="$6" __init_func="$7" __get_func="$8" local __shutdown_func="$9" __private="${10}" __capacity="${11}" # Required parameter(s) [ "$__name" ] || return $FAILURE if [ "$__var_to_set" ]; then setvar "$__var_to_set" "" || return $FAILURE fi local __device if f_device_find -1 "$__name" "$__type" __device; then f_struct_free "$__device" f_struct_new DEVICE "$__device" || return $FAILURE else __device=device_$(( NDEVICES + 1 )) f_struct_new DEVICE "$__device" || return $FAILURE NDEVICES=$(( $NDEVICES + 1 )) fi $__device set name "$__name" $__device set desc "$__desc" $__device set devname "$__devname" $__device set type "$__type" $__device set enabled "$__enabled" $__device set init "$__init_func" $__device set get "$__get_func" $__device set shutdown "$__shutdown_func" $__device set private "$__private" $__device set capacity "$__capacity" [ "$__var_to_set" ] && setvar "$__var_to_set" "$__device" return $SUCCESS } # f_device_reset # # Reset the registered device chain. # f_device_reset() { local n=1 while [ $n -le $NDEVICES ]; do f_device_shutdown device_$n # # XXX This potentially leaks $dev->private if it's being # used to point to something dynamic, but you're not supposed # to call this routine at such times that some open instance # has its private member pointing somewhere anyway. # f_struct_free device_$n n=$(( $n + 1 )) done NDEVICES=0 } # f_device_reset_network # # Reset the registered network device chain. # f_device_reset_network() { local n=1 device type private i while [ $n -le $NDEVICES ]; do device=device_$n f_struct $device || continue $device get type type [ "$type" = "$DEVICE_TYPE_NETWORK" ] || continue # # Leave the device up (don't call shutdown routine) # # Network devices may have DEVICE_INFO private member $device get private private [ "$private" ] && f_struct_free "$private" # Free the network device f_struct_free $device # Fill the gap we just created i=$n while [ $i -lt $NDEVICES ]; do f_struct_copy device_$(( $i + 1 )) device_$i done f_struct_free device_$NDEVICES # Finally decrement the number of devices NDEVICES=$(( $NDEVICES - 1 )) n=$(( $n + 1 )) done } # f_device_get_all # # Get all device information for all devices. # f_device_get_all() { local devname type desc capacity f_dprintf "f_device_get_all: Probing devices..." f_dialog_info "$msg_probing_devices_please_wait_this_can_take_a_while" # First go for the network interfaces f_device_get_all_network # Next, go for the GEOM devices we might want to use as media local geom geoms geom_name debug= f_geom_find "" $GEOM_CLASS_DEV geoms for geom in $geoms; do if ! f_device_probe_geom $geom; then debug= $geom get name geom_name f_dprintf "WARNING! Unable to classify %s as %s" \ "GEOM device $geom_name" "media source" fi done } # f_device_get_all_network # # Get all network device information for attached network devices. # f_device_get_all_network() { local devname desc device flags for devname in $( ifconfig -l ); do # Eliminate network devices that don't make sense case "$devname" in lo*) continue ;; esac # Try and find its description f_device_desc "$devname" $DEVICE_TYPE_NETWORK desc f_dprintf "Found network device named %s" "$devname" debug= f_device_register device $devname "$desc" \ "$devname" $DEVICE_TYPE_NETWORK 1 \ f_media_init_network "" f_media_shutdown_network "" -1 # Set flags based on media and status flags=0 eval "$( ifconfig $devname 2> /dev/null | awk -v var=flags ' function _or(var, mask) { printf "%s=$(( $%s | $%s ))\n", var, var, mask } BEGIN { S = "[[:space:]]+" } { if (!match($0, "^" S "(media|status):" S)) next value = substr($0, RLENGTH + 1) if ($1 == "media:") { if (value ~ /Ethernet/) _or(var, "IF_ETHERNET") if (value ~ /802\.11/) _or(var, "IF_WIRELESS") } else if ($1 == "status:") { if (value ~ /^active/) _or(var, "IF_ACTIVE") } }' )" $device set flags $flags done } # f_device_rescan # # Rescan all devices, after closing previous set - convenience function. # f_device_rescan() { f_device_reset f_geom_rescan f_device_get_all } # f_device_rescan_network # # Rescan all network devices, after closing previous set - for convenience. # f_device_rescan_network() { f_device_reset_network f_device_get_all_network } # f_device_probe_geom $geom # # Probe a single GEOM device and if it can be classified as a media source, # register it using f_device_register() with known type-specific arguments. # f_device_probe_geom() { local geom="$1" f_struct "$geom" || return $FAILURE # geom associated variables local geom_name geom_consumer provider_ref geom_provider= local provider_geom provider_config provider_class= local provider_config_type catalog_struct catalog_type local disk_ident # gnop(8)/geli(8) associated variables (p for `parent device') local p_devname p_geom p_consumer p_provider_ref p_provider local p_provider_config p_provider_geom p_provider_class # md(4) associated variables local config config_type config_file magic= # Temporarily disable debugging to keep debug output light local old_debug="$debug" debug= # # Get the GEOM name (for use below in device registration) # $geom get name devname || continue # # Attempt to get the consumer, provider, provider config, and # provider class for this geom (errors ignored). # # NB: Each GEOM in the `DEV' class should have one consumer. # That consumer should have a reference to its provider. # $geom get consumer1 geom_consumer f_struct "$geom_consumer" get provider_ref provider_ref && f_geom_find_by id "$provider_ref" provider geom_provider if f_struct "$geom_provider"; then $geom_provider get config provider_config f_geom_parent $geom_provider provider_geom && f_geom_parent $provider_geom provider_class fi # # Get values for device registration (errors ignored) # f_struct "$provider_class" get name type f_struct "$geom_provider" get mediasize capacity f_struct "$provider_config" get descr desc # # For gnop(8), geli(8), or combination thereof, change device type to # that of the consumer # p_devname= p_geom= p_provider= p_provider_config= case "$devname" in *.nop.eli) p_devname="${devname%.nop.eli}" ;; *.eli.nop) p_devname="${devname%.eli.nop}" ;; *.eli) p_devname="${devname%.eli}" ;; *.nop) p_devname="${devname%.nop}" ;; esac [ "$p_devname" ] && f_geom_find "$p_devname" $GEOM_CLASS_DEV p_geom if [ "${p_geom:-$geom}" != "$geom" ]; then f_struct "$p_geom" get consumer1 p_consumer f_struct "$p_consumer" get provider_ref p_provider_ref && f_geom_find_by id "$p_provider_ref" provider p_provider if f_struct "$p_provider"; then $p_provider get config p_provider_config f_geom_parent $p_provider p_provider_geom && f_geom_parent $p_provider_geom p_provider_class fi f_struct "$p_provider_class" get name type fi # Look up geom device in device catalog for default description f_device_catalog_get \ $DEVICE_TYPE_ANY "${p_devname:-$devname}" catalog_struct [ "$desc" ] || f_struct "catalog_device_$catalog_struct" get desc desc # Use device catalog entry for potential re-classification(s) f_struct "catalog_device_$catalog_struct" get type catalog_type # Restore debugging for this next part (device registration) debug="$old_debug" # # Register the device # local retval device case "$type" in $GEOM_CLASS_DISK) # First attempt to classify by device catalog (see MAIN) case "$catalog_type" in $DEVICE_TYPE_CDROM) f_dprintf "Found CDROM device for disk %s" "$devname" debug= f_device_register device "$devname" "$desc" \ "/dev/$devname" $DEVICE_TYPE_CDROM 1 \ f_media_init_cdrom f_media_get_cdrom \ f_media_shutdown_cdrom "" "$capacity" && return $SUCCESS ;; esac # Fall back to register label device as a disk and taste it f_dprintf "Found disk device named %s" "$devname" debug= f_struct "$p_provider_config" get \ ident disk_ident || debug= f_struct "$provider_config" get \ ident disk_ident debug= f_device_register device "$devname" "$desc" \ "/dev/$devname" $DEVICE_TYPE_DISK 1 \ "" "" "" "$disk_ident" "$capacity" retval=$? # Detect ``dangerously dedicated'' filesystems (errors ignored) f_device_probe_disk_fs device "$devname" "$capacity" && retval=$SUCCESS return $retval ;; - $GEOM_CLASS_FD) - f_dprintf "Found floppy device named %s" "$devname" - debug= f_device_register device "$devname" "$desc" \ - "/dev/$devname" $DEVICE_TYPE_FLOPPY 1 \ - f_media_init_floppy f_media_get_floppy \ - f_media_shutdown_floppy "" "$capacity" - return $? - ;; $GEOM_CLASS_LABEL) : fall through to below section # reduces indentation level ;; $GEOM_CLASS_MD) f_dprintf "Found disk device named %s" "$devname" debug= f_device_register device "$devname" "$desc" \ "/dev/$devname" $DEVICE_TYPE_DISK 1 \ "" "" "" "" "$capacity" retval=$? # # Attempt to get file(1) magic to potentially classify as # alternate media type. If unable to get magic, fall back to # md(4) characteristics (such as vnode filename). # [ -r "/dev/$devname" ] && magic=$( file -bs "/dev/$devname" 2> /dev/null ) if [ ! "$magic" ]; then # Fall back to md(4) characteristics if f_struct "$p_provider_config"; then config="$p_provider_config" else config="$provider_config" fi debug= f_struct "$config" get type config_type debug= f_struct "$config" get file config_file # Substitute magic for below based on type and file case "$config_type=$config_file" in vnode=*.iso) magic="ISO 9660" ;; esac fi f_device_probe_disk_fs device \ "$devname" "$capacity" "$magic" && retval=$SUCCESS # Errors ignored return $retval ;; $GEOM_CLASS_PART) if f_struct "$p_provider_config"; then config="$p_provider_config" else config="$provider_config" fi debug= f_struct "$config" get type provider_config_type f_device_probe_geom_part device \ "$provider_config_type" "$devname" "$capacity" retval=$? device_type=$DEVICE_TYPE_NONE [ $retval -eq $SUCCESS ] && debug= f_struct "$device" get type device_type # Potentially re-classify as USB device if [ "$device_type" = "$DEVICE_TYPE_UFS" -a \ "$catalog_type" = "$DEVICE_TYPE_USB" ] then f_dprintf "Found USB device for partition %s" \ "$devname" debug= f_struct "$p_provider_geom" get \ name disk_name || debug= f_struct "$provider_geom" get \ name disk_name debug= f_device_register device "$devname" "$desc" \ "/dev/$devname" $DEVICE_TYPE_USB 1 \ f_media_init_usb f_media_get_usb \ f_media_shutdown_usb "$disk_name" "$capacity" retval=$? fi return $retval ;; $GEOM_CLASS_RAID) # Use the provider geom name as the description if [ ! "$desc" ]; then f_struct "$p_provider_geom" get name desc || f_struct "$provider_geom" get name desc fi f_dprintf "Found disk device named %s" "$devname" debug= f_device_register device \ "$devname" "${desc:-GEOM RAID device}" \ "/dev/$devname" $DEVICE_TYPE_DISK 1 \ "" "" "" "" "$capacity" retval=$? # Detect ``dangerously dedicated'' filesystems f_device_probe_disk_fs device "$devname" "$capacity" && retval=$SUCCESS # Errors ignored return $retval ;; $GEOM_CLASS_ZFS_ZVOL) f_dprintf "Found disk device named %s" "$devname" debug= f_device_register device \ "$devname" "${desc:-GEOM ZFS::ZVOL device}" \ "/dev/$devname" $DEVICE_TYPE_DISK 1 \ "" "" "" "" "$capacity" retval=$? # Detect ``dangerously dedicated'' filesystems f_device_probe_disk_fs device "$devname" "$capacity" && retval=$SUCCESS # Errors ignored return $retval ;; *) return $FAILURE # Unknown GEOM class esac # # Still here? Must be $GEOM_CLASS_LABEL # local label_geom label_devname label_devgeom= label_devconsumer local label_devprovider= label_devprovider_ref label_devprovider_config local label_gpart_type if f_struct "$p_provider"; then label_geom="$p_provider_geom" else label_geom="$provider_geom" fi case "$devname" in gpt/*|gptid/*) # # Attempt to get the partition type by getting the `config' # member of the provider for our device (which is named in the # parent geom of our current provider). # debug= f_struct "$label_geom" get name label_devname && debug= f_geom_find "$label_devname" $GEOM_CLASS_DEV \ label_devgeom debug= f_struct "$label_devgeom" get \ consumer1 label_devconsumer debug= f_struct "$label_devconsumer" get \ provider_ref label_devprovider_ref && debug= f_geom_find_by id "$label_devprovider_ref" \ provider label_devprovider debug= f_struct "$label_devprovider" get \ config label_devprovider_config debug= f_struct "$label_devprovider_config" get \ type label_gpart_type # # Register device label based on partition type # f_device_probe_geom_part device \ "$label_gpart_type" "$devname" "$capacity" return $? ;; iso9660/*) f_dprintf "Found CDROM device labeled %s" "$devname" debug= f_device_register device \ "$devname" "ISO9660 file system" \ "/dev/$devname" $DEVICE_TYPE_CDROM 1 \ f_media_init_cdrom f_media_get_cdrom \ f_media_shutdown_cdrom "" "$capacity" return $? ;; label/*) # For generic labels, use provider geom name as real device debug= f_struct "$label_geom" get name label_devname # Look up label geom device in device catalog for default desc debug= f_device_catalog_get \ $DEVICE_TYPE_ANY "$label_devname" catalog_struct [ "$desc" ] || debug= f_struct \ "catalog_device_$catalog_struct" get desc desc # Use device catalog entry for potential re-classification(s) debug= f_struct "catalog_device_$catalog_struct" get \ type catalog_type # First attempt to classify by device catalog (see MAIN) case "$catalog_type" in $DEVICE_TYPE_CDROM) f_dprintf "Found CDROM device for disk %s" "$devname" debug= f_device_register device "$devname" "$desc" \ "/dev/$devname" $DEVICE_TYPE_CDROM 1 \ f_media_init_cdrom f_media_get_cdrom \ f_media_shutdown_cdrom "" "$capacity" && return $SUCCESS ;; esac # Fall back to register label device as a disk and taste it f_dprintf "Found disk device labeled %s" "$devname" debug= f_device_register device \ "$devname" "GEOM LABEL device" \ "/dev/$devname" $DEVICE_TYPE_DISK 1 \ "" "" "" "" "$capacity" retval=$? # Detect ``dangerously dedicated'' filesystems (errors ignored) f_device_probe_disk_fs device "$devname" "$capacity" && retval=$SUCCESS return $retval ;; msdosfs/*) f_dprintf "Found DOS partition labeled %s" "$devname" debug= f_device_register device "$devname" "DOS file system" \ "/dev/$devname" $DEVICE_TYPE_DOS 1 \ f_media_init_dos f_media_get_dos \ f_media_shutdown_dos "" "$capacity" return $? ;; ufs/*|ufsid/*) f_dprintf "Found UFS partition labeled %s" "$devname" debug= f_device_register device "$devname" "UFS file system" \ "/dev/$devname" $DEVICE_TYPE_UFS 1 \ f_media_init_ufs f_media_get_ufs \ f_media_shutdown_ufs "" "$capacity" return $? ;; ext2fs/*|ntfs/*|reiserfs/*) return $FAILURE # No media device handlers for these labels ;; esac # Unable to classify GEOM label return $FAILURE } # f_device_probe_geom_part $var_to_set $gpart_type $devname $capacity [$magic] # # Given a gpart(8) partition type and a device name, register the device if it # is a known partition type that we can handle. If $var_to_set is non-NULL, # upon success holds the DEVICE struct name of the registered device. # # Returns success if the device was successfully registered, failure otherwise. # f_device_probe_geom_part() { local __var_to_set="$1" __gpart_type="$2" __devname="$3" local __capacity="${4:--1}" __magic="$5" # # Register device based on partition type # NB: !0 equates to `unused' bsdlabel # case "$__gpart_type" in fat16|fat32) f_dprintf "Found DOS partition named %s" "$__devname" debug= f_device_register "$__var_to_set" \ "$__devname" "DOS file system" \ "/dev/$__devname" $DEVICE_TYPE_DOS 1 \ f_media_init_dos f_media_get_dos \ f_media_shutdown_dos "" "$__capacity" return $? ;; freebsd|!0) # Commonly used inappropriately, taste for FreeBSD [ -r "/dev/$__devname" -a ! "$__magic" ] && __magic=$( file -bs "/dev/$__devname" 2> /dev/null ) case "$__magic" in *"Unix Fast File system"*) f_dprintf "Found UFS partition named %s" "$__devname" debug= f_device_register "$__var_to_set" \ "$__devname" "UFS file system" \ "/dev/$__devname" $DEVICE_TYPE_UFS 1 \ f_media_init_ufs f_media_get_ufs \ f_media_shutdown_ufs "" "$__capacity" return $? esac return $FAILURE ;; freebsd-ufs) f_dprintf "Found UFS partition named %s" "$__devname" debug= f_device_register "$__var_to_set" \ "$__devname" "UFS file system" \ "/dev/$__devname" $DEVICE_TYPE_UFS 1 \ f_media_init_ufs f_media_get_ufs \ f_media_shutdown_ufs "" "$__capacity" return $? ;; apple-*|linux-*|ms-*|netbsd-*|ntfs|vmware-*) return $FAILURE # No device types for these ;; bios-*|ebr|efi|mbr|freebsd-boot|freebsd-swap) return $FAILURE # Not a source for media ;; freebsd-nandfs|freebsd-vinum|freebsd-zfs) return $FAILURE # Unsupported as media source ;; esac return $FAILURE # Unknown partition type } # f_device_probe_disk_fs $var_to_set $devname [$capacity [$magic]] # # Given a device name, taste it and register the device if it is a so-called # ``dangerously dedicated'' file system written without a partition table. # Tasting is done using file(1) (specifically `file -bs') but if $magic is # present and non-NULL it is used instead. If $var_to_set is non-NULL, upon # success holds the DEVICE struct name of the registered device. # # Returns success if the device was successfully registered, failure otherwise. # f_device_probe_disk_fs() { local __var_to_set="$1" __devname="$2" __capacity="${3:--1}" local __magic="$4" [ -r "/dev/${__devname#/dev/}" -a ! "$__magic" ] && __magic=$( file -bs "/dev/$__devname" 2> /dev/null ) case "$__magic" in *"ISO 9660"*) f_dprintf "Found CDROM device for disk %s" "$__devname" debug= f_device_register "$__var_to_set" \ "$__devname" "ISO9660 file system" \ "/dev/$__devname" $DEVICE_TYPE_CDROM 1 \ f_media_init_cdrom f_media_get_cdrom \ f_media_shutdown_cdrom "" "$__capacity" return $? ;; *"Unix Fast File system"*) f_dprintf "Found UFS device for disk %s" "$__devname" debug= f_device_register "$__var_to_set" \ "$__devname" "UFS file system" \ "/dev/$__devname" $DEVICE_TYPE_UFS 1 \ f_media_init_ufs f_media_get_ufs \ f_media_shutdown_ufs "" "$__capacity" return $? ;; *"FAT (12 bit)"*|*"FAT (16 bit)"*|*"FAT (32 bit)"*) f_dprintf "Found DOS device for disk %s" "$__devname" debug= f_device_register "$__var_to_set" \ "$__devname" "DOS file system" \ "/dev/$__devname" $DEVICE_TYPE_DOS 1 \ f_media_init_dos f_media_get_dos \ f_media_shutdown_dos "" "$__capacity" return $? ;; esac return $FAILURE # Unknown file system type } # f_device_catalog_get $type $name [$var_to_set] # # Fetch the struct name of the catalog device matching device $name. If $type # is either NULL, missing, or set to $DEVICE_TYPE_ANY then only $name is used. # Returns success if a match was found, otherwise failure. # # If $var_to_set is missing or NULL, the struct name is printed to standard out # for capturing in a sub-shell (which is less-recommended because of # performance degredation; for example, when called in a loop). # f_device_catalog_get() { local __type="$1" __name="$2" __var_to_set="$3" local __dname= # Return failure if no $name [ "$__name" ] || return $FAILURE # Disable debugging to keep debug output light local debug= # # Attempt to create an alternate-form of $__name that contains the # first contiguous string of numbers replaced with `%d' for comparison # against stored pattern names (see MAIN). # local __left="${__name%%[0-9]*}" __right="${__name#*[0-9]}" if [ "$__left" != "$__name" ]; then # Chop leading digits from right 'til we hit first non-digit while :; do case "$__right" in [0-9]*) __right="${__right#[0-9]}" ;; *) break esac done __dname="${__left}%d$__right" fi [ "$__type" = "$DEVICE_TYPE_ANY" ] && __type= local __dev __dev_name __dev_type for __dev in $DEVICE_CATALOG; do catalog_device_$__dev get name __dev_name [ "$__dev_name" = "$__name" -o "$__dev_name" = "$__dname" ] || continue catalog_device_$__dev get type __dev_type [ "${__type:-$__dev_type}" = "$__dev_type" ] || continue if [ "$__var_to_set" ]; then setvar "$__var_to_set" $__dev else echo $__dev fi return $? done [ "$__var_to_set" ] && setvar "$__var_to_set" "" return $FAILURE } # f_device_catalog_set $type $name $desc # # Store a description (desc) in-association with device $type and $name. # Returns success unless $name is NULL or missing. Use f_device_catalog_get() # routine with the same $name and optionally $type to retrieve catalog device # structure (see CATALOG_DEVICE struct definition in GLOBALS section). # f_device_catalog_set() { local type="$1" name="$2" desc="$3" local struct dev dev_type found= [ "$name" ] || return $FAILURE # Disable debugging to keep debug output light local debug= f_str2varname "$name" struct if [ ! "$DEVICE_CATALOG_APPEND_ONLY" ]; then for dev in $DEVICE_CATALOG; do [ "$dev" = "$struct" ] || continue found=1 break done fi if [ "$found" ]; then f_struct_free "catalog_device_$struct" else DEVICE_CATALOG="$DEVICE_CATALOG $struct" fi f_struct_new CATALOG_DEVICE "catalog_device_$struct" || return $FAILURE catalog_device_$struct set type "$type" catalog_device_$struct set name "$name" catalog_device_$struct set desc "$desc" return $SUCCESS } # f_device_desc $device_name $device_type [$var_to_set] # # Print a description for a device name (eg., `fxp0') given a specific device # type/class. # # If $var_to_set is missing or NULL, the device description is printed to # standard out for capturing in a sub-shell (which is less-recommended because # of performance degredation; for example, when called in a loop). # f_device_desc() { local __name="$1" __type="$2" __var_to_set="$3" local __devname __devunit __cp # Check variables [ "$__name" ] || return $SUCCESS [ "$__type" = "$DEVICE_TYPE_ANY" ] && type= [ "$__var_to_set" ] && { setvar "$__var_to_set" "" || return; } # # Return sysctl MIB dev.NAME.UNIT.%desc if it exists, otherwise fall # through to further alternate methods. # if f_have sysctl; then __devname="${__name%%[0-9]*}" __devunit="${__name#$__devname}" __devunit="${__devunit%%[!0-9]*}" if [ "$__var_to_set" ]; then if __cp=$( sysctl -n "dev.$__devname.$__devunit.%desc" \ 2> /dev/null ); then setvar "$__var_to_set" "$__cp" && return $SUCCESS fi else sysctl -n "dev.$__devname.$__devunit.%desc" \ 2> /dev/null && return $SUCCESS fi fi # Look up device in catalog for default description local __catalog_struct debug= f_device_catalog_get "$__type" "$__name" __catalog_struct debug= f_struct "catalog_device_$__catalog_struct" get \ desc "$__var_to_set" && return $SUCCESS # # Sensible fall-backs for specific types # case "$__type" in $DEVICE_TYPE_CDROM) __cp="" ;; $DEVICE_TYPE_DISK) __cp="" ;; - $DEVICE_TYPE_FLOPPY) __cp="" ;; $DEVICE_TYPE_USB) __cp="" ;; $DEVICE_TYPE_NETWORK) __cp="" ;; *) __cp="" esac if [ "$__var_to_set" ]; then setvar "$__var_to_set" "$__cp" else echo "$__cp" fi return $FAILURE } # f_device_is_ethernet $device # # Returns true if $device is a wired Ethernet network interface. Otherwise # returns false. Example wired interfaces include: fxp0 em0 bge0 rl0 etc. # f_device_is_ethernet() { local dev="$1" type flags # Make sure we have an actual device by that name f_struct "$dev" || return $FAILURE # Make sure that the device is a network device $dev get type type [ "$type" = "$DEVICE_TYPE_NETWORK" ] || return $FAILURE # Make sure that the media flags indicate that it is Ethernet $dev get flags flags [ $(( ${flags:-0} & $IF_ETHERNET )) -eq $IF_ETHERNET ] } # f_device_is_wireless $device # # Returns true if $device is a Wireless network interface. Otherwise returns # false. Examples of wireless interfaces include: iwn0 # f_device_is_wireless() { local dev="$1" type flags # Make sure we have an actual device by that name f_struct "$dev" || return $FAILURE # Make sure that the device is a network device $dev get type type [ "$type" = "$DEVICE_TYPE_NETWORK" ] || return $FAILURE # Make sure that the media flags indicate that it is 802.11 wireless $dev get flags flags [ $(( ${flags:-0} & $IF_WIRELESS )) -eq $IF_WIRELESS ] } # f_device_is_active $device # # Returns true if $device is active. Otherwise returns false. Currently this # only works for network interfaces. # f_device_is_active() { local dev="$1" type flags=0 # Make sure we have an actual device by that name f_struct "$dev" || return $FAILURE $dev get type type case "$type" in $DEVICE_TYPE_NETWORK) # Make sure that the media flags indicate that it is active $dev get flags flags [ $(( ${flags:-0} & $IF_ACTIVE )) -eq $IF_ACTIVE ] ;; *) return $FAILURE esac } # f_device_find [-1] $name [$type [$var_to_set]] # # Find one or more registered devices by name, type, or both. Returns a space- # separated list of devices matching the search criterion. # # If `-1' option flag is given, only the first matching device is returned. # # If $var_to_set is missing or NULL, the device name(s) are printed to standard # out for capturing in a sub-shell (which is less-recommended because of # performance degredation; for example, when called in a loop). # f_device_find() { local OPTIND=1 OPTARG flag only_one= while getopts 1 flag; do case "$flag" in 1) only_one=1 ;; esac done shift $(( $OPTIND - 1 )) local __name="$1" __type="${2:-$DEVICE_TYPE_ANY}" __var_to_set="$3" local __n=1 __devname __devtype __found= while [ $__n -le $NDEVICES ]; do device_$__n get name __devname device_$__n get type __devtype if [ "$__name" = "$__devname" -o ! "$__name" ] && [ "$__type" = "$DEVICE_TYPE_ANY" -o \ "$__type" = "$__devtype" ] then __found="$__found device_$__n" [ "$only_one" ] && break fi __n=$(( $__n + 1 )) done if [ "$__var_to_set" ]; then setvar "$__var_to_set" "${__found# }" else echo $__found fi [ "$__found" ] # Return status } # f_device_init $device # # Initialize a device by evaluating its `init' function. The $device argument # is a DEVICE struct name. # f_device_init() { local device="$1" init_func f_struct "$device" || return $? $device get init init_func ${init_func:-:} "$device" } # f_device_get $device $file [$probe] # # Read $file by evaluating the device's `get' function. The file is commonly # produced on standard output (but it truly depends on the function called). # The $device argument is a DEVICE struct name. # f_device_get() { local device="$1" file="$2" probe="$3" get_func f_struct "$device" || return $? $device get get get_func ${get_func:-:} "$device" "$file" ${3+"$probe"} } # f_device_shutdown $device # # Shutdown a device by evaluating its `shutdown' function. The $device argument # is a DEVICE struct name. # f_device_shutdown() { local device="$1" shutdown_func f_struct "$device" || return $? $device get shutdown shutdown_func ${shutdown_func:-:} "$device" } # f_devices_sort_by $property $var_to_get [$var_to_set] # # Take list of devices from $var_to_get (separated by whitespace, newline # included) and sort them by $property (e.g., `name'). The sorted list of # DEVICE struct names is returned on standard output separated by whitespace # (newline to be specific) unless $var_to_set is present and non-NULL. # # This function is a two-parter. Below is the awk(1) portion of the function, # afterward is the sh(1) function which utilizes the below awk script. # f_device_sort_by_awk=' # Variables that should be defined on the invocation line: # -v prop="property" function _asorti(src, dest) { k = nitems = 0 for (i in src) dest[++nitems] = i for (i = 1; i <= nitems; k = i++) { idx = dest[i] while ((k > 0) && (dest[k] > idx)) { dest[k+1] = dest[k]; k-- } dest[k+1] = idx } return nitems } { split($0, devs, FS) for (d in devs) { name = ENVIRON["_struct_value_" devs[d] "_" prop] devices[name] = devs[d] } } END { nitems = _asorti(devices, devices_sorted) for (i = 1; i <= nitems; i++) print devices[devices_sorted[i]] } ' f_device_sort_by() { local __property="${1:-name}" __var_to_get="$2" __var_to_set="$3" f_isset "$__var_to_get" || return $FAILURE local __dev for __dev in $( f_getvar "$__var_to_get" ); do export _struct_value_${__dev}_$__property done local __cp setvar "${__var_to_set:-__cp}" "$( f_getvar "$__var_to_get" | awk -v prop="$__property" "$f_device_sort_by_awk" )" [ "$__var_to_set" ] || echo "$__cp" } # f_device_menu $title $prompt $hline $device_type [$helpfile] # # Display a menu listing all the devices of a certain type in the system. # f_device_menu() { f_dialog_title "$1" local title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE" f_dialog_title_restore local prompt="$2" hline="$3" type="$4" helpfile="$5" local devs f_device_find "" "$type" devs || return $DIALOG_CANCEL local name desc menu_list= f_device_sort_by name devs devs for dev in $devs; do $dev get name name $dev get desc desc f_shell_escape "$name" name f_shell_escape "$desc" desc menu_list="$menu_list '$name' '$desc'" # END-QUOTE done menu_list="${menu_list#$NL}" local height width rows eval f_dialog_menu_size height width rows \ \"\$title\" \ \"\$btitle\" \ \"\$prompt\" \ \"\$hline\" \ $menu_list local errexit= case $- in *e*) errexit=1; esac set +e local mtag while :; do mtag=$( eval $DIALOG \ --title \"\$title\" \ --backtitle \"\$btitle\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ --cancel-label \"\$msg_cancel\" \ ${helpfile:+ \ --help-button \ --help-label \"\$msg_help\" \ ${USE_XDIALOG:+--help \"\"} \ } \ --menu \"\$prompt\" \ $height $width $rows \ $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) local retval=$? [ $retval -ne $DIALOG_HELP ] && break # Otherwise, the Help button was pressed f_show_help "$helpfile" # ...then loop back to menu done f_dprintf "retval=%u mtag=[%s]" $retval "$mtag" [ "$errexit" ] && set -e if [ $retval -eq $DIALOG_OK ]; then # Clean up the output of [X]dialog(1) f_dialog_data_sanitize mtag # Map the user's choice back to a struct name local index device index=$( eval f_dialog_menutag2index \"\$mtag\" $menu_list ) device=$( set -- $devs; eval echo \${$index} ) echo "$device" >&2 fi return $retval } # # Short-hand # f_cdrom() { f_device_catalog_set $DEVICE_TYPE_CDROM "$1" "$2"; } f_disk() { f_device_catalog_set $DEVICE_TYPE_DISK "$1" "$2"; } -f_floppy() { f_device_catalog_set $DEVICE_TYPE_FLOPPY "$1" "$2"; } f_usb() { f_device_catalog_set $DEVICE_TYPE_USB "$1" "$2"; } f_network() { f_device_catalog_set $DEVICE_TYPE_NETWORK "$1" "$2"; } ############################################################ MAIN # # The below classifications allow us to re-group the GEOM devices from the # `DEV' GEOM class appropriately while providing fall-back descriptions both # for making the below code more maintainable and handling the rare case the # GEOM device lacks a description. # DEVICE_CATALOG_APPEND_ONLY=1 # Make initial loading faster -# CDROM, Disk, Floppy, and USB devices/names +# CDROM, Disk, and USB devices/names f_cdrom "cd%d" "SCSI CDROM drive" f_cdrom "mcd%d" "Mitsumi (old model) CDROM drive" f_cdrom "scd%d" "Sony CDROM drive - CDU31/33A type" f_disk "aacd%d" "Adaptec FSA RAID array" f_disk "ada%d" "ATA/SATA disk device" f_disk "amrd%d" "AMI MegaRAID drive" f_disk "da%d" "SCSI disk device" f_disk "idad%d" "Compaq RAID array" f_disk "ipsd%d" "IBM ServeRAID RAID array" f_disk "md%d" "md(4) disk device" f_disk "mfid%d" "LSI MegaRAID SAS array" f_disk "mlxd%d" "Mylex RAID disk" f_disk "twed%d" "3ware ATA RAID array" f_disk "vtbd%d" "VirtIO Block Device" -f_floppy "fd%d" "Floppy Drive unit A" f_usb "da%da" "USB Mass Storage Device" # Network interfaces/names f_network "ae%d" "Attansic/Atheros L2 Fast Ethernet" f_network "age%d" "Attansic/Atheros L1 Gigabit Ethernet" f_network "alc%d" "Atheros AR8131/AR8132 PCIe Ethernet" f_network "ale%d" "Atheros AR8121/AR8113/AR8114 PCIe Ethernet" f_network "an%d" "Aironet 4500/4800 802.11 wireless adapter" f_network "ath%d" "Atheros IEEE 802.11 wireless adapter" f_network "aue%d" "ADMtek USB Ethernet adapter" f_network "axe%d" "ASIX Electronics USB Ethernet adapter" f_network "bce%d" "Broadcom NetXtreme II Gigabit Ethernet card" f_network "bfe%d" "Broadcom BCM440x PCI Ethernet card" f_network "bge%d" "Broadcom BCM570x PCI Gigabit Ethernet card" f_network "bm%d" "Apple BMAC Built-in Ethernet" f_network "bwn%d" "Broadcom BCM43xx IEEE 802.11 wireless adapter" f_network "cas%d" "Sun Cassini/Cassini+ or NS DP83065 Saturn Ethernet" f_network "cc3i%d" "SDL HSSI sync serial PCI card" f_network "cue%d" "CATC USB Ethernet adapter" f_network "cxgb%d" "Chelsio T3 10Gb Ethernet card" f_network "dc%d" "DEC/Intel 21143 (and clones) PCI Fast Ethernet card" f_network "de%d" "DEC DE435 PCI NIC or other DC21040-AA based card" f_network "disc%d" "Software discard network interface" f_network "ed%d" "Novell NE1000/2000; 3C503; NE2000-compatible PCMCIA" f_network "el%d" "3Com 3C501 Ethernet card" f_network "em%d" "Intel(R) PRO/1000 Ethernet card" f_network "ep%d" "3Com 3C509 Ethernet card/3C589 PCMCIA" f_network "et%d" "Agere ET1310 based PCI Express Gigabit Ethernet card" f_network "ex%d" "Intel EtherExpress Pro/10 Ethernet card" f_network "fe%d" "Fujitsu MB86960A/MB86965A Ethernet card" f_network "fpa%d" "DEC DEFPA PCI FDDI card" f_network "fwe%d" "FireWire Ethernet emulation" f_network "fwip%d" "IP over FireWire" f_network "fxp%d" "Intel EtherExpress Pro/100B PCI Fast Ethernet card" f_network "gem%d" "Apple GMAC or Sun ERI/GEM Ethernet adapter" f_network "hme%d" "Sun HME (Happy Meal Ethernet) Ethernet adapter" f_network "ie%d" "AT&T StarLAN 10 and EN100; 3Com 3C507; NI5210" f_network "igb%d" "Intel(R) PRO/1000 PCI Express Gigabit Ethernet card" f_network "ipw%d" "Intel PRO/Wireless 2100 IEEE 802.11 adapter" f_network "iwi%d" "Intel PRO/Wireless 2200BG/2225BG/2915ABG adapter" f_network "iwn%d" "Intel Wireless WiFi Link 4965AGN IEEE 802.11n adapter" f_network "ix%d" "Intel Etherexpress Ethernet card" f_network "ixgbe%d" "Intel(R) PRO/10Gb Ethernet card" f_network "jme%d" "JMicron JMC250 Gigabit/JMC260 Fast Ethernet" f_network "kue%d" "Kawasaki LSI USB Ethernet adapter" f_network "le%d" "AMD Am7900 LANCE or Am79C9xx PCnet Ethernet adapter" f_network "lge%d" "Level 1 LXT1001 Gigabit Ethernet card" f_network "lnc%d" "Lance/PCnet (Isolan/Novell NE2100/NE32-VL) Ethernet" f_network "lo%d" "Loop-back (local) network interface" f_network "lp%d" "Parallel Port IP (PLIP) peer connection" f_network "malo%d" "Marvell Libertas 88W8335 802.11 wireless adapter" f_network "msk%d" "Marvell/SysKonnect Yukon II Gigabit Ethernet" f_network "mxge%d" "Myricom Myri10GE 10Gb Ethernet card" f_network "nfe%d" "NVIDIA nForce MCP Ethernet" f_network "ng%d" "Vimage netgraph(4) bridged Ethernet device" f_network "nge%d" "NatSemi PCI Gigabit Ethernet card" f_network "nve%d" "NVIDIA nForce MCP Ethernet" f_network "pcn%d" "AMD Am79c79x PCI Ethernet card" f_network "plip%d" "Parallel Port IP (PLIP) peer connection" f_network "ral%d" "Ralink Technology IEEE 802.11 wireless adapter" f_network "ray%d" "Raytheon Raylink 802.11 wireless adapter" f_network "re%d" "RealTek 8139C+/8169/8169S/8110S PCI Ethernet adapter" f_network "rl%d" "RealTek 8129/8139 PCI Ethernet card" f_network "rue%d" "RealTek USB Ethernet card" f_network "rum%d" "Ralink Technology USB IEEE 802.11 wireless adapter" f_network "sf%d" "Adaptec AIC-6915 PCI Ethernet card" f_network "sge%d" "Silicon Integrated Systems SiS190/191 Ethernet" f_network "sis%d" "SiS 900/SiS 7016 PCI Ethernet card" f_network "sk%d" "SysKonnect PCI Gigabit Ethernet card" f_network "sn%d" "SMC/Megahertz Ethernet card" f_network "snc%d" "SONIC Ethernet card" f_network "sr%d" "SDL T1/E1 sync serial PCI card" f_network "ste%d" "Sundance ST201 PCI Ethernet card" f_network "stge%d" "Sundance/Tamarack TC9021 Gigabit Ethernet" f_network "ti%d" "Alteon Networks PCI Gigabit Ethernet card" f_network "tl%d" "Texas Instruments ThunderLAN PCI Ethernet card" f_network "tx%d" "SMC 9432TX Ethernet card" f_network "txp%d" "3Com 3cR990 Ethernet card" f_network "uath%d" "Atheros AR5005UG and AR5005UX USB wireless adapter" f_network "upgt%d" "Conexant/Intersil PrismGT USB wireless adapter" f_network "ural%d" "Ralink Technology RT2500USB 802.11 wireless adapter" f_network "urtw%d" "Realtek 8187L USB wireless adapter" f_network "vge%d" "VIA VT612x PCI Gigabit Ethernet card" f_network "vlan%d" "IEEE 802.1Q VLAN network interface" f_network "vr%d" "VIA VT3043/VT86C100A Rhine PCI Ethernet card" f_network "vx%d" "3COM 3c590 / 3c595 Ethernet card" f_network "wb%d" "Winbond W89C840F PCI Ethernet card" f_network "wi%d" "Lucent WaveLAN/IEEE 802.11 wireless adapter" f_network "wpi%d" "Intel 3945ABG IEEE 802.11 wireless adapter" f_network "wx%d" "Intel Gigabit Ethernet (82452) card" f_network "xe%d" "Xircom/Intel EtherExpress Pro100/16 Ethernet card" f_network "xl%d" "3COM 3c90x / 3c90xB PCI Ethernet card" f_network "zyd%d" "ZyDAS ZD1211/ZD1211B USB 802.11 wireless adapter" DEVICE_CATALOG_APPEND_ONLY= # Additional loading modifies existing devices f_count NCATALOG_DEVICES $DEVICE_CATALOG f_dprintf "%s: Initialized device catalog with %u names/descriptions." \ device.subr $NCATALOG_DEVICES # # Scan for the above devices unless requeted otherwise # f_dprintf "%s: DEVICE_SELF_SCAN_ALL=[%s]" device.subr "$DEVICE_SELF_SCAN_ALL" case "$DEVICE_SELF_SCAN_ALL" in ""|0|[Nn][Oo]|[Oo][Ff][Ff]|[Ff][Aa][Ll][Ss][Ee]) : do nothing ;; *) f_device_get_all esac f_dprintf "%s: Successfully loaded." device.subr fi # ! $_DEVICE_SUBR diff --git a/usr.sbin/bsdconfig/share/media/Makefile b/usr.sbin/bsdconfig/share/media/Makefile index d6b77d96ee7f..2cbce2d492b2 100644 --- a/usr.sbin/bsdconfig/share/media/Makefile +++ b/usr.sbin/bsdconfig/share/media/Makefile @@ -1,7 +1,7 @@ FILESDIR= ${SHAREDIR}/bsdconfig/media FILES= any.subr cdrom.subr common.subr directory.subr dos.subr \ - floppy.subr ftp.subr http.subr httpproxy.subr network.subr \ + ftp.subr http.subr httpproxy.subr network.subr \ nfs.subr options.subr tcpip.subr ufs.subr usb.subr wlan.subr .include diff --git a/usr.sbin/bsdconfig/share/media/any.subr b/usr.sbin/bsdconfig/share/media/any.subr index d98f58567bfa..ea4fef0b5151 100644 --- a/usr.sbin/bsdconfig/share/media/any.subr +++ b/usr.sbin/bsdconfig/share/media/any.subr @@ -1,148 +1,145 @@ if [ ! "$_MEDIA_ANY_SUBR" ]; then _MEDIA_ANY_SUBR=1 # # Copyright (c) 2012-2013 Devin Teske # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # ############################################################ INCLUDES BSDCFG_SHARE="/usr/share/bsdconfig" . $BSDCFG_SHARE/common.subr || exit 1 f_dprintf "%s: loading includes..." media/any.subr f_include $BSDCFG_SHARE/dialog.subr f_include $BSDCFG_SHARE/media/cdrom.subr f_include $BSDCFG_SHARE/media/directory.subr f_include $BSDCFG_SHARE/media/dos.subr -f_include $BSDCFG_SHARE/media/floppy.subr f_include $BSDCFG_SHARE/media/ftp.subr f_include $BSDCFG_SHARE/media/http.subr f_include $BSDCFG_SHARE/media/httpproxy.subr f_include $BSDCFG_SHARE/media/nfs.subr f_include $BSDCFG_SHARE/media/options.subr f_include $BSDCFG_SHARE/media/ufs.subr f_include $BSDCFG_SHARE/media/usb.subr f_include $BSDCFG_SHARE/struct.subr BSDCFG_LIBE="/usr/libexec/bsdconfig" f_include_lang $BSDCFG_LIBE/include/messages.subr MEDIA_HELPFILE=$BSDCFG_LIBE/include/media.hlp ############################################################ FUNCTIONS # f_media_get_type # # Prompt the user to select amongst the known media types (included above). # # If the user does not cancel or press Esc, invokes the f_media_set_* function # associated with the chosen media type. If after all that we have a struct # named `device_media' then success is returned, otherwise failure. # # NOTE: The f_media_set_* function should create the `device_media' struct. # See `struct.subr' and the above `media/*.subr' includes for more details. # f_media_get_type() { f_dialog_title "$msg_choose_installation_media" local title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE" f_dialog_title_restore local prompt="$msg_choose_installation_media_description" local menu_list=" '1 $msg_cd_dvd' '$msg_install_from_a_freebsd_cd_dvd' '2 $msg_ftp' '$msg_install_from_an_ftp_server' '3 $msg_http_proxy' '$msg_install_from_an_ftp_server_thru_proxy' '4 $msg_http_direct' '$msg_install_from_an_http_server' '5 $msg_directory' '$msg_install_from_the_existing_filesystem' '6 $msg_nfs' '$msg_install_over_nfs' '7 $msg_dos' '$msg_install_from_a_dos_partition' '8 $msg_ufs' '$msg_install_from_a_ufs_partition' - '9 $msg_floppy' '$msg_install_from_a_floppy_disk_set' 'A $msg_usb' '$msg_install_from_a_usb_drive' 'X $msg_options' '$msg_view_set_various_media_options' " # END-QUOTE local hline="$hline_choose_help_for_more_information_on_media_types" local height width rows eval f_dialog_menu_size height width rows \ \"\$title\" \ \"\$btitle\" \ \"\$prompt\" \ \"\$hline\" \ $menu_list local mtag while :; do mtag=$( eval $DIALOG \ --title \"\$title\" \ --backtitle \"\$btitle\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ --cancel-label \"\$msg_cancel\" \ --help-button \ --help-label \"\$msg_help\" \ ${USE_XDIALOG:+--help \"\"} \ --menu \"\$prompt\" \ $height $width $rows \ $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) local retval=$? f_dialog_data_sanitize mtag f_dprintf "retval=%s mtag=[%s]" $retval "$mtag" if [ $retval -eq $DIALOG_HELP ]; then f_show_help "$MEDIA_HELPFILE" continue elif [ $retval -ne $DIALOG_OK ]; then return $FAILURE fi case "$mtag" in ?" $msg_cd_dvd") f_media_set_cdrom ;; ?" $msg_ftp") f_media_set_ftp ;; ?" $msg_http_proxy") f_media_set_http_proxy ;; ?" $msg_http_direct") f_media_set_http ;; ?" $msg_directory") f_media_set_directory ;; ?" $msg_dos") f_media_set_dos ;; ?" $msg_nfs") f_media_set_nfs ;; ?" $msg_ufs") f_media_set_ufs ;; - ?" $msg_floppy") f_media_set_floppy ;; ?" $msg_usb") f_media_set_usb ;; ?" $msg_options") f_media_options_menu continue ;; esac break done f_struct device_media || return $FAILURE } ############################################################ MAIN f_dprintf "%s: Successfully loaded." media/any.subr fi # ! $_MEDIA_ANY_SUBR diff --git a/usr.sbin/bsdconfig/share/media/floppy.subr b/usr.sbin/bsdconfig/share/media/floppy.subr deleted file mode 100644 index ae17ee27f282..000000000000 --- a/usr.sbin/bsdconfig/share/media/floppy.subr +++ /dev/null @@ -1,228 +0,0 @@ -if [ ! "$_MEDIA_FLOPPY_SUBR" ]; then _MEDIA_FLOPPY_SUBR=1 -# -# Copyright (c) 2012-2013 Devin Teske -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# -# -############################################################ INCLUDES - -BSDCFG_SHARE="/usr/share/bsdconfig" -. $BSDCFG_SHARE/common.subr || exit 1 -f_dprintf "%s: loading includes..." media/floppy.subr -f_include $BSDCFG_SHARE/device.subr -f_include $BSDCFG_SHARE/dialog.subr -f_include $BSDCFG_SHARE/media/common.subr -f_include $BSDCFG_SHARE/struct.subr -f_include $BSDCFG_SHARE/variable.subr - -BSDCFG_LIBE="/usr/libexec/bsdconfig" -f_include_lang $BSDCFG_LIBE/include/messages.subr - -############################################################ GLOBALS - -FLOPPY_MOUNTED= -FLOPPY_DISTWANTED= - -############################################################ FUNCTIONS - -# f_media_set_floppy -# -# Return success if we both found and set the media type to be a floppy. -# -f_media_set_floppy() -{ - f_media_close - - local devs ndevs - f_device_find "" $DEVICE_TYPE_FLOPPY devs - f_count ndevs $devs - - if [ ${ndevs:=0} -eq 0 ]; then - f_interactive && f_show_msg "$msg_no_floppy_devices_found" - return $FAILURE - elif [ $ndevs -eq 1 ]; then - f_struct_copy $devs device_media - else - local dev - local title="$msg_choose_a_floppy_drive" - local prompt="$msg_please_select_a_floppy_drive" - local hline= - - dev=$( f_device_menu \ - "$title" "$prompt" "$hline" $DEVICE_TYPE_FLOPPY \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) || - return $FAILURE - - f_struct_copy "$dev" device_media - fi - - f_struct device_media && - device_media unset private - - f_struct device_media || return $FAILURE -} - -# f_media_init_floppy $device -# -# Initializes the Floppy media device. Returns success if able to mount the -# Floppy disk device using either mount_msdosfs(8) or mount(8) (tried in that -# order). -# -f_media_init_floppy() -{ - local funcname=f_media_init_floppy - local dev="$1" devname err - - $dev get devname devname || return $FAILURE - f_dprintf "Init floppy called for %s distribution. devname=[%s]" \ - "${FLOPPY_DISTWANTED:-some}" "$devname" - - if [ "$FLOPPY_MOUNTED" ]; then - f_dprintf "Floppy device already mounted." - return $SUCCESS - fi - - local mp - $dev get private mp - if [ ! -e "${mp:=$MOUNTPOINT}" ] && ! f_quietly mkdir -p "$mp"; then - f_show_msg "$msg_unable_to_make_directory_mountpoint" \ - "$mp" "$devname" - return $FAILURE - fi - - if f_interactive; then - local desc - $dev get desc desc - if [ "$FLOPPY_DISTWANTED" ]; then - f_show_msg "$msg_please_insert_floppy_in_drive" "$desc" - else - f_show_msg "$msg_please_insert_floppy_containing" \ - "$FLOPPY_DISTWANTED" "$desc" - fi - fi - - if ! { - f_eval_catch -dk err $funcname mount_msdosfs \ - 'mount_msdosfs -o ro -m 0777 -u 0 -g 0 "%s" "%s"' \ - "$devname" "$mp" || - f_eval_catch -dk err $funcname mount \ - 'mount -o ro "%s" "%s"' "$devname" "$mp" - }; then - err="${err#mount: }"; err="${err#*: }" - local name - $dev get name name - f_show_msg "$msg_error_mounting_floppy_device" \ - "$name" "$devname" "$mp" "$err" - return $FAILURE - fi - FLOPPY_MOUNTED=1 - FLOPPY_DISTWANTED= - return $SUCCESS -} - -# f_media_get_floppy $device $file [$probe_type] -# -# Returns data from $file on a mounted Floppy disk device. Similar to cat(1). -# If $probe_type is present and non-NULL, limits retries to zero and returns -# success if $file exists. If $probe_type is equal to $PROBE_SIZE, prints the -# size of $file in bytes to standard-out. -# -f_media_get_floppy() -{ - local funcname=f_media_get_floppy - local dev="$1" file="$2" probe_type="$3" - local name - - $dev get name name - f_dprintf "f_media_get_floppy: dev=[%s] file=[%s] probe_type=%s" \ - "$name" "$file" "$probe_type" - - # - # floppies don't use f_media_generic_get() because it's too expensive - # to speculatively open files on a floppy disk. Make user get it - # right or give up with floppies. - # - local mp - $dev get private mp - local fp="${mp:=$MOUNTPOINT}/$file" - if ! [ -f "$fp" -a -r "$fp" ]; then - local nretries=4 - [ "$probe_type" = "$PROBE_SIZE" ] && echo "-1" - [ "$probe_type" ] && return $FAILURE - while ! [ -f "$fp" -a -r "$fp" ]; do - if [ $nretries -eq 0 ]; then - f_show_msg "$msg_failed_to_get_floppy_file" \ - "$fp" - [ "$probe_type" = "$PROBE_SIZE" ] && echo "-1" - return $FAILURE - fi - FLOPPY_DISTWANTED="$fp" - f_media_shutdown_floppy "$dev" - f_media_init_floppy "$dev" || return $FAILURE - nretries=$(( $nretries - 1 )) - done - fi - # - # If we reach here, $file exists - # - if [ "$probe_type" = "$PROBE_SIZE" ]; then - local size - f_eval_catch -dk size $funcname stat 'stat -f %%z "%s"' "$fp" - f_isinteger "$size" || size=-1 - echo "$size" - fi - [ "$probe_type" ] && return $SUCCESS - cat "$fp" -} - -# f_media_shutdown_floppy $device -# -# Shuts down the Floppy disk device using umount(8). Return status should be -# ignored. -# -f_media_shutdown_floppy() -{ - local funcname=f_media_shutdown_floppy - local dev="$1" err mp - - [ "$FLOPPY_MOUNTED" ] || return $FAILURE - - $dev get private mp - if f_eval_catch -d $funcname umount \ - 'umount -f "%s"' "${mp:=$MOUNTPOINT}" - then - FLOPPY_MOUNTED= - if f_interactive && [ "$_systemState" != "fixit" ]; then - local desc - $dev get desc desc - f_show_msg "$msg_you_may_remove_the_floppy" "$desc" - fi - fi -} - -############################################################ MAIN - -f_dprintf "%s: Successfully loaded." media/floppy.subr - -fi # ! $_MEDIA_FLOPPY_SUBR diff --git a/usr.sbin/bsdconfig/share/media/options.subr b/usr.sbin/bsdconfig/share/media/options.subr index 340619a50ac1..a4de6395127e 100644 --- a/usr.sbin/bsdconfig/share/media/options.subr +++ b/usr.sbin/bsdconfig/share/media/options.subr @@ -1,326 +1,325 @@ if [ ! "$_MEDIA_OPTIONS_SUBR" ]; then _MEDIA_OPTIONS_SUBR=1 # # Copyright (c) 2012-2013 Devin Teske # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # ############################################################ INCLUDES BSDCFG_SHARE="/usr/share/bsdconfig" . $BSDCFG_SHARE/common.subr || exit 1 f_dprintf "%s: loading includes..." media/options.subr f_include $BSDCFG_SHARE/dialog.subr f_include $BSDCFG_SHARE/media/any.subr f_include $BSDCFG_SHARE/media/ftp.subr f_include $BSDCFG_SHARE/struct.subr f_include $BSDCFG_SHARE/variable.subr BSDCFG_LIBE="/usr/libexec/bsdconfig" f_include_lang $BSDCFG_LIBE/include/messages.subr OPTIONS_HELPFILE=$BSDCFG_LIBE/include/options.hlp ############################################################ FUNCTIONS # f_media_options_menu # # Prompt the user to confirm/edit various media settings. Returns success. # f_media_options_menu() { f_dialog_title "$msg_options_editor" local title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE" f_dialog_title_restore local prompt= local menu_list # Calculated below local defaultitem= local hline="$hline_arrows_tab_enter" # # A hack so that the dialogs below are always interactive in a script # local old_interactive= if ! f_interactive; then f_getvar $VAR_NONINTERACTIVE old_interactive unset $VAR_NONINTERACTIVE fi local cp while :; do menu_list= f_getvar $VAR_NFS_SECURE cp if [ "$cp" = "YES" ]; then menu_list="$menu_list ' $msg_nfs_secure' 'YES' '$msg_nfs_server_talks_only_on_a_secure_port'" else menu_list="$menu_list ' $msg_nfs_secure' 'NO' '$msg_nfs_server_talks_only_on_a_secure_port'" fi f_getvar $VAR_SLOW_ETHER cp if [ "$cp" = "YES" ]; then menu_list="$menu_list ' $msg_nfs_slow' 'YES' '$msg_user_is_using_a_slow_pc_or_ethernet_card'" else menu_list="$menu_list ' $msg_nfs_slow' 'NO' '$msg_user_is_using_a_slow_pc_or_ethernet_card'" fi f_getvar $VAR_NFS_TCP cp if [ "$cp" = "YES" ]; then menu_list="$menu_list ' $msg_nfs_tcp' 'YES' '$msg_use_tcp_protocol_for_nfs'" else menu_list="$menu_list ' $msg_nfs_tcp' 'NO' '$msg_use_tcp_protocol_for_nfs'" fi f_getvar $VAR_NFS_V3 cp if [ "$cp" = "YES" ]; then menu_list="$menu_list ' $msg_nfs_version_3' 'YES' '$msg_use_nfs_version_3'" else menu_list="$menu_list ' $msg_nfs_version_3' 'NO' '$msg_use_nfs_version_3'" fi f_getvar $VAR_DEBUG cp if [ "$cp" ]; then menu_list="$menu_list ' $msg_debugging' 'YES' '$msg_emit_extra_debugging_output'" else menu_list="$menu_list ' $msg_debugging' 'NO' '$msg_emit_extra_debugging_output'" fi f_getvar $VAR_NO_CONFIRM cp if [ "$cp" ]; then menu_list="$menu_list ' $msg_yes_to_all' 'YES' '$msg_assume_yes_to_all_non_critical_dialogs'" else menu_list="$menu_list ' $msg_yes_to_all' 'NO' '$msg_assume_yes_to_all_non_critical_dialogs'" fi f_getvar $VAR_TRY_DHCP cp if [ "$cp" = "YES" ]; then menu_list="$menu_list ' $msg_dhcp' 'YES' '$msg_attempt_automatic_dhcp_configuration'" else menu_list="$menu_list ' $msg_dhcp' 'NO' '$msg_attempt_automatic_dhcp_configuration'" fi f_getvar $VAR_TRY_RTSOL cp if [ "$cp" = "YES" ]; then menu_list="$menu_list ' $msg_ipv6' 'YES' '$msg_attempt_ipv6_configuration_of_interfaces'" else menu_list="$menu_list ' $msg_ipv6' 'NO' '$msg_attempt_ipv6_configuration_of_interfaces'" fi f_getvar $VAR_FTP_USER cp menu_list="$menu_list ' $msg_ftp_username' '$cp' '$msg_username_and_password_to_use'" f_getvar $VAR_EDITOR cp menu_list="$menu_list ' $msg_editor' '$cp' '$msg_which_text_editor_to_use'" f_getvar $VAR_RELNAME cp menu_list="$menu_list ' $msg_release_name' '$cp' '$msg_which_release_to_attempt_to_load'" if f_struct device_media; then device_media get type cp case "$cp" in $DEVICE_TYPE_UFS|$DEVICE_TYPE_DISK) cp="$msg_file_system" ;; $DEVICE_TYPE_DIRECTORY) cp="$msg_directory" ;; - $DEVICE_TYPE_FLOPPY) cp="$msg_floppy" ;; $DEVICE_TYPE_FTP) cp="$msg_ftp" ;; $DEVICE_TYPE_HTTP_PROXY) cp="$msg_http_proxy" ;; $DEVICE_TYPE_HTTP) cp="$msg_http_direct" ;; $DEVICE_TYPE_CDROM) cp="$msg_cdrom" ;; $DEVICE_TYPE_USB) cp="$msg_usb" ;; $DEVICE_TYPE_DOS) cp="$msg_dos" ;; $DEVICE_TYPE_NFS) cp="$msg_nfs" ;; *) cp="<$msg_unknown>" esac else cp="<$msg_not_yet_set>" fi menu_list="$menu_list ' $msg_media_type' '$cp' '$msg_the_current_installation_media_type'" f_getvar $VAR_MEDIA_TIMEOUT cp menu_list="$menu_list ' $msg_media_timeout' '$cp' '$msg_timeout_value_in_seconds_for_slow_media'" f_getvar $VAR_PKG_TMPDIR cp menu_list="$menu_list ' $msg_package_temp' '$cp' '$msg_directory_where_package_temporary_files_go'" menu_list="$menu_list ' $msg_rescan_devices' '<*>' '$msg_rerun_bsdconfig_initial_device_probe' ' $msg_use_defaults' '[${msg_reset}]' '$msg_reset_all_values_to_startup_defaults' " # END-QUOTE local height width rows eval f_dialog_menu_with_help_size height width rows \ \"\$title\" \ \"\$btitle\" \ \"\$prompt\" \ \"\$hline\" \ $menu_list local mtag mtag=$( eval $DIALOG \ --title \"\$title\" \ --backtitle \"\$btitle\" \ --hline \"\$hline\" \ --item-help \ --ok-label \"\$msg_ok\" \ --cancel-label \"\$msg_done\" \ --help-button \ --help-label \"\$msg_help\" \ --default-item \"\$defaultitem\" \ ${USE_XDIALOG:+--help \"\"} \ --menu \"\$prompt\" \ $height $width $rows \ $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) local retval=$? f_dialog_data_sanitize mtag defaultitem="$mtag" f_dprintf "retval=%s mtag=[%s]" $retval "$mtag" if [ $retval -eq $DIALOG_HELP ]; then f_show_help "$OPTIONS_HELPFILE" continue elif [ $retval -ne $DIALOG_OK ]; then break # to success fi case "$mtag" in " $msg_nfs_secure") f_getvar $VAR_NFS_SECURE cp if [ "$cp" = "YES" ]; then export $VAR_NFS_SECURE="NO" else export $VAR_NFS_SECURE="YES" fi ;; " $msg_nfs_slow") f_getvar $VAR_SLOW_ETHER cp if [ "$cp" = "YES" ]; then export $VAR_SLOW_ETHER="NO" else export $VAR_SLOW_ETHER="YES" fi ;; " $msg_nfs_tcp") f_getvar $VAR_NFS_TCP cp if [ "$cp" = "YES" ]; then export $VAR_NFS_TCP="NO" else export $VAR_NFS_TCP="YES" fi ;; " $msg_nfs_version_3") f_getvar $VAR_NFS_V3 cp if [ "$cp" = "YES" ]; then export $VAR_NFS_V3="NO" else export $VAR_NFS_V3="YES" fi ;; " $msg_debugging") if f_getvar $VAR_DEBUG cp && [ "$cp" ]; then unset $VAR_DEBUG else export $VAR_DEBUG=1 fi ;; " $msg_yes_to_all") if f_getvar $VAR_NO_CONFIRM cp && [ "$cp" ]; then unset $VAR_NO_CONFIRM else export $VAR_NO_CONFIRM=1 fi ;; " $msg_dhcp") f_getvar $VAR_TRY_DHCP cp if [ "$cp" = "YES" ]; then export $VAR_TRY_DHCP="NO" else export $VAR_TRY_DHCP="YES" fi ;; " $msg_ipv6") f_getvar $VAR_TRY_RTSOL cp if [ "$cp" = "YES" ]; then export $VAR_TRY_RTSOL="NO" else export $VAR_TRY_RTSOL="YES" fi ;; " $msg_ftp_username") f_media_set_ftp_userpass ;; " $msg_editor") f_variable_get_value $VAR_EDITOR \ "$msg_please_specify_the_name_of_the_text_editor" ;; " $msg_release_name") f_variable_get_value $VAR_RELNAME \ "$msg_please_specify_the_release_you_wish_to_load" ;; " $msg_media_type") f_media_get_type ;; " $msg_media_timeout") f_variable_get_value $VAR_MEDIA_TIMEOUT \ "$msg_please_specify_the_number_of_seconds_to_wait" ;; " $msg_package_temp") f_variable_get_value $VAR_PKG_TMPDIR \ "$msg_please_specify_a_temporary_directory" ;; " $msg_rescan_devices") f_device_rescan ;; " $msg_use_defaults") f_variable_set_defaults ;; esac done # Restore old VAR_NONINTERACTIVE if needed. [ "$old_interactive" ] && setvar $VAR_NONINTERACTIVE "$old_interactive" return $SUCCESS } ############################################################ MAIN f_dprintf "%s: Successfully loaded." media/options.subr fi # ! $_MEDIA_OPTIONS_SUBR diff --git a/usr.sbin/bsdconfig/share/packages/index.subr b/usr.sbin/bsdconfig/share/packages/index.subr index dd432adf6adf..bd29b882d0d9 100644 --- a/usr.sbin/bsdconfig/share/packages/index.subr +++ b/usr.sbin/bsdconfig/share/packages/index.subr @@ -1,415 +1,413 @@ if [ ! "$_PACKAGES_INDEX_SUBR" ]; then _PACKAGES_INDEX_SUBR=1 # # Copyright (c) 2013-2016 Devin Teske # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # ############################################################ INCLUDES BSDCFG_SHARE="/usr/share/bsdconfig" . $BSDCFG_SHARE/common.subr || exit 1 f_dprintf "%s: loading includes..." packages/index.subr f_include $BSDCFG_SHARE/device.subr f_include $BSDCFG_SHARE/media/common.subr f_include $BSDCFG_SHARE/packages/musthavepkg.subr f_include $BSDCFG_SHARE/strings.subr BSDCFG_LIBE="/usr/libexec/bsdconfig" f_include_lang $BSDCFG_LIBE/include/messages.subr ############################################################ GLOBALS PACKAGE_INDEX= _INDEX_INITTED= # # Default path to pkg(8) repo-packagesite.sqlite database # SQLITE_REPO="/var/db/pkg/repo-FreeBSD.sqlite" # # Default path to on-disk cache INDEX file # PACKAGES_INDEX_CACHEFILE="/var/run/bsdconfig/packages_INDEX.cache" ############################################################ FUNCTIONS # f_index_initialize [$var_to_set] # # Read and initialize the global index. Returns success unless media cannot be # initialized for any reason (e.g. user cancels media selection dialog or an # error occurs). The index is sorted before being loaded into $var_to_set. # # NOTE: The index is processed with f_index_read() [below] after being loaded. # f_index_initialize() { local __funcname=f_index_initialize local __var_to_set="${1:-PACKAGE_INDEX}" [ "$_INDEX_INITTED" ] && return $SUCCESS # Got any media? f_media_verify || return $FAILURE # Make sure we have a usable pkg(8) with $PKG_ABI f_musthavepkg_init # Does it move when you kick it? f_device_init device_media || return $FAILURE f_show_info "$msg_attempting_to_update_repository_catalogue" # # Generate $PACKAGESITE variable for pkg(8) based on media type # local __type __data __site device_media get type __type device_media get private __data case "$__type" in $DEVICE_TYPE_DIRECTORY) __site="file://$__data/packages/$PKG_ABI" ;; - $DEVICE_TYPE_FLOPPY) - __site="file://${__data:-$MOUNTPOINT}/packages/$PKG_ABI" ;; $DEVICE_TYPE_FTP) f_getvar $VAR_FTP_PATH __site __site="$__site/packages/$PKG_ABI" ;; $DEVICE_TYPE_HTTP) f_getvar $VAR_HTTP_PATH __site __site="$__site/$PKG_ABI/latest" ;; $DEVICE_TYPE_HTTP_PROXY) f_getvar $VAR_HTTP_PROXY_PATH __site __site="$__site/packages/$PKG_ABI" ;; $DEVICE_TYPE_CDROM) __site="file://$MOUNTPOINT/packages/$PKG_ABI" export REPOS_DIR="$MOUNTPOINT/packages/repos" ;; *) # UFS, DISK, CDROM, USB, DOS, NFS, etc. __site="file://$MOUNTPOINT/packages/$PKG_ABI" esac f_dprintf "PACKAGESITE=[%s]" "$__site" if ! f_eval_catch $__funcname pkg \ 'PACKAGESITE="%s" pkg update' "$__site" then f_show_err "$msg_unable_to_update_pkg_from_selected_media" f_device_shutdown device_media return $FAILURE fi # # Try to get contents from validated on-disk cache # # # Calculate digest used to determine if the on-disk persistent cache # INDEX (containing this digest on the first line) is valid and can be # used to quickly populate the environment. # local __sqlite_digest if ! __sqlite_digest=$( md5 < "$SQLITE_REPO" 2> /dev/null ); then f_show_err "$msg_no_pkg_database_found" f_device_shutdown device_media return $FAILURE fi # # Check to see if the persistent cache INDEX file exists # if [ -f "$PACKAGES_INDEX_CACHEFILE" ]; then # # Attempt to populate the environment with the (soon to be) # validated on-disk cache. If validation fails, fall-back to # generating a fresh cache. # if eval $__var_to_set='$( ( # Get digest as the first word on first line read digest rest_ignored # # If the stored digest matches the calculated- # one populate the environment from the on-disk # cache and provide success exit status. # if [ "$digest" = "$__sqlite_digest" ]; then cat exit $SUCCESS else # Otherwise, return the current value eval echo \"\$__var_to_set\" exit $FAILURE fi ) < "$PACKAGES_INDEX_CACHEFILE" 2> /dev/null )'; then if ! f_index_read "$__var_to_set"; then f_show_err \ "$msg_io_or_format_error_on_index_file" return $FAILURE fi _INDEX_INITTED=1 return $SUCCESS fi # Otherwise, fall-thru to create a fresh cache from scratch fi # # If we reach this point, we need to generate the data from scratch # eval "$__var_to_set"='$( pkg rquery -I | ( exec 2<&1; dpv -ko /dev/stderr >&$TERMINAL_STDOUT_PASSTHRU \ -b "$DIALOG_BACKTITLE" \ -- "$msg_generating_index_from_pkg_database" ) | sort )' # # Attempt to create the persistent on-disk cache # # Create a new temporary file to write to local __tmpfile if f_eval_catch -dk __tmpfile $__funcname mktemp \ 'mktemp -t "%s"' "$pgm" then # Write the temporary file contents echo "$__sqlite_digest" > "$__tmpfile" debug= f_getvar "$__var_to_set" >> "$__tmpfile" # Finally, move the temporary file into place case "$PACKAGES_INDEX_CACHEFILE" in */*) f_eval_catch -d $__funcname mkdir \ 'mkdir -p "%s"' "${PACKAGES_INDEX_CACHEFILE%/*}" esac f_eval_catch -d $__funcname mv 'mv -f "%s" "%s"' \ "$__tmpfile" "$PACKAGES_INDEX_CACHEFILE" fi if ! f_index_read "$__var_to_set"; then f_show_err "$msg_io_or_format_error_on_index_file" return $FAILURE fi _INDEX_INITTED=1 return $SUCCESS } # f_index_read [$var_to_get] # # Process the INDEX file (contents contained in $var_to_get) and... # # 1. create a list ($CATEGORY_MENU_LIST) of categories with package counts # 2. For convenience, create $_npkgs holding the total number of all packages # 3. extract associative categories for each package into $_categories_$varpkg # 4. extract runtime dependencies for each package into $_rundeps_$varpkg # 5. extract a [sorted] list of categories into $PACKAGE_CATEGORIES # 6. create $_npkgs_$varcat holding the total number of packages in category # # NOTE: $varpkg is the product of f_str2varname $package varpkg # NOTE: $package is the name as it appears in the INDEX (no archive suffix) # NOTE: We only show categories for which there are at least one package. # NOTE: $varcat is the product of f_str2varname $category varcat # f_index_read() { local var_to_get="${1:-PACKAGE_INDEX}" # Export variables required by awk(1) below export msg_no_description_provided export msg_all msg_all_desc export VALID_VARNAME_CHARS export msg_packages eval "$( debug= f_getvar "$var_to_get" | awk -F'|' ' function _asorti(src, dest) { k = nitems = 0 # Copy src indices to dest and calculate array length for (i in src) dest[++nitems] = i # Sort the array of indices (dest) using insertion sort method for (i = 1; i <= nitems; k = i++) { idx = dest[i] while ((k > 0) && (dest[k] > idx)) { dest[k+1] = dest[k] k-- } dest[k+1] = idx } return nitems } function print_category(category, npkgs, desc) { cat = category # Accent the category if the first page has been # cached (also acting as a visitation indicator) if ( ENVIRON["_index_page_" varcat "_1"] ) cat = cat "*" printf "'\''%s'\'' '\''%s " packages "'\'' '\''%s'\''\n", cat, npkgs, desc } BEGIN { valid_chars = ENVIRON["VALID_VARNAME_CHARS"] default_desc = ENVIRON["msg_no_description_provided"] packages = ENVIRON["msg_packages"] tpkgs = 0 prefix = "" } { tpkgs++ varpkg = $1 gsub("[^" valid_chars "]", "_", varpkg) print "_categories_" varpkg "=\"" $7 "\"" split($7, pkg_categories, /[[:space:]]+/) for (pkg_category in pkg_categories) categories[pkg_categories[pkg_category]]++ print "_rundeps_" varpkg "=\"" $9 "\"" } END { print "_npkgs=" tpkgs # For convenience, total package count n = _asorti(categories, categories_sorted) # Produce package counts for each category for (i = 1; i <= n; i++) { cat = varcat = categories_sorted[i] npkgs = categories[cat] gsub("[^" valid_chars "]", "_", varcat) print "_npkgs_" varcat "=\"" npkgs "\"" } # Create menu list and generate list of categories at same time print "CATEGORY_MENU_LIST=\"" print_category(ENVIRON["msg_all"], tpkgs, ENVIRON["msg_all_desc"]) category_list = "" for (i = 1; i <= n; i++) { cat = varcat = categories_sorted[i] npkgs = categories[cat] cur_prefix = tolower(substr(cat, 1, 1)) if ( prefix != cur_prefix ) prefix = cur_prefix else cat = " " cat gsub("[^" valid_chars "]", "_", varcat) desc = ENVIRON["_category_" varcat] if ( ! desc ) desc = default_desc print_category(cat, npkgs, desc) category_list = category_list " " cat } print "\"" # Produce the list of categories (calculated in above block) sub(/^ /, "", category_list) print "PACKAGE_CATEGORIES=\"" category_list "\"" }' | ( exec 2<&1; dpv -ko /dev/stderr >&$TERMINAL_STDOUT_PASSTHRU \ -b "$DIALOG_BACKTITLE" -- "$msg_reading_package_index_data" ) )" # End-Quote } # f_index_extract_pages $var_to_get $var_basename $pagesize [$category] # # Extracts the package INDEX ($PACKAGE_INDEX by default if/when $var_to_get is # NULL; but should not be missing) into a series of sequential variables # corresponding to "pages" containing up to $pagesize packages. The package # INDEX data must be contained in the variable $var_to_get. The extracted pages # are stored in variables ${var_basename}_# -- where "#" is a the page number. # If $category is set, only packages for that category are extracted. # Otherwise, if $category is "All", missing, or NULL, all packages are # extracted and no filtering is done. # f_index_extract_pages() { local var_to_get="${1:-PACKAGE_INDEX}" var_basename="$2" pagesize="$3" local category="$4" # Optional eval "$( debug= f_getvar "$var_to_get" | awk -F'|' \ -v cat="$category" \ -v pagesize="$pagesize" \ -v var_basename="$var_basename" \ -v i18n_all="$msg_all" ' BEGIN { n = page = 0 } /'\''/{ gsub(/'\''/, "'\''\\'\'\''") } { if ( cat !~ "(^$|^" i18n_all "$)" && $7 !~ \ "(^|[[:space:]])" cat "([[:space:]]|$)" ) next starting_new_page = (n++ == (pagesize * page)) if ( starting_new_page ) printf "%s%s", ( n > 1 ? "'\''\n" : "" ), var_basename "_" ++page "='\''" printf "%s%s", ( starting_new_page ? "" : "\n" ), $0 } END { if ( n > 0 ) print "'\''" }' )" } # f_index_search $var_to_get $name [$var_to_set] # # Search the package INDEX ($PACKAGE_INDEX by default if/when $var_to_get is # NULL; but should not be missing) for $name, returning the first match. # Matches are strict (not regular expressions) and must match the beginning # portion of the package name to be considered a match. If $var_to_set is # missing or NULL, output is sent to standard output. If a match is found, # returns success; otherwise failure. # f_index_search() { local __var_to_get="${1:-PACKAGE_INDEX}" __pkg_basename="$2" local __var_to_set="$3" f_dprintf "f_index_search: Searching package data (in %s) for %s" \ "$__var_to_get" "$__pkg_basename" local __pkg= __pkg=$( debug= f_getvar "$__var_to_get" | awk -F'|' -v basename="$__pkg_basename" ' BEGIN { n = length(basename) } substr($1, 0, n) == basename { print $1; exit } ' ) if [ ! "$__pkg" ]; then f_dprintf "f_index_search: No packages matching %s found" \ "$__pkg_basename" return $FAILURE fi f_dprintf "f_index_search: Found package %s" "$__pkg" if [ "$__var_to_set" ]; then setvar "$__var_to_set" "$__pkg" else echo "$__pkg" fi return $SUCCESS } ############################################################ MAIN f_dprintf "%s: Successfully loaded." packages/index.subr fi # ! $_PACKAGES_INDEX_SUBR diff --git a/usr.sbin/bsdconfig/share/script.subr b/usr.sbin/bsdconfig/share/script.subr index feac3b47bdef..055202f1bd93 100644 --- a/usr.sbin/bsdconfig/share/script.subr +++ b/usr.sbin/bsdconfig/share/script.subr @@ -1,218 +1,217 @@ if [ ! "$_SCRIPT_SUBR" ]; then _SCRIPT_SUBR=1 # # Copyright (c) 2012-2014 Devin Teske # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # ############################################################ INCLUDES BSDCFG_SHARE="/usr/share/bsdconfig" . $BSDCFG_SHARE/common.subr || exit 1 f_dprintf "%s: loading includes..." script.subr f_include $BSDCFG_SHARE/device.subr f_include $BSDCFG_SHARE/media/any.subr f_include $BSDCFG_SHARE/media/tcpip.subr f_include $BSDCFG_SHARE/mustberoot.subr f_include $BSDCFG_SHARE/networking/services.subr f_include $BSDCFG_SHARE/packages/packages.subr f_include $BSDCFG_SHARE/usermgmt/group.subr f_include $BSDCFG_SHARE/usermgmt/user.subr f_include $BSDCFG_SHARE/variable.subr ############################################################ GLOBALS RESWORDS= ############################################################ FUNCTIONS # f_resword_new $resword $function # # Create a new `reserved' word for scripting purposes. Reswords call pre- # defined functions but differ from those functions in the following ways: # # + Unless noError is set (must be non-NULL), if calling the resword # results in failure, the application will terminate prematurely. # + noError is unset after each/every resword is called. # # Reswords should not be used in bsdconfig itself (hence the name `reserved # word') but instead only in scripts loaded through f_script_load(). # f_resword_new() { local resword="$1" func="$2" [ "$resword" ] || return $FAILURE f_dprintf "script.subr: New resWord %s -> %s" "$resword" "$func" eval $resword\(\){ f_dispatch $func $resword \"\$@\"\; } RESWORDS="$RESWORDS${RESWORDS:+ }$resword" } # f_dispatch $func $resword # # Wrapper function used by `reserved words' (reswords) to call other functions. # If $noError is set and non-NULL, a failure result from $func is ignored, # otherwise the application is prematurely terminated using f_die(). # # NOTE: $noError is unset after every call. # f_dispatch() { local func="$1" resword="$2" shift 2 # func resword f_dprintf "f_dispatch: calling resword \`%s'" "$resword" eval $func "$@" local retval=$? if [ $retval -ne $SUCCESS ]; then local _ignore_this_error f_getvar $VAR_NO_ERROR _ignore_this_error [ "$_ignore_this_error" ] || f_die $retval \ "$msg_command_failed_rest_of_script_aborted" "$resword" fi unset $VAR_NO_ERROR } # f_script_load [$file] # # Load a script (usually filled with reswords). If $file is missing or NULL, # use one of the following instead (in order): # # $configFile (global) # install.cfg # /stand/install.fg # /tmp/install.cfg # # Unknown/unregistered reswords will generate sh(1) syntax errors but not cause # premature termination. # # Returns success if a script was loaded and itself returned success. # f_script_load() { local funcname=f_script_load local script="$1" config_file retval=$SUCCESS f_dprintf "$funcname: script=[%s]" "$script" if [ ! "$script" ]; then f_getvar $VAR_CONFIG_FILE config_file for script in \ $config_file \ install.cfg \ /stand/install.cfg \ /tmp/install.cfg \ ; do [ -e "$script" ] && break done fi local old_interactive= f_getvar $VAR_NONINTERACTIVE old_interactive # save a copy # Hint to others that we're running from a script, should they care setvar $VAR_NONINTERACTIVE yes if [ "$script" = "-" ]; then f_dprintf "$funcname: Loading script from stdin" eval "$( cat )" retval=$? else f_dprintf "$funcname: Loading script \`%s'" "$script" if [ ! -e "$script" ]; then f_show_msg "$msg_unable_to_open" "$script" return $FAILURE fi . "$script" retval=$? fi [ "$old_interactive" ] && setvar $VAR_NONINTERACTIVE "$old_interactive" return $retval } ############################################################ MAIN # # Reserved words meant for scripting # # this file f_resword_new loadConfig f_script_load # device.subr f_resword_new deviceRescan f_device_rescan # media/common.subr f_resword_new mediaOpen f_media_open f_resword_new mediaClose f_media_close # media includes f_resword_new mediaGetType f_media_get_type # media/any.subr f_resword_new mediaSetCDROM f_media_set_cdrom # media/cdrom.subr f_resword_new mediaSetDOS f_media_set_dos # media/dos.subr f_resword_new mediaSetDirectory f_media_set_directory # media/directory.subr -f_resword_new mediaSetFloppy f_media_set_floppy # media/floppy.subr f_resword_new mediaSetNFS f_media_set_nfs # media/nfs.subr f_resword_new mediaSetUFS f_media_set_ufs # media/ufs.subr f_resword_new mediaSetUSB f_media_set_usb # media/usb.subr f_resword_new optionsEditor f_media_options_menu # media/options.subr f_resword_new tcpMenuSelect f_dialog_menu_select_tcp # media/tcp.subr # media/ftp.subr f_resword_new mediaSetFTP f_media_set_ftp f_resword_new mediaSetFTPActive f_media_set_ftp_active f_resword_new mediaSetFTPPassive f_media_set_ftp_passive f_resword_new mediaSetFTPUserPass f_media_set_ftp_userpass # media/http.subr f_resword_new mediaSetHTTP f_media_set_http # media/httpproxy.subr f_resword_new mediaSetHTTPProxy f_media_set_http_proxy # networking/services.subr f_resword_new configPCNFSD f_config_pcnfsd # packages/packages.subr f_resword_new configPackages f_package_config f_resword_new packageAdd f_package_add f_resword_new packageDelete f_package_delete f_resword_new packageReinstall f_package_reinstall # usermgmt/group.subr f_resword_new addGroup f_group_add f_resword_new deleteGroup f_group_delete f_resword_new editGroup f_group_edit # usermgmt/user.subr f_resword_new addUser f_user_add f_resword_new deleteUser f_user_delete f_resword_new editUser f_user_edit # variable.subr f_resword_new installVarDefaults f_variable_set_defaults f_resword_new dumpVariables f_dump_variables f_dprintf "%s: Successfully loaded." script.subr fi # ! $_SCRIPT_SUBR