summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig
diff options
context:
space:
mode:
authorsjg <sjg@FreeBSD.org>2015-05-27 01:19:58 +0000
committersjg <sjg@FreeBSD.org>2015-05-27 01:19:58 +0000
commit65145fa4c81da358fcbc3b650156dab705dfa34e (patch)
tree55c065b6730aaac2afb6c29933ee6ec5fa4c4249 /usr.sbin/bsdconfig
parent60ff4eb0dff94a04d75d0d52a3957aaaf5f8c693 (diff)
parente6b664c390af88d4a87208bc042ce503da664c3b (diff)
downloadFreeBSD-src-65145fa4c81da358fcbc3b650156dab705dfa34e.zip
FreeBSD-src-65145fa4c81da358fcbc3b650156dab705dfa34e.tar.gz
Merge sync of head
Diffstat (limited to 'usr.sbin/bsdconfig')
-rw-r--r--usr.sbin/bsdconfig/console/INDEX9
-rw-r--r--usr.sbin/bsdconfig/include/messages.subr1
-rw-r--r--usr.sbin/bsdconfig/includes/INDEX3
-rw-r--r--usr.sbin/bsdconfig/networking/share/device.subr4
-rw-r--r--usr.sbin/bsdconfig/share/dialog.subr85
-rw-r--r--usr.sbin/bsdconfig/share/geom.subr2
-rw-r--r--usr.sbin/bsdconfig/share/keymap.subr4
-rw-r--r--usr.sbin/bsdconfig/timezone/share/continents.subr45
-rw-r--r--usr.sbin/bsdconfig/timezone/share/countries.subr43
-rwxr-xr-xusr.sbin/bsdconfig/timezone/timezone42
-rw-r--r--usr.sbin/bsdconfig/usermgmt/share/user.subr5
11 files changed, 190 insertions, 53 deletions
diff --git a/usr.sbin/bsdconfig/console/INDEX b/usr.sbin/bsdconfig/console/INDEX
index 18763fd..e298f34 100644
--- a/usr.sbin/bsdconfig/console/INDEX
+++ b/usr.sbin/bsdconfig/console/INDEX
@@ -1,5 +1,5 @@
# Copyright (c) 2012 Ron McDowell
-# Copyright (c) 2012 Devin Teske
+# Copyright (c) 2012-2015 Devin Teske
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -46,6 +46,13 @@ menu_help="Customize system console behavior"
# can be i18n'ed but `command' is the name of a script.
#
menu_selection="console|console"
+menu_selection="vt_font|font"
+menu_selection="vt_keymap|keymap"
+menu_selection="vt_repeat|repeat"
+menu_selection="vt_saver|saver"
+menu_selection="vt_screenmap|screenmap"
+menu_selection="vt_ttys|ttys"
+# For backward compatibility
menu_selection="syscons_font|font"
menu_selection="syscons_keymap|keymap"
menu_selection="syscons_repeat|repeat"
diff --git a/usr.sbin/bsdconfig/include/messages.subr b/usr.sbin/bsdconfig/include/messages.subr
index 3d6aad0..04f4485 100644
--- a/usr.sbin/bsdconfig/include/messages.subr
+++ b/usr.sbin/bsdconfig/include/messages.subr
@@ -138,7 +138,6 @@ msg_ftp="FTP"
msg_ftp_desc="FTP client and server utilities."
msg_ftp_passive="FTP Passive"
msg_ftp_username="FTP username"
-msg_games_desc="Various games and sundry amusements."
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."
diff --git a/usr.sbin/bsdconfig/includes/INDEX b/usr.sbin/bsdconfig/includes/INDEX
index 6e829be..a6a6c49 100644
--- a/usr.sbin/bsdconfig/includes/INDEX
+++ b/usr.sbin/bsdconfig/includes/INDEX
@@ -1,4 +1,4 @@
-# Copyright (c) 2013 Devin Teske
+# Copyright (c) 2013-2015 Devin Teske
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -45,6 +45,7 @@ menu_help=""
# can be i18n'ed but `command' is the name of a script.
#
menu_selection="includes|includes"
+menu_selection="api|includes"
#
# ------------ Items below this line do NOT need i18n translation ------------
diff --git a/usr.sbin/bsdconfig/networking/share/device.subr b/usr.sbin/bsdconfig/networking/share/device.subr
index bb41be3..14758e6 100644
--- a/usr.sbin/bsdconfig/networking/share/device.subr
+++ b/usr.sbin/bsdconfig/networking/share/device.subr
@@ -1,6 +1,6 @@
if [ ! "$_NETWORKING_DEVICE_SUBR" ]; then _NETWORKING_DEVICE_SUBR=1
#
-# Copyright (c) 2006-2013 Devin Teske
+# Copyright (c) 2006-2015 Devin Teske
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -207,7 +207,7 @@ f_dialog_menu_netdev_edit()
'3 $msg_ipaddr4' '$ipaddr'
'4 $msg_netmask' '$netmask'
'5 $msg_options' '$options'
- "
+ " # END-QUOTE
eval f_dialog_menu_size height width rows \
\"\$DIALOG_TITLE\" \
\"\$DIALOG_BACKTITLE\" \
diff --git a/usr.sbin/bsdconfig/share/dialog.subr b/usr.sbin/bsdconfig/share/dialog.subr
index db99a70..d7c2d2c 100644
--- a/usr.sbin/bsdconfig/share/dialog.subr
+++ b/usr.sbin/bsdconfig/share/dialog.subr
@@ -1,6 +1,6 @@
if [ ! "$_DIALOG_SUBR" ]; then _DIALOG_SUBR=1
#
-# Copyright (c) 2006-2014 Devin Teske
+# Copyright (c) 2006-2015 Devin Teske
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -1580,6 +1580,56 @@ f_xdialog_info()
-1 # timeout of -1 means abort when EOF on stdin
}
+############################################################ PAUSE FUNCTIONS
+
+# f_dialog_pause $msg_text $duration [$hline]
+#
+# Display a message in a widget with a progress bar that runs backward for
+# $duration seconds.
+#
+f_dialog_pause()
+{
+ local pause_text="$1" duration="$2" hline="$3" height width
+ f_isinteger "$duration" || return $FAILURE
+ f_dialog_buttonbox_size height width \
+ "$DIALOG_TITLE" "$DIALOG_BACKTITLE" "$pause_text" "$hline"
+ if [ "$USE_XDIALOG" ]; then
+ $DIALOG \
+ --title "$DIALOG_TITLE" \
+ --backtitle "$DIALOG_BACKTITLE" \
+ --ok-label "$msg_skip" \
+ --cancel-label "$msg_cancel" \
+ ${noCancel:+--no-cancel} \
+ --timeout "$duration" \
+ --yesno "$pause_text" \
+ $height $width
+ else
+ [ $duration -gt 0 ] && duration=$(( $duration - 1 ))
+ [ $duration -gt 1 ] && duration=$(( $duration - 1 ))
+ height=$(( $height + 3 )) # Add height for progress bar
+ $DIALOG \
+ --title "$DIALOG_TITLE" \
+ --backtitle "$DIALOG_BACKTITLE" \
+ --hline "$hline" \
+ --ok-label "$msg_skip" \
+ --cancel-label "$msg_cancel" \
+ ${noCancel:+--no-cancel} \
+ --pause "$pause_text" \
+ $height $width "$duration"
+ fi
+}
+
+# f_dialog_pause_no_cancel $msg_text $duration [$hline]
+#
+# Display a message in a widget with a progress bar that runs backward for
+# $duration seconds. No cancel button is provided. Always returns success.
+#
+f_dialog_pause_no_cancel()
+{
+ noCancel=1 f_dialog_pause "$@"
+ return $SUCCESS
+}
+
############################################################ MSGBOX FUNCTIONS
# f_dialog_msgbox $msg_text [$hline]
@@ -2066,6 +2116,39 @@ f_dialog_menutag2index_with_help()
return $FAILURE
}
+# f_dialog_menutag2help $tag_chosen $tag1 $item1 $help1 $tag2 $item2 $help2 ...
+#
+# To use the `--menu' option of dialog(1) with the `--item-help' option, you
+# must pass an ordered list of tag/item/help triplets on the command-line. When
+# the user selects a menu option the tag for that item is printed to stderr.
+#
+# This function allows you to dereference the tag chosen by the user back into
+# the help associated with said tag (item is discarded/ignored).
+#
+# Pass the tag chosen by the user as the first argument, followed by the
+# ordered list of tag/item/help triplets (HINT: use the same tag/item/help list
+# as was passed to dialog(1) for consistency).
+#
+# If the tag cannot be found, NULL is returned.
+#
+f_dialog_menutag2help()
+{
+ local tag="$1" tagn help
+ shift 1 # tag
+
+ while [ $# -gt 0 ]; do
+ tagn="$1"
+ help="$3"
+ shift 3 # tagn/item/help
+
+ if [ "$tag" = "$tagn" ]; then
+ echo "$help"
+ return $SUCCESS
+ fi
+ done
+ return $FAILURE
+}
+
############################################################ INIT FUNCTIONS
# f_dialog_init
diff --git a/usr.sbin/bsdconfig/share/geom.subr b/usr.sbin/bsdconfig/share/geom.subr
index 19ed784..912a5c7 100644
--- a/usr.sbin/bsdconfig/share/geom.subr
+++ b/usr.sbin/bsdconfig/share/geom.subr
@@ -409,7 +409,7 @@ f_geom_parent()
############################################################ MAIN
#
-# Parse GEOM configuration unless requeted otherwise
+# Parse GEOM configuration unless requested otherwise
#
f_dprintf "%s: GEOM_SELF_SCAN_ALL=[%s]" geom.subr "$GEOM_SELF_SCAN_ALL"
case "$GEOM_SELF_SCAN_ALL" in
diff --git a/usr.sbin/bsdconfig/share/keymap.subr b/usr.sbin/bsdconfig/share/keymap.subr
index d4f391c..7f2f87c 100644
--- a/usr.sbin/bsdconfig/share/keymap.subr
+++ b/usr.sbin/bsdconfig/share/keymap.subr
@@ -1,6 +1,6 @@
if [ ! "$_KEYMAP_SUBR" ]; then _KEYMAP_SUBR=1
#
-# Copyright (c) 2013 Devin Teske
+# Copyright (c) 2013-2015 Devin Teske
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -219,7 +219,7 @@ f_keymap_get_all()
echo -n "$k "
# NOTE: Translate '8x8' to '8x08' before sending to
# sort(1) so that things work out as we might expect.
- debug= keymap_$k get desc | sed -e 's/8x8/8x08/g'
+ debug= keymap_$k get desc | awk 'gsub(/8x8/,"8x08")||1'
done | sort -k2 | awk '{
printf "%s%s", (started ? " " : ""), $1; started = 1
}'
diff --git a/usr.sbin/bsdconfig/timezone/share/continents.subr b/usr.sbin/bsdconfig/timezone/share/continents.subr
index 02c4071..764f33f 100644
--- a/usr.sbin/bsdconfig/timezone/share/continents.subr
+++ b/usr.sbin/bsdconfig/timezone/share/continents.subr
@@ -1,6 +1,6 @@
if [ ! "$_TIMEZONE_CONTINENTS_SUBR" ]; then _TIMEZONE_CONTINENTS_SUBR=1
#
-# Copyright (c) 2011-2012 Devin Teske
+# Copyright (c) 2011-2015 Devin Teske
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -87,7 +87,7 @@ export continent_utc_title
############################################################ FUNCTIONS
-# f_continent $cont $property
+# f_continent $cont $property [$var_to_set]
#
# Returns a single property of a given continent. Available properties are:
#
@@ -102,37 +102,60 @@ export continent_utc_title
# (which appears after continent selection).
# menu_list Menu-list of regions for this continent.
#
+# If $var_to_set is missing or NULL, the value of $var_to_get is printed to
+# standard output for capturing in a sub-shell (which is less-recommended
+# because of performance degredation; for example, when called in a loop).
+#
f_continent()
{
- local cont="$1" property="$2"
- eval echo \"\${continent_${cont}_$property}\"
+ f_getvar "continent_${1}_$2" $3
}
-# f_find_continent $title
+# f_find_continent $title [$var_to_set]
#
# Returns continent identifier given continent title.
#
+# If $var_to_set is missing or NULL, the value of $var_to_get is printed to
+# standard output for capturing in a sub-shell (which is less-recommended
+# because of performance degredation; for example, when called in a loop).
+#
f_find_continent()
{
- local cont
- for cont in $CONTINENTS; do
- if [ "$1" = "$( f_continent $cont title )" ]; then
- echo "$cont"
+ local __cont __title
+ for __cont in $CONTINENTS; do
+ f_continent $__cont title __title
+ if [ "$1" = "$__title" ]; then
+ if [ "$2" ]; then
+ setvar "$2" $__cont
+ else
+ echo "$__cont"
+ fi
return $SUCCESS
fi
done
return $FAILURE
}
-# f_OCEANP $cont
+# f_OCEANP $cont [$var_to_set]
#
# Returns "1" if the first argument is an ocean, otherwise NULL.
#
+# If $var_to_set is missing or NULL, the value of $var_to_get is printed to
+# standard output for capturing in a sub-shell (which is less-recommended
+# because of performance degredation; for example, when called in a loop).
+#
f_OCEANP()
{
case "$1" in
arctic|atlantic|indian|pacific)
- echo 1
+ if [ "$2" ]; then
+ setvar "$2" 1
+ else
+ echo 1
+ fi
+ ;;
+ *)
+ [ "$2" ] && setvar "$2" ""
esac
}
diff --git a/usr.sbin/bsdconfig/timezone/share/countries.subr b/usr.sbin/bsdconfig/timezone/share/countries.subr
index ff05766..8958e87 100644
--- a/usr.sbin/bsdconfig/timezone/share/countries.subr
+++ b/usr.sbin/bsdconfig/timezone/share/countries.subr
@@ -1,6 +1,6 @@
if [ ! "$_TIMEZONE_COUNTRIES_SUBR" ]; then _TIMEZONE_COUNTRIES_SUBR=1
#
-# Copyright (c) 2011-2012 Devin Teske
+# Copyright (c) 2011-2015 Devin Teske
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -25,8 +25,10 @@ if [ ! "$_TIMEZONE_COUNTRIES_SUBR" ]; then _TIMEZONE_COUNTRIES_SUBR=1
# SUCH DAMAGE.
#
# $FreeBSD$
+#
+############################################################ FUNCTIONS
-# f_country $code $property
+# f_country $code $property [$var_to_set]
#
# Returns a single property of a given country. Available properties are:
#
@@ -44,10 +46,13 @@ if [ ! "$_TIMEZONE_COUNTRIES_SUBR" ]; then _TIMEZONE_COUNTRIES_SUBR=1
# descr_N Like name, but for the Nth zone when the country has
# multiple zones (nzones > 0)
#
+# If $var_to_set is missing or NULL, the value of $var_to_get is printed to
+# standard output for capturing in a sub-shell (which is less-recommended
+# because of performance degredation; for example, when called in a loop).
+#
f_country()
{
- local code="$1" property="$2"
- eval echo \"\${country_${code}_$property}\"
+ f_getvar "country_${1}_$2" $3
}
# f_sort_countries
@@ -59,22 +64,42 @@ f_country()
# afterward is the sh(1) function which utilizes the below awk script.
#
f_sort_countries_awk='
+function _asorti(src, dest)
{
- split($0, array, /[[:space:]]+/)
+ 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
+}
+BEGIN {
+ split(ENVIRON["COUNTRIES"], array, /[[:space:]]+/)
for (item in array)
{
tlc = array[item]
- print ENVIRON["country_" tlc "_name"] " " tlc
+ name = ENVIRON["country_" tlc "_name"]
+ countries[name] = tlc
}
+ n = _asorti(countries, sorted_countries)
+ for (i = 1; i <= n; i++)
+ print countries[sorted_countries[i]]
+ exit
}
'
f_sort_countries()
{
- COUNTRIES=$( echo "$COUNTRIES" | awk "$f_sort_countries_awk" |
- sort | awk '{print $NF}' )
- export COUNTRIES
+ export COUNTRIES # for awk(1) ENVIRON[] visibility
+ COUNTRIES=$( awk "$f_sort_countries_awk" )
+ export COUNTRIES # Pedantic
}
+############################################################ MAIN
+
f_dprintf "%s: Successfully loaded." timezone/countries.subr
fi # ! $_TIMEZONE_COUNTRIES_SUBR
diff --git a/usr.sbin/bsdconfig/timezone/timezone b/usr.sbin/bsdconfig/timezone/timezone
index 66f2d78..a291442 100755
--- a/usr.sbin/bsdconfig/timezone/timezone
+++ b/usr.sbin/bsdconfig/timezone/timezone
@@ -1,6 +1,6 @@
#!/bin/sh
#-
-# Copyright (c) 2011-2013 Devin Teske
+# Copyright (c) 2011-2015 Devin Teske
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -280,8 +280,8 @@ f_make_menus # creates $continent_menu_list and $continent_*_menu_list
#
# Launch application main menu
#
-defaultctry=""
-defaultzone=""
+defaultctry=
+defaultzone=
NEED_CONTINENT=1
NEED_COUNTRY=1
while :; do
@@ -299,10 +299,10 @@ while :; do
continent=$( eval f_dialog_menutag2item \"\$mtag\" \
$continent_menu_list )
- cont=$( f_find_continent "$continent" )
- cont_title=$( f_continent $cont title )
- nitems=$( f_continent $cont nitems )
- isocean=$( f_OCEANP $cont )
+ f_find_continent "$continent" cont
+ f_continent $cont title cont_title
+ f_continent $cont nitems nitems
+ f_OCEANP $cont isocean
fi
if [ "$NEED_COUNTRY" ]; then
@@ -345,7 +345,7 @@ while :; do
#
# Calculate size of menu
#
- menu_list=$( f_continent $cont menu_list )
+ f_continent $cont menu_list menu_list
eval f_dialog_menu_size height width rows \
\"\$title\" \
\"\$btitle\" \
@@ -378,7 +378,7 @@ while :; do
fi
# Get the country code from the user's selection
- tlc=$( f_continent $cont tlc_$tag )
+ f_continent $cont tlc_$tag tlc
NEED_COUNTRY=
fi
@@ -387,12 +387,12 @@ while :; do
# If the selection has only one zone (nzones == -1),
# just set it.
#
- nzones=$( f_country $tlc nzones )
+ f_country $tlc nzones nzones
if [ $nzones -lt 0 ]; then
- real_cont=$( f_country $tlc cont )
- real_continent=$( f_continent $real_cont name )
- name=$( f_country $tlc name )
- filename=$( f_country $tlc filename )
+ f_country $tlc cont real_cont
+ f_continent $real_cont name real_continent
+ f_country $tlc name name
+ f_country $tlc filename filename
if ! f_confirm_zone "$real_continent/$filename"; then
[ $nitems -eq 1 ] && NEED_CONTINENT=1
@@ -400,13 +400,13 @@ while :; do
continue
fi
else
- f_sprintf title "$msg_country_time_zones" \
- "$( f_country $tlc name )"
+ f_country $tlc name name
+ f_sprintf title "$msg_country_time_zones" "$name"
f_dialog_title "$title"
title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE"
f_dialog_title_restore
prompt="$msg_select_zone"
- menu_list=$( f_country $tlc menu_list )
+ f_country $tlc menu_list menu_list
eval f_dialog_menu_size height width rows \
\"\$title\" \"\$btitle\" \"\$prompt\" \"\" $menu_list
@@ -435,10 +435,10 @@ while :; do
continue
fi
- real_cont=$( f_country $tlc cont_$n )
- real_continent=$( f_continent $real_cont name )
- name=$( f_country $tlc name )
- filename=$( f_country $tlc filename_$n )
+ f_country $tlc cont_$n real_cont
+ f_continent $real_cont name real_continent
+ f_country $tlc name name
+ f_country $tlc filename_$n filename
f_confirm_zone "$real_continent/$filename" || continue
fi
diff --git a/usr.sbin/bsdconfig/usermgmt/share/user.subr b/usr.sbin/bsdconfig/usermgmt/share/user.subr
index 5fd65fb..d0e3887 100644
--- a/usr.sbin/bsdconfig/usermgmt/share/user.subr
+++ b/usr.sbin/bsdconfig/usermgmt/share/user.subr
@@ -1,7 +1,7 @@
if [ ! "$_USERMGMT_USER_SUBR" ]; then _USERMGMT_USER_SUBR=1
#
# Copyright (c) 2012 Ron McDowell
-# Copyright (c) 2012-2014 Devin Teske
+# Copyright (c) 2012-2015 Devin Teske
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -830,8 +830,7 @@ f_user_delete()
f_eval_catch $funcname \
pw '%s -H 0' "$cmd"
else
- f_eval_catch $funcname \
- pw '%s -h -' "$cmd"
+ f_eval_catch $funcname pw '%s -h -' "$cmd"
fi
fi
fi
OpenPOWER on IntegriCloud