diff options
Diffstat (limited to 'usr.sbin/bsdconfig/networking')
-rwxr-xr-x | usr.sbin/bsdconfig/networking/devices | 4 | ||||
-rwxr-xr-x | usr.sbin/bsdconfig/networking/hostname | 3 | ||||
-rwxr-xr-x | usr.sbin/bsdconfig/networking/networking | 14 | ||||
-rw-r--r-- | usr.sbin/bsdconfig/networking/share/device.subr | 26 | ||||
-rw-r--r-- | usr.sbin/bsdconfig/networking/share/media.subr | 4 | ||||
-rw-r--r-- | usr.sbin/bsdconfig/networking/share/resolv.subr | 12 |
6 files changed, 47 insertions, 16 deletions
diff --git a/usr.sbin/bsdconfig/networking/devices b/usr.sbin/bsdconfig/networking/devices index dd1fb37..7304a78 100755 --- a/usr.sbin/bsdconfig/networking/devices +++ b/usr.sbin/bsdconfig/networking/devices @@ -71,10 +71,12 @@ f_mustberoot_init # # Launch application main menu # +defaultitem="" while :; do - f_dialog_menu_netdev + f_dialog_menu_netdev "$defaultitem" retval=$? interface=$( f_dialog_menutag ) + defaultitem="$interface" [ $retval -eq 0 ] || break diff --git a/usr.sbin/bsdconfig/networking/hostname b/usr.sbin/bsdconfig/networking/hostname index ab74ae6..4029d3c 100755 --- a/usr.sbin/bsdconfig/networking/hostname +++ b/usr.sbin/bsdconfig/networking/hostname @@ -28,6 +28,9 @@ # ############################################################ INCLUDES +# Prevent device.subr (included indirectly) from auto scanning on load +DEVICE_SELF_SCAN_ALL=NO + BSDCFG_SHARE="/usr/share/bsdconfig" . $BSDCFG_SHARE/common.subr || exit 1 f_dprintf "%s: loading includes..." "$0" diff --git a/usr.sbin/bsdconfig/networking/networking b/usr.sbin/bsdconfig/networking/networking index d3c8a8d..3697f31 100755 --- a/usr.sbin/bsdconfig/networking/networking +++ b/usr.sbin/bsdconfig/networking/networking @@ -68,15 +68,17 @@ dialog_menu_main() local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --menu \"\" $size $menu_list \ + --title \"\$DIALOG_TITLE\" \ + --backtitle \"\$DIALOG_BACKTITLE\" \ + --hline \"\$hline\" \ + --ok-label \"\$msg_ok\" \ + --cancel-label \"\$msg_cancel\" \ + --default-item \"\$DEFAULTITEM_$$\" \ + --menu \"\" $size $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) local retval=$? + setvar DEFAULTITEM_$$ "$dialog_menu" setvar DIALOG_MENU_$$ "$dialog_menu" return $retval } diff --git a/usr.sbin/bsdconfig/networking/share/device.subr b/usr.sbin/bsdconfig/networking/share/device.subr index cac8ef5..b47bfc9 100644 --- a/usr.sbin/bsdconfig/networking/share/device.subr +++ b/usr.sbin/bsdconfig/networking/share/device.subr @@ -55,12 +55,15 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr ############################################################ FUNCTIONS -# f_dialog_menu_netdev +# f_dialog_menu_netdev [$default] # -# Display a list of network devices with descriptions. +# Display a list of network devices with descriptions. Optionally, if present +# and non-NULL, initially highlight $default interface. # f_dialog_menu_netdev() { + local defaultitem="${1%\*}" # Tim trailing asterisk if present + # # Display a message to let the user know we're working... # (message will remain until we throw up the next dialog) @@ -125,6 +128,15 @@ f_dialog_menu_netdev() return $FAILURE fi + # + # Maybe the default item was marked as active + # + if [ "$defaultitem" ]; then + ifconfig "$defaultitem" 2> /dev/null | awk \ + '( $1 == "status:" && $2 != "active" ) { exit 0 }' || + defaultitem="$defaultitem*" + fi + local hline="$hline_arrows_tab_enter" # @@ -140,11 +152,12 @@ f_dialog_menu_netdev() $interfaces ) local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ --cancel-label \"\$msg_cancel\" \ + --default-item \"\$defaultitem\" \ --menu \"\$prompt\" $size \ $interfaces \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD @@ -188,6 +201,7 @@ f_dialog_menu_netdev_edit() # changes effective because all three options must be specified at-once # to ifconfig(8). # + local defaultitem= while :; do local dhcp_status="$msg_disabled" [ "$dhcp" ] && dhcp_status="$msg_enabled" @@ -210,7 +224,7 @@ f_dialog_menu_netdev_edit() $menu_list ) local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ @@ -218,6 +232,7 @@ f_dialog_menu_netdev_edit() --help-button \ --help-label \"\$msg_help\" \ ${USE_XDIALOG:+--help \"\"} \ + --default-item \"\$defaultitem\" \ --menu \"\$prompt\" $size \ $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD @@ -234,6 +249,9 @@ f_dialog_menu_netdev_edit() elif [ $retval -ne $SUCCESS ]; then # "Cancel" was chosen (-1) or ESC was pressed (255) return $retval + else + # Only update default-item on success + defaultitem="$tag" fi # diff --git a/usr.sbin/bsdconfig/networking/share/media.subr b/usr.sbin/bsdconfig/networking/share/media.subr index eed8364a..e0e71e7 100644 --- a/usr.sbin/bsdconfig/networking/share/media.subr +++ b/usr.sbin/bsdconfig/networking/share/media.subr @@ -1,6 +1,6 @@ if [ ! "$_NETWORKING_MEDIA_SUBR" ]; then _NETWORKING_MEDIA_SUBR=1 # -# Copyright (c) 2006-2012 Devin Teske +# Copyright (c) 2006-2013 Devin Teske # All Rights Reserved. # # Redistribution and use in source and binary forms, with or without @@ -207,7 +207,7 @@ f_dialog_menu_media_options() local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ diff --git a/usr.sbin/bsdconfig/networking/share/resolv.subr b/usr.sbin/bsdconfig/networking/share/resolv.subr index b525a4d..c37e719 100644 --- a/usr.sbin/bsdconfig/networking/share/resolv.subr +++ b/usr.sbin/bsdconfig/networking/share/resolv.subr @@ -396,7 +396,7 @@ f_dialog_menu_nameservers() local opt_exit="$msg_return_to_previous_menu" local opt_add="$msg_add_nameserver" local hline="$hline_arrows_tab_enter" - local prompt size + local prompt size defaultitem= # # Loop forever until the user has finished configuring nameservers @@ -435,11 +435,12 @@ f_dialog_menu_nameservers() $menu_list ) local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ --cancel-label \"\$msg_cancel\" \ + --default-item \"\$defaultitem\" \ --menu \"\$prompt\" $size \ $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD @@ -450,7 +451,12 @@ f_dialog_menu_nameservers() local tag="$( f_dialog_menutag )" ns="" # Return if "Cancel" was chosen (-1) or ESC was pressed (255) - [ $retval -eq $SUCCESS ] || return $retval + if [ $retval -ne $SUCCESS ]; then + return $retval + else + # Only update default-item on success + defaultitem="$tag" + fi case "$tag" in "X $msg_exit") break;; |