Performance and debugging enhancements:
+ Remove UNAME_P=$(...) from startup/misc -- already supplied by common.subr + Use f_getvar instead of $(eval echo \$$var) -- f_getvar is sub-shell free + Add `-e' and `-k var' options to f_eval_catch -- increasing use-cases + Use f_eval_catch to display errors on failure -- reducing duplicated code + Use f_eval_catch when we need output from a command -- improving debugging + Optimize f_isinter of strings.subr for performance -- now sub-shell free + Improve error checking on pidfiles -- using f_eval_catch and f_isinteger + Use $var_to_set arg of f_ifconfig_{inet,netmask} -- eliminate sub-shells + Use f_sprintf instead of $(printf ...) -- consolidate sub-shells + Use $var_to_set arg of f_route_get_default -- eliminate sub-shells + Add f_count to replace $(set -- ...;echo $#) -- eliminate sub-shells + Add f_count_ifs to replace $(IFS=x;set -- ...;echo $#) -- no sub-shells + Replace var="$var${var:+ }..." in loops with var="$var ..." with a follow- up var="${var# }" to trim leading whitespace -- optimize loops + Use $var_to_set arg of f_resolv_conf_nameservers -- eliminate sub-shells + Comments for the f_eval_catch function + Remove a duplicate `local ... desc ...' in f_device_get_all of device.subr + Use $var_to_set arg of f_device_capacity -- eliminate sub-shells + Whitespace fixes in f_dialog_init of dialog.subr + Optimize f_inet_atoi of media/tcpip.subr for performance -- sub-shell free + In several cases, send stderr to /dev/null -- clean up runtime execution + Change f_err of common.subr to go to program stderr not terminal stderr, allowing redirection of output from functions that use f_err + Disable debugging when using f_getvar to get variable argument to f_startup_rcconf_map_expand of startup/rcconf.subr + Use f_replace_all instead of $(echo ... | tr | sed) -- performance + Add a $var_to_set option to f_index_{file,menusel_{command,keyword}} of common.subr -- centralize sub-shells
This commit is contained in:
parent
914afe13c2
commit
d4ae33f072
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=259054
@ -37,8 +37,8 @@ f_include $BSDCFG_SHARE/mustberoot.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="080.console"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ FUNCTIONS
|
||||
|
||||
|
@ -38,8 +38,8 @@ f_include $BSDCFG_SHARE/sysrc.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="080.console"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ FUNCTIONS
|
||||
|
||||
@ -174,14 +174,16 @@ esac
|
||||
|
||||
[ "$f8" -a "$f14" -a "$f16" ] || f_die 1 "$msg_unknown_font_selection"
|
||||
|
||||
f_sysrc_set font8x8 "$f8" || f_die
|
||||
f_sysrc_set font8x14 "$f14" || f_die
|
||||
f_sysrc_set font8x16 "$f16" || f_die
|
||||
f_eval_catch "$0" f_sysrc_set 'f_sysrc_set font8x8 "%s"' "$f8" || f_die
|
||||
f_eval_catch "$0" f_sysrc_set 'f_sysrc_set font8x14 "%s"' "$f14" || f_die
|
||||
f_eval_catch "$0" f_sysrc_set 'f_sysrc_set font8x16 "%s"' "$f16" || f_die
|
||||
|
||||
if [ "$mc_start" ]; then
|
||||
f_sysrc_set mousechar_start "$mc_start" || f_die
|
||||
f_eval_catch "$0" f_sysrc_set \
|
||||
'f_sysrc_set mousechar_start "%s"' "$mc_start" || f_die
|
||||
else
|
||||
f_sysrc_delete mousechar_start || f_die
|
||||
f_eval_catch "$0" f_sysrc_delete \
|
||||
'f_sysrc_delete mousechar_start' || f_die
|
||||
fi
|
||||
|
||||
exit $SUCCESS
|
||||
|
@ -38,8 +38,8 @@ f_include $BSDCFG_SHARE/sysrc.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="080.console"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ CONFIGURATION
|
||||
|
||||
@ -246,10 +246,8 @@ while :; do
|
||||
keymap_name=
|
||||
mtag="${mtag# }" # remove single leading-space if-present
|
||||
for name in $KEYMAP_NAMES; do
|
||||
if [ "$( eval echo \"\$msg_$name\" )" = "$mtag" ]; then
|
||||
keymap_name="$name"
|
||||
break
|
||||
fi
|
||||
debug= f_getvar msg_$name msg
|
||||
[ "$msg" = "$mtag" ] && keymap_name="$name" break
|
||||
done
|
||||
|
||||
[ "$keymap_name" ] || continue
|
||||
@ -319,7 +317,8 @@ while :; do
|
||||
esac
|
||||
|
||||
if [ "$keymap_to_set" ]; then
|
||||
f_sysrc_set keymap "$keymap_to_set" || f_die
|
||||
f_eval_catch "$0" f_sysrc_set \
|
||||
'f_sysrc_set keymap "%s"' "$keymap_to_set" || f_die
|
||||
break
|
||||
else
|
||||
f_die 1 "$msg_unknown_keymap"
|
||||
|
@ -38,8 +38,8 @@ f_include $BSDCFG_SHARE/sysrc.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="080.console"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ FUNCTIONS
|
||||
|
||||
@ -129,7 +129,8 @@ case "$mtag" in
|
||||
esac
|
||||
|
||||
if [ "$repeat_rate_to_set" ]; then
|
||||
f_sysrc_set keyrate "$repeat_rate_to_set" || f_die
|
||||
f_eval_catch "$0" f_sysrc_set \
|
||||
'f_sysrc_set keyrate "%s"' "$repeat_rate_to_set" || f_die
|
||||
break
|
||||
else
|
||||
f_die 1 "$msg_unknown_repeat_rate"
|
||||
|
@ -38,8 +38,8 @@ f_include $BSDCFG_SHARE/sysrc.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="080.console"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ FUNCTIONS
|
||||
|
||||
@ -144,7 +144,8 @@ case "$mtag" in
|
||||
f_dialog_title "$msg_value_required"
|
||||
f_dialog_input blanktime "$msg_enter_timeout_period" \
|
||||
"$( f_sysrc_get blanktime )" &&
|
||||
f_sysrc_set blanktime "$blanktime" || f_die
|
||||
f_eval_catch "$0" f_sysrc_set \
|
||||
'f_sysrc_set blanktime "%s"' "$blanktime" || f_die
|
||||
f_dialog_title_restore
|
||||
exit $SUCCESS
|
||||
esac
|
||||
@ -180,7 +181,8 @@ case "$mtag" in
|
||||
esac
|
||||
|
||||
if [ "$saver_to_set" ]; then
|
||||
f_sysrc_set saver "$saver_to_set" || f_die
|
||||
f_eval_catch "$0" f_sysrc_set \
|
||||
'f_sysrc_set saver "%s"' "$saver_to_set" || f_die
|
||||
break
|
||||
else
|
||||
f_die 1 "$msg_unknown_saver"
|
||||
|
@ -38,8 +38,8 @@ f_include $BSDCFG_SHARE/sysrc.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="080.console"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ FUNCTIONS
|
||||
|
||||
@ -141,7 +141,8 @@ case "$mtag" in
|
||||
esac
|
||||
|
||||
if [ "$scrnmap_to_set" ]; then
|
||||
f_sysrc_set scrnmap "$scrnmap_to_set" || f_die
|
||||
f_eval_catch "$0" f_sysrc_set \
|
||||
'f_sysrc_set scrnmap "%s"' "$scrnmap_to_set" || f_die
|
||||
break
|
||||
else
|
||||
f_die 1 "$msg_unknown_screenmap_selection"
|
||||
|
@ -38,8 +38,8 @@ f_include $BSDCFG_SHARE/sysrc.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="080.console"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ CONFIGURATION
|
||||
|
||||
@ -108,23 +108,28 @@ dialog_menu_main()
|
||||
#
|
||||
ttys_set_type()
|
||||
{
|
||||
local funcname=ttys_set_type
|
||||
local consterm="$1" err
|
||||
|
||||
#
|
||||
# Create new temporary file to write our ttys(5) update with new types.
|
||||
#
|
||||
local tmpfile="$( mktemp -t "$pgm" )"
|
||||
[ "$tmpfile" ] || return $FAILURE
|
||||
local tmpfile
|
||||
f_eval_catch -k tmpfile $funcname mktemp 'mktemp -t "%s"' "$pgm" ||
|
||||
return $FAILURE
|
||||
|
||||
#
|
||||
# Fixup permissions and ownership (mktemp(1) creates the temporary file
|
||||
# with 0600 permissions -- change the permissions and ownership to
|
||||
# match ttys(5) before we write it out and mv(1) it into place).
|
||||
#
|
||||
local mode="$( stat -f '%#Lp' "$ETC_TTYS" 2> /dev/null )"
|
||||
local owner="$( stat -f '%u:%g' "$ETC_TTYS" 2> /dev/null )"
|
||||
f_quietly chmod "${mode:-0644}" "$tmpfile"
|
||||
f_quietly chown "${owner:-root:wheel}" "$tmpfile"
|
||||
local mode owner
|
||||
f_eval_catch -dk mode $funcname stat \
|
||||
'stat -f "%%#Lp" "%s"' "$ETC_TTYS" || mode=0644
|
||||
f_eval_catch -dk owner $funcname stat \
|
||||
'stat -f "%%u:%%g" "%s"' "$ETC_TTYS" || owner="root:wheel"
|
||||
f_eval_catch -d $funcname chmod 'chmod "%s" "%s"' "$mode" "$tmpfile"
|
||||
f_eval_catch -d $funcname chown 'chown "%s" "%s"' "$owner" "$tmpfile"
|
||||
|
||||
#
|
||||
# Operate on ttys(5), replacing only the types of `ttyv*' and
|
||||
@ -156,10 +161,8 @@ ttys_set_type()
|
||||
f_dialog_msgbox "$err"
|
||||
return $FAILURE
|
||||
fi
|
||||
if ! err=$( mv -f "$tmpfile" "$ETC_TTYS" 2>&1 ); then
|
||||
f_dialog_msgbox "$err"
|
||||
f_eval_catch $funcname mv 'mv -f "%s" "%s"' "$tmpfile" "$ETC_TTYS" ||
|
||||
return $FAILURE
|
||||
fi
|
||||
|
||||
return $SUCCESS
|
||||
}
|
||||
|
@ -37,8 +37,8 @@ f_include $BSDCFG_SHARE/mustberoot.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="050.diskmgmt"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ CONFIGURATION
|
||||
|
||||
|
@ -37,8 +37,8 @@ f_include $BSDCFG_SHARE/mustberoot.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="020.docsinstall"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ CONFIGURATION
|
||||
|
||||
|
@ -41,8 +41,8 @@ BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="dot"
|
||||
f_include_lang $BSDCFG_LIBE/include/messages.subr
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ CONFIGURATION
|
||||
|
||||
|
@ -41,8 +41,8 @@ BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="includes"
|
||||
f_include_lang $BSDCFG_LIBE/include/messages.subr
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ GLOBALS
|
||||
|
||||
|
@ -38,8 +38,8 @@ f_include $BSDCFG_SHARE/sysrc.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="110.mouse"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ CONFIGURATION
|
||||
|
||||
@ -73,12 +73,16 @@ f_mustberoot_init
|
||||
#
|
||||
# Stop the mouse daemon
|
||||
#
|
||||
[ -r "$MOUSED_PIDFILE" ] &&
|
||||
f_quietly kill "$( cat "$MOUSED_PIDFILE" )"
|
||||
f_sysrc_set moused_enable "NO" || f_die
|
||||
f_sysrc_set moused_type "NO" || f_die
|
||||
f_sysrc_delete moused_port || f_die
|
||||
f_sysrc_delete moused_flags || f_die
|
||||
if [ -r "$MOUSED_PIDFILE" ]; then
|
||||
f_eval_catch -dk pid "$0" cat 'cat "%s"' "$MOUSED_PIDFILE" &&
|
||||
f_isinteger "$pid" &&
|
||||
[ $pid -gt 0 ] &&
|
||||
f_eval_catch -d "$0" kill 'kill %s' $pid
|
||||
fi
|
||||
f_eval_catch "$0" f_sysrc_set 'f_sysrc_set moused_enable NO' || f_die
|
||||
f_eval_catch "$0" f_sysrc_set 'f_sysrc_set moused_type NO' || f_die
|
||||
f_eval_catch "$0" f_sysrc_delete 'f_sysrc_delete moused_port' || f_die
|
||||
f_eval_catch "$0" f_sysrc_delete 'f_sysrc_delete moused_flags' || f_die
|
||||
|
||||
#
|
||||
# Message box
|
||||
|
@ -38,8 +38,8 @@ f_include $BSDCFG_SHARE/sysrc.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="110.mouse"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ CONFIGURATION
|
||||
|
||||
@ -85,10 +85,15 @@ flags=$( f_sysrc_get moused_flags )
|
||||
# Start the mouse daemon
|
||||
#
|
||||
f_dialog_info "$msg_trying_to_start_the_mouse_daemon"
|
||||
[ -r "$MOUSED_PIDFILE" ] &&
|
||||
f_quietly kill "$( cat "$MOUSED_PIDFILE" 2> /dev/null )"
|
||||
f_quietly vidcontrol -m on
|
||||
f_quietly moused -t "$type" -p "$port" $flags
|
||||
if [ -r "$MOUSED_PIDFILE" ]; then
|
||||
f_eval_catch -dk pid "$0" cat 'cat "%s"' "$MOUSED_PIDFILE" &&
|
||||
f_isinteger "$pid" &&
|
||||
[ $pid -gt 0 ] &&
|
||||
f_eval_catch -d "$0" kill 'kill %s' $pid
|
||||
fi
|
||||
f_eval_catch -d "$0" vidcontrol 'vidcontrol -m on'
|
||||
f_eval_catch -d "$0" moused \
|
||||
'moused -t "%s" -p "%s" %s' "$type" "$port" "$flags"
|
||||
|
||||
#
|
||||
# Confirm with the user that the mouse is working
|
||||
@ -101,14 +106,19 @@ f_dialog_title_restore
|
||||
#
|
||||
# Stop the mouse daemon
|
||||
#
|
||||
f_quietly vidcontrol -m off
|
||||
f_eval_catch -d "$0" vidcontrol 'vidcontrol -m off'
|
||||
if [ $retval -eq $DIALOG_OK ]; then
|
||||
f_sysrc_set moused_enable "YES" || f_die
|
||||
ln -fs /dev/sysmouse /dev/mouse || f_die # backwards compat
|
||||
f_eval_catch "$0" f_sysrc_set 'f_sysrc_set moused_enable YES' || f_die
|
||||
f_eval_catch "$0" ln \
|
||||
'ln -fs /dev/sysmouse /dev/mouse' || f_die # backwards compat
|
||||
else
|
||||
[ -r "$MOUSED_PIDFILE" ] &&
|
||||
f_quietly kill "$( cat "$MOUSED_PIDFILE" )"
|
||||
f_sysrc_set moused_enable "NO" || f_die
|
||||
if [ -r "$MOUSED_PIDFILE" ]; then
|
||||
f_eval_catch -dk pid "$0" cat 'cat "%s"' "$MOUSED_PIDFILE" &&
|
||||
f_isinteger "$pid" &&
|
||||
[ $pid -gt 0 ] &&
|
||||
f_eval_catch -d "$0" kill 'kill %s' $pid
|
||||
fi
|
||||
f_eval_catch "$0" f_sysrc_set 'f_sysrc_set moused_enable NO' || f_die
|
||||
fi
|
||||
|
||||
exit $SUCCESS
|
||||
|
@ -38,8 +38,8 @@ f_include $BSDCFG_SHARE/sysrc.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="110.mouse"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ CONFIGURATION
|
||||
|
||||
@ -86,7 +86,7 @@ f_dialog_title_restore
|
||||
#
|
||||
# Save the new value
|
||||
#
|
||||
f_sysrc_set moused_flags "$flags" || f_die
|
||||
f_eval_catch "$0" f_sysrc_set 'f_sysrc_set moused_flags "%s"' "$flags" || f_die
|
||||
|
||||
exit $SUCCESS
|
||||
|
||||
|
@ -37,8 +37,8 @@ f_include $BSDCFG_SHARE/mustberoot.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="110.mouse"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ FUNCTIONS
|
||||
|
||||
|
@ -38,8 +38,8 @@ f_include $BSDCFG_SHARE/sysrc.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="110.mouse"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ FUNCTIONS
|
||||
|
||||
@ -141,7 +141,8 @@ case "$mtag" in
|
||||
esac
|
||||
|
||||
if [ "$moused_port_to_set" ]; then
|
||||
f_sysrc_set moused_port "$moused_port_to_set" || f_die
|
||||
f_eval_catch "$0" f_sysrc_set \
|
||||
'f_sysrc_set moused_port "%s"' "$moused_port_to_set" || f_die
|
||||
else
|
||||
f_die 1 "$msg_unknown_mouse_port_selection"
|
||||
fi
|
||||
|
@ -38,8 +38,8 @@ f_include $BSDCFG_SHARE/sysrc.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="110.mouse"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ FUNCTIONS
|
||||
|
||||
@ -157,7 +157,8 @@ case "$mtag" in
|
||||
esac
|
||||
|
||||
if [ "$moused_type_to_set" ]; then
|
||||
f_sysrc_set moused_type "$moused_type_to_set" || f_die
|
||||
f_eval_catch "$0" f_sysrc_set \
|
||||
'f_sysrc_set moused_type "%s"' "$moused_type_to_set" || f_die
|
||||
else
|
||||
f_die 1 "$msg_unknown_mouse_protocol_selection"
|
||||
fi
|
||||
|
@ -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"
|
||||
@ -38,8 +41,8 @@ f_include $BSDCFG_SHARE/networking/routing.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ MAIN
|
||||
|
||||
|
@ -49,8 +49,8 @@ f_include $BSDCFG_SHARE/networking/netmask.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ MAIN
|
||||
|
||||
@ -143,8 +143,8 @@ while :; do
|
||||
# Fill in IP address/netmask from active settings if no
|
||||
# configuration could be extrapolated from rc.conf(5)
|
||||
#
|
||||
[ "$_ipaddr" ] || _ipaddr=$( f_ifconfig_inet $interface )
|
||||
[ "$_netmask" ] || _netmask=$( f_ifconfig_netmask $interface )
|
||||
[ "$_ipaddr" ] || f_ifconfig_inet $interface _ipaddr
|
||||
[ "$_netmask" ] || f_ifconfig_netmask $interface _netmask
|
||||
|
||||
# Get the extra options (this always comes from rc.conf(5))
|
||||
_options=$( f_ifconfig_options $interface )
|
||||
|
@ -41,8 +41,8 @@ f_include $BSDCFG_SHARE/networking/hostname.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ MAIN
|
||||
|
||||
|
@ -41,8 +41,8 @@ f_include $BSDCFG_SHARE/networking/resolv.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ MAIN
|
||||
|
||||
|
@ -37,8 +37,8 @@ f_include $BSDCFG_SHARE/mustberoot.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ FUNCTIONS
|
||||
|
||||
|
@ -40,6 +40,7 @@ f_include $BSDCFG_SHARE/networking/media.subr
|
||||
f_include $BSDCFG_SHARE/networking/netmask.subr
|
||||
f_include $BSDCFG_SHARE/networking/resolv.subr
|
||||
f_include $BSDCFG_SHARE/networking/routing.subr
|
||||
f_include $BSDCFG_SHARE/strings.subr
|
||||
f_include $BSDCFG_SHARE/sysrc.subr
|
||||
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
|
||||
@ -163,6 +164,7 @@ f_dialog_menu_netdev()
|
||||
#
|
||||
f_dialog_menu_netdev_edit()
|
||||
{
|
||||
local funcname=f_dialog_menu_netdev_edit
|
||||
local interface="$1" ipaddr="$2" netmask="$3" options="$4" dhcp="$5"
|
||||
local prompt menu_list height width rows
|
||||
|
||||
@ -175,7 +177,7 @@ f_dialog_menu_netdev_edit()
|
||||
dhcp_orig="$5"
|
||||
|
||||
local hline="$hline_arrows_tab_enter"
|
||||
prompt=$( printf "$msg_network_configuration" "$interface" )
|
||||
f_sprintf prompt "$msg_network_configuration" "$interface"
|
||||
|
||||
#
|
||||
# Loop forever until the user has finished configuring the different
|
||||
@ -254,8 +256,9 @@ f_dialog_menu_netdev_edit()
|
||||
# are made is changed parts of the system may hang.
|
||||
#
|
||||
if f_nfs_mounted && ! f_jailed; then
|
||||
local setting="$( printf "$msg_current_dhcp_status" \
|
||||
"$interface" "$dhcp_status" )"
|
||||
local setting
|
||||
f_sprintf setting "$msg_current_dhcp_status" \
|
||||
"$interface" "$dhcp_status"
|
||||
f_noyes "$msg_nfs_mounts_may_cause_hang" "$setting" ||
|
||||
continue
|
||||
fi
|
||||
@ -269,7 +272,7 @@ f_dialog_menu_netdev_edit()
|
||||
trap - SIGINT
|
||||
( # Execute within sub-shell to allow/catch Ctrl-C
|
||||
trap 'exit $FAILURE' SIGINT
|
||||
msg=$( printf "$msg_scanning_for_dhcp" "$interface" )
|
||||
f_sprintf msg "$msg_scanning_for_dhcp" "$interface"
|
||||
if [ "$USE_XDIALOG" ]; then
|
||||
(
|
||||
f_quietly ifconfig "$interface" delete
|
||||
@ -319,14 +322,16 @@ f_dialog_menu_netdev_edit()
|
||||
|
||||
local value=
|
||||
if [ "$dhcp" ]; then
|
||||
f_sysrc_delete defaultrouter
|
||||
f_eval_catch $funcname f_sysrc_delete \
|
||||
'f_sysrc_delete defaultrouter'
|
||||
value=DHCP
|
||||
else
|
||||
value="inet $ipaddr netmask $netmask"
|
||||
value="$value${options:+ }$options"
|
||||
fi
|
||||
|
||||
f_sysrc_set ifconfig_$interface "$value"
|
||||
f_eval_catch $funcname f_sysrc_set \
|
||||
'f_sysrc_set "ifconfig_%s" "%s"' "$interface" "$value"
|
||||
fi
|
||||
|
||||
#
|
||||
@ -337,10 +342,12 @@ f_dialog_menu_netdev_edit()
|
||||
then
|
||||
f_show_info "$msg_bring_interface_up" "$interface"
|
||||
|
||||
local dr="$( f_sysrc_get defaultrouter )" err
|
||||
local dr="$( f_sysrc_get defaultrouter )"
|
||||
if [ "$dr" = "NO" -o ! "$dr" ]; then
|
||||
dr=$( f_route_get_default )
|
||||
[ "$dr" ] && f_sysrc_set defaultrouter "$dr"
|
||||
f_route_get_default dr
|
||||
[ "$dr" ] && f_eval_catch \
|
||||
$funcname f_sysrc_set \
|
||||
'f_sysrc_set defaultrouter "%s"' "$dr"
|
||||
fi
|
||||
#
|
||||
# Make a backup of resolv.conf(5) before using
|
||||
@ -351,16 +358,13 @@ f_dialog_menu_netdev_edit()
|
||||
# resolv.conf(5) by-default upon termination).
|
||||
#
|
||||
f_quietly cp -fp "$RESOLV_CONF" "$RESOLV_CONF.$$"
|
||||
err=$( ifconfig $interface inet $ipaddr \
|
||||
netmask $netmask $options 2>&1 )
|
||||
if [ $? -eq $SUCCESS ]; then
|
||||
if [ "$dr" -a "$dr" != "NO" ]; then
|
||||
err=$( route add default "$dr" 2>&1 )
|
||||
[ $? -eq $SUCCESS ] || \
|
||||
dialog_msgbox "$err"
|
||||
fi
|
||||
else
|
||||
dialog_msgbox "$err"
|
||||
if f_eval_catch $funcname ifconfig \
|
||||
'ifconfig "%s" inet "%s" netmask "%s" %s' \
|
||||
"$interface" "$ipaddr" "$netmask" "$options"
|
||||
then
|
||||
[ "$dr" -a "$dr" != "NO" ] &&
|
||||
f_eval_catch $funcname route \
|
||||
'route add default "%s"' "$dr"
|
||||
fi
|
||||
if cmp -s "$RESOLV_CONF" "$RESOLV_CONF.$$"; then
|
||||
f_quietly rm -f "$RESOLV_CONF.$$"
|
||||
|
@ -95,6 +95,7 @@ f_dialog_validate_hostname()
|
||||
#
|
||||
f_dialog_input_hostname()
|
||||
{
|
||||
local funcname=f_dialog_input_hostname
|
||||
local hostname="$( f_sysrc_get 'hostname:-$(hostname)' )"
|
||||
local hostname_orig="$hostname" # for change-tracking
|
||||
|
||||
@ -120,7 +121,8 @@ f_dialog_input_hostname()
|
||||
#
|
||||
if [ "$hostname" != "$hostname_orig" ]; then
|
||||
f_dialog_info "$msg_saving_hostname"
|
||||
f_sysrc_set hostname "$hostname"
|
||||
f_eval_catch $funcname f_sysrc_set \
|
||||
'f_sysrc_set hostname "%s"' "$hostname"
|
||||
fi
|
||||
|
||||
#
|
||||
|
@ -144,13 +144,14 @@ f_dialog_input_ipaddr()
|
||||
# system may hang (if any NFS mounts are using that interface).
|
||||
#
|
||||
if f_nfs_mounted && ! f_jailed; then
|
||||
local setting="$( printf "$msg_current_ipaddr" \
|
||||
"$interface" "$_ipaddr" )"
|
||||
local setting
|
||||
f_sprintf setting "$msg_current_ipaddr" "$interface" "$_ipaddr"
|
||||
f_noyes "$msg_nfs_mounts_may_cause_hang" "$setting" ||
|
||||
return $DIALOG_CANCEL
|
||||
fi
|
||||
|
||||
local msg="$( printf "$msg_please_enter_new_ip_addr" "$interface" )"
|
||||
local msg
|
||||
f_sprintf msg "$msg_please_enter_new_ip_addr" "$interface"
|
||||
|
||||
#
|
||||
# Loop until the user provides taint-free input.
|
||||
|
@ -115,13 +115,15 @@ f_dialog_input_options()
|
||||
# the system may hang (if any NFS mounts are using that interface).
|
||||
#
|
||||
if f_nfs_mounted && ! f_jailed; then
|
||||
local setting="$( printf "$msg_current_options" \
|
||||
"$interface" "$options" )"
|
||||
local setting
|
||||
f_sprintf setting "$msg_current_options" \
|
||||
"$interface" "$options"
|
||||
f_noyes "$msg_nfs_mounts_may_cause_hang" "$setting" ||
|
||||
return $DIALOG_CANCEL
|
||||
fi
|
||||
|
||||
local msg="$( printf "$msg_please_enter_mediaopts" "$interface" )"
|
||||
local msg
|
||||
f_sprintf msg "$msg_please_enter_mediaopts" "$interface"
|
||||
local hline="$hline_alnum_punc_tab_enter"
|
||||
|
||||
local _options
|
||||
@ -162,8 +164,9 @@ f_dialog_menu_media_options()
|
||||
# the system may hang (if any NFS mounts are using that interface).
|
||||
#
|
||||
if f_nfs_mounted && ! f_jailed; then
|
||||
local setting="$( printf "$msg_current_options" \
|
||||
"$interface" "$_options" )"
|
||||
local setting
|
||||
f_sprintf setting "$msg_current_options" \
|
||||
"$interface" "$_options"
|
||||
f_noyes "$msg_nfs_mounts_may_cause_hang" "$setting" ||
|
||||
return $DIALOG_CANCEL
|
||||
fi
|
||||
@ -196,11 +199,11 @@ f_dialog_menu_media_options()
|
||||
|
||||
local msg
|
||||
if [ "$USE_XDIALOG" ]; then
|
||||
msg=$( printf "$xmsg_supported_media_options" \
|
||||
"$interface" "$interface" )
|
||||
f_sprintf msg "$xmsg_supported_media_options" \
|
||||
"$interface" "$interface"
|
||||
else
|
||||
msg=$( printf "$msg_supported_media_options" \
|
||||
"$interface" "$interface" )
|
||||
f_sprintf msg "$msg_supported_media_options" \
|
||||
"$interface" "$interface"
|
||||
fi
|
||||
|
||||
local hline="$hline_arrows_tab_enter"
|
||||
|
@ -94,8 +94,9 @@ f_dialog_input_netmask()
|
||||
# the system may hang (if any NFS mounts are using that interface).
|
||||
#
|
||||
if f_nfs_mounted && ! f_jailed; then
|
||||
local setting="$( printf "$msg_current_subnet" \
|
||||
"$interface" "$_netmask" )"
|
||||
local setting
|
||||
f_sprintf setting "$msg_current_subnet" \
|
||||
"$interface" "$_netmask"
|
||||
f_noyes "$msg_nfs_mounts_may_cause_hang" "$setting" ||
|
||||
return $DIALOG_CANCEL
|
||||
fi
|
||||
@ -103,7 +104,8 @@ f_dialog_input_netmask()
|
||||
#
|
||||
# Loop until the user provides taint-free input.
|
||||
#
|
||||
local msg="$( printf "$msg_please_enter_subnet_mask" "$interface" )"
|
||||
local msg
|
||||
f_sprintf msg "$msg_please_enter_subnet_mask" "$interface"
|
||||
while :; do
|
||||
#
|
||||
# Return error status if:
|
||||
|
@ -162,20 +162,23 @@ END {
|
||||
'
|
||||
f_dialog_resolv_conf_update()
|
||||
{
|
||||
local funcname=f_dialog_resolv_conf_update
|
||||
local hostname="$1"
|
||||
|
||||
#
|
||||
# Extrapolate the desired domain search parameter for resolv.conf(5)
|
||||
#
|
||||
local search ndots domain="${hostname#*.}"
|
||||
local search nfields ndots domain="${hostname#*.}"
|
||||
if [ "$RESOLVER_SEARCH_DOMAINS_ALL" = "1" ]; then
|
||||
search=""
|
||||
ndots=$( IFS=.; set -- $domain; echo $(( $# - 1 )) )
|
||||
search=
|
||||
IFS=. f_count_ifs nfields "$domain"
|
||||
ndots=$(( $nfields - 1 ))
|
||||
while [ $ndots -ge ${RESOLVER_SEARCH_NDOTS:-1} ]; do
|
||||
search="$search${search:+ }$domain"
|
||||
search="$search $domain"
|
||||
domain="${domain#*.}"
|
||||
ndots=$(( $ndots - 1 ))
|
||||
done
|
||||
search="${search# }"
|
||||
domain="${hostname#*.}"
|
||||
else
|
||||
search="$domain"
|
||||
@ -194,8 +197,9 @@ f_dialog_resolv_conf_update()
|
||||
# Create a new temporary file to write our resolv.conf(5)
|
||||
# update with our new `domain' and `search' directives.
|
||||
#
|
||||
local tmpfile="$( mktemp -t "$pgm" )"
|
||||
[ "$tmpfile" ] || return $DIALOG_CANCEL
|
||||
local tmpfile
|
||||
f_eval_catch -dk tmpfile $funcname mktemp \
|
||||
'mktemp -t "%s"' "$tmpfile" || return $DIALOG_CANCEL
|
||||
|
||||
#
|
||||
# Fixup permissions and ownership (mktemp(1) creates the
|
||||
@ -203,10 +207,16 @@ f_dialog_resolv_conf_update()
|
||||
# permissions and ownership to match resolv.conf(5) before
|
||||
# we write it out and mv(1) it into place).
|
||||
#
|
||||
local mode="$( stat -f '%#Lp' "$RESOLV_CONF" 2> /dev/null )"
|
||||
local owner="$( stat -f '%u:%g' "$RESOLV_CONF" 2> /dev/null )"
|
||||
f_quietly chmod "${mode:-0644}" "$tmpfile"
|
||||
f_quietly chown "${owner:-root:wheel}" "$tmpfile"
|
||||
local mode owner
|
||||
f_eval_catch -dk mode $funcname stat \
|
||||
'stat -f "%%#Lp" "%s"' "$RESOLV_CONF" || mode=0644
|
||||
f_eval_catch -dk owner $funcname stat \
|
||||
'stat -f "%%u:%%g" "%s"' "$RESOLV_CONF" ||
|
||||
owner="root:wheel"
|
||||
f_eval_catch -d $funcname chmod \
|
||||
'chmod "%s" "%s"' "$mode" "$tmpfile"
|
||||
f_eval_catch -d $funcname chown \
|
||||
'chown "%s" "%s"' "$owner" "$tmpfile"
|
||||
|
||||
#
|
||||
# Operate on resolv.conf(5), replacing only the last
|
||||
@ -237,7 +247,8 @@ f_dialog_resolv_conf_update()
|
||||
#
|
||||
echo "$new_contents" | tail -r > "$tmpfile" ||
|
||||
return $DIALOG_CANCEL
|
||||
f_quietly mv "$tmpfile" "$RESOLV_CONF"
|
||||
f_eval_catch -d $funcname mv \
|
||||
'mv "%s" "%s"' "$tmpfile" "$RESOLV_CONF"
|
||||
|
||||
fi
|
||||
}
|
||||
@ -288,6 +299,7 @@ END { if ( ! found ) exit 3 }
|
||||
'
|
||||
f_dialog_input_nameserver()
|
||||
{
|
||||
local funcname=f_dialog_input_nameserver
|
||||
local index="${1:-0}" old_ns="$2" new_ns
|
||||
local ns="$old_ns"
|
||||
|
||||
@ -344,17 +356,23 @@ f_dialog_input_nameserver()
|
||||
#
|
||||
# Create a new temporary file to write our new resolv.conf(5)
|
||||
#
|
||||
local tmpfile="$( mktemp -t "$pgm" )"
|
||||
[ "$tmpfile" ] || return $DIALOG_CANCEL
|
||||
local tmpfile
|
||||
f_eval_catch -dk tmpfile $funcname mktemp \
|
||||
'mktemp -t "%s"' "$pgm" || return $DIALOG_CANCEL
|
||||
|
||||
#
|
||||
# Quietly fixup permissions and ownership
|
||||
#
|
||||
local mode owner
|
||||
mode=$( stat -f '%#Lp' "$RESOLV_CONF" 2> /dev/null )
|
||||
owner=$( stat -f '%u:%g' "$RESOLV_CONF" 2> /dev/null )
|
||||
f_quietly chmod "${mode:-0644}" "$tmpfile"
|
||||
f_quietly chown "${owner:-root:wheel}" "$tmpfile"
|
||||
f_eval_catch -dk mode $funcname stat \
|
||||
'stat -f "%%#Lp" "%s"' "$RESOLV_CONF" || mode=0644
|
||||
f_eval_catch -dk owner $funcname stat \
|
||||
'stat -f "%%u:%%g" "%s"' "$RESOLV_CONF" ||
|
||||
owner="root:wheel"
|
||||
f_eval_catch -d $funcname chmod \
|
||||
'chmod "%s" "%s"' "$mode" "$tmpfile"
|
||||
f_eval_catch -d $funcname chown \
|
||||
'chown "%s" "%s"' "$owner" "$tmpfile"
|
||||
|
||||
#
|
||||
# Operate on resolv.conf(5)
|
||||
@ -383,7 +401,8 @@ f_dialog_input_nameserver()
|
||||
# file into place.
|
||||
#
|
||||
echo "$new_contents" > "$tmpfile" || return $DIALOG_CANCEL
|
||||
f_quietly mv "$tmpfile" "$RESOLV_CONF"
|
||||
f_eval_catch -d $funcname mv \
|
||||
'mv "%s" "%s"' "$tmpfile" "$RESOLV_CONF"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -409,7 +428,8 @@ f_dialog_menu_nameservers()
|
||||
#
|
||||
# Re/Build list of nameservers
|
||||
#
|
||||
local nameservers="$( f_resolv_conf_nameservers )"
|
||||
local nameservers
|
||||
f_resolv_conf_nameservers nameservers
|
||||
menu_list=$(
|
||||
index=1
|
||||
|
||||
|
@ -35,6 +35,7 @@ f_include $BSDCFG_SHARE/dialog.subr
|
||||
f_include $BSDCFG_SHARE/media/tcpip.subr
|
||||
f_include $BSDCFG_SHARE/networking/common.subr
|
||||
f_include $BSDCFG_SHARE/networking/ipaddr.subr
|
||||
f_include $BSDCFG_SHARE/strings.subr
|
||||
f_include $BSDCFG_SHARE/sysrc.subr
|
||||
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
|
||||
@ -48,6 +49,8 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
#
|
||||
f_dialog_input_defaultrouter()
|
||||
{
|
||||
local funcname=f_dialog_input_defaultrouter
|
||||
|
||||
#
|
||||
# Get the defaultrouter. When this is not configured, the default is
|
||||
# "NO", however we don't ever want to present this default to the user
|
||||
@ -61,9 +64,7 @@ f_dialog_input_defaultrouter()
|
||||
local defaultrouter="$( f_sysrc_get 'defaultrouter:-NO' )"
|
||||
local defaultrouter_orig="$defaultrouter" # for change-tracking
|
||||
case "$defaultrouter" in
|
||||
[Nn][Oo])
|
||||
defaultrouter=$( f_route_get_default )
|
||||
;;
|
||||
[Nn][Oo]) f_route_get_default defaultrouter ;;
|
||||
esac
|
||||
|
||||
#
|
||||
@ -72,8 +73,9 @@ f_dialog_input_defaultrouter()
|
||||
# mounted, the system will hang.
|
||||
#
|
||||
if f_nfs_mounted && ! f_jailed; then
|
||||
local setting="$( printf "$msg_current_default_router" \
|
||||
"$defaultrouter" )"
|
||||
local setting
|
||||
f_sprintf setting "$msg_current_default_router" \
|
||||
"$defaultrouter"
|
||||
f_noyes "$msg_nfs_mounts_may_cause_hang" "$setting" ||
|
||||
return $DIALOG_CANCEL
|
||||
fi
|
||||
@ -101,27 +103,25 @@ f_dialog_input_defaultrouter()
|
||||
f_dialog_info "$msg_saving_default_router"
|
||||
|
||||
# Save the default router/gateway
|
||||
f_sysrc_set defaultrouter "$defaultrouter"
|
||||
f_eval_catch $funcname f_sysrc_set \
|
||||
'f_sysrc_set defaultrouter "%s"' "$defaultrouter"
|
||||
fi
|
||||
|
||||
#
|
||||
# Only ask to apply setting if the current defaultrouter is different
|
||||
# than the stored configuration (in rc.conf(5)).
|
||||
#
|
||||
if [ "$( f_route_get_default )" != "$defaultrouter" ]; then
|
||||
local dr
|
||||
f_route_get_default dr
|
||||
if [ "$dr" != "$defaultrouter" ]; then
|
||||
f_dialog_clear
|
||||
f_yesno "$msg_activate_default_router" \
|
||||
"$( f_route_get_default )" "$defaultrouter"
|
||||
f_yesno "$msg_activate_default_router" "$dr" "$defaultrouter"
|
||||
if [ $? -eq $DIALOG_OK ]; then
|
||||
local err
|
||||
|
||||
# Apply the default router/gateway
|
||||
f_quietly route delete default
|
||||
err=$( route add default "$defaultrouter" 2>&1 )
|
||||
if [ $? -ne $SUCCESS ]; then
|
||||
f_dialog_msgbox "$err"
|
||||
f_eval_catch -d $funcname route 'route delete default'
|
||||
f_eval_catch $funcname route \
|
||||
'route add default "%s"' "$defaultrouter" ||
|
||||
return $DIALOG_CANCEL
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
@ -42,8 +42,9 @@ f_include $BSDCFG_SHARE/sysrc.subr
|
||||
#
|
||||
f_config_pcnfsd()
|
||||
{
|
||||
local funcname=f_config_pcnfsd
|
||||
f_package_add "pcnfsd" || return $?
|
||||
f_sysrc_set mountd_flags "-n"
|
||||
f_eval_catch $funcname f_sysrc_set 'f_sysrc_set mountd_flags -n'
|
||||
return $SUCCESS
|
||||
}
|
||||
|
||||
|
@ -45,8 +45,8 @@ f_include $BSDCFG_SHARE/packages/packages.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="030.packages"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ MAIN
|
||||
|
||||
|
@ -37,8 +37,8 @@ f_include $BSDCFG_SHARE/password/password.subr
|
||||
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="040.password"
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ CONFIGURATION
|
||||
|
||||
@ -73,8 +73,8 @@ f_mustberoot_init
|
||||
# Prompt the user to input a new password (and change it if they don't cancel)
|
||||
#
|
||||
if f_dialog_input_password; then
|
||||
err=$( echo "$pw_password" | pw usermod $USER_ROOT -h 0 2>&1 ) ||
|
||||
f_die $? "%s" "$err"
|
||||
echo "$pw_password" | f_eval_catch "$0" pw \
|
||||
'pw usermod "%s" -h 0' "$USER_ROOT" || f_die
|
||||
f_show_msg "$msg_password_changed"
|
||||
fi
|
||||
|
||||
|
@ -40,8 +40,8 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
SECURELEVEL_HELPFILE=$BSDCFG_LIBE/$APP_DIR/include/securelevel.hlp
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ FUNCTIONS
|
||||
|
||||
@ -143,19 +143,26 @@ done
|
||||
|
||||
case "$mtag" in
|
||||
"$msg_disabled")
|
||||
f_sysrc_set kern_securelevel_enable "NO"
|
||||
f_eval_catch "$0" f_sysrc_set \
|
||||
'f_sysrc_set kern_securelevel_enable NO' || f_die
|
||||
;;
|
||||
"$msg_secure")
|
||||
f_sysrc_set kern_securelevel_enable "YES"
|
||||
f_sysrc_set kern_securelevel "1"
|
||||
f_eval_catch "$0" f_sysrc_set \
|
||||
'f_sysrc_set kern_securelevel_enable YES' || f_die
|
||||
f_eval_catch "$0" f_sysrc_set \
|
||||
'f_sysrc_set kern_securelevel 1' || f_die
|
||||
;;
|
||||
"$msg_highly_secure")
|
||||
f_sysrc_set kern_securelevel_enable "YES"
|
||||
f_sysrc_set kern_securelevel "2"
|
||||
f_eval_catch "$0" f_sysrc_set \
|
||||
'f_sysrc_set kern_securelevel_enable YES' || f_die
|
||||
f_eval_catch "$0" f_sysrc_set \
|
||||
'f_sysrc_set kern_securelevel 2' || f_die
|
||||
;;
|
||||
"$msg_network_secure")
|
||||
f_sysrc_set kern_securelevel_enable "YES"
|
||||
f_sysrc_set kern_securelevel "3"
|
||||
f_eval_catch "$0" f_sysrc_set \
|
||||
'f_sysrc_set kern_securelevel_enable YES' || f_die
|
||||
f_eval_catch "$0" f_sysrc_set \
|
||||
'f_sysrc_set kern_securelevel 3' || f_die
|
||||
;;
|
||||
*)
|
||||
f_die 1 "$msg_unknown_kern_securelevel_selection"
|
||||
|
@ -38,8 +38,8 @@ f_include $BSDCFG_SHARE/sysrc.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="130.security"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ FUNCTIONS
|
||||
|
||||
@ -162,9 +162,11 @@ while :; do
|
||||
"2 ["?"] $msg_securelevel") # Configure securelevels for the system
|
||||
$BSDCFG_LIBE/$APP_DIR/kern_securelevel ${USE_XDIALOG:+-X} ;;
|
||||
"3 [X] $msg_nfs_port") # Require that NFS clients use reserved ports
|
||||
f_sysrc_set nfs_reserved_port_only "NO" ;;
|
||||
f_eval_catch "$0" f_sysrc_set \
|
||||
'f_sysrc_set nfs_reserved_port_only NO' ;;
|
||||
"3 [ ] $msg_nfs_port") # Same; Toggle value
|
||||
f_sysrc_set nfs_reserved_port_only "YES" ;;
|
||||
f_eval_catch "$0" f_sysrc_set \
|
||||
'f_sysrc_set nfs_reserved_port_only YES' ;;
|
||||
*)
|
||||
f_die 1 "$msg_unknown_security_menu_selection"
|
||||
esac
|
||||
|
@ -58,10 +58,10 @@ FAILURE=1
|
||||
#
|
||||
# Operating environment details
|
||||
#
|
||||
export UNAME_S="$(uname -s)" # Operating System (i.e. FreeBSD)
|
||||
export UNAME_P="$(uname -p)" # Processor Architecture (i.e. i386)
|
||||
export UNAME_M="$(uname -m)" # Machine platform (i.e. i386)
|
||||
export UNAME_R="$(uname -r)" # Release Level (i.e. X.Y-RELEASE)
|
||||
export UNAME_S="$( uname -s )" # Operating System (i.e. FreeBSD)
|
||||
export UNAME_P="$( uname -p )" # Processor Architecture (i.e. i386)
|
||||
export UNAME_M="$( uname -m )" # Machine platform (i.e. i386)
|
||||
export UNAME_R="$( uname -r )" # Release Level (i.e. X.Y-RELEASE)
|
||||
if [ ! "${PKG_ABI+set}" ]; then
|
||||
export PKG_ABI="$(
|
||||
ASSUME_ALWAYS_YES=1 pkg -vv |
|
||||
@ -204,7 +204,7 @@ f_debug_init()
|
||||
#
|
||||
f_err()
|
||||
{
|
||||
printf "$@" >&${TERMINAL_STDERR_PASSTHRU:-2}
|
||||
printf "$@" >&2
|
||||
}
|
||||
|
||||
# f_quietly $command [$arguments ...]
|
||||
@ -565,7 +565,7 @@ f_usage()
|
||||
exit $FAILURE
|
||||
}
|
||||
|
||||
# f_index_file $keyword
|
||||
# f_index_file $keyword [$var_to_set]
|
||||
#
|
||||
# Process all INDEX files known to bsdconfig and return the path to first file
|
||||
# containing a menu_selection line with a keyword portion matching $keyword.
|
||||
@ -575,6 +575,9 @@ f_usage()
|
||||
#
|
||||
# If no file is found, error status is returned along with the NULL string.
|
||||
#
|
||||
# If $var_to_set is NULL or missing, output is printed to stdout (which is less
|
||||
# recommended due to performance degradation; in a loop for example).
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
@ -591,33 +594,55 @@ END { exit ! found }
|
||||
'
|
||||
f_index_file()
|
||||
{
|
||||
local keyword="$1"
|
||||
local lang="${LANG:-$LC_ALL}"
|
||||
local __keyword="$1" __var_to_set="$2"
|
||||
local __lang="${LANG:-$LC_ALL}"
|
||||
local __indexes="$BSDCFG_LIBE${BSDCFG_LIBE:+/}*/INDEX"
|
||||
|
||||
f_dprintf "f_index_file: keyword=[%s] lang=[%s]" "$keyword" "$lang"
|
||||
f_dprintf "f_index_file: keyword=[%s] lang=[%s]" "$__keyword" "$__lang"
|
||||
|
||||
if [ "$lang" ]; then
|
||||
awk -v keyword="$keyword" "$f_index_file_awk" \
|
||||
$BSDCFG_LIBE${BSDCFG_LIBE:+/}*/INDEX.$lang &&
|
||||
return $SUCCESS
|
||||
if [ "$__lang" ]; then
|
||||
if [ "$__var_to_set" ]; then
|
||||
eval "$__var_to_set"='"$( awk -v keyword="$__keyword" \
|
||||
"$f_index_file_awk" $__indexes.$__lang
|
||||
)"' && return $SUCCESS
|
||||
else
|
||||
awk -v keyword="$__keyword" "$f_index_file_awk" \
|
||||
$__indexes.$__lang && return $SUCCESS
|
||||
fi
|
||||
# No match, fall-thru to non-i18n sources
|
||||
fi
|
||||
awk -v keyword="$keyword" "$f_index_file_awk" \
|
||||
$BSDCFG_LIBE${BSDCFG_LIBE:+/}*/INDEX && return $SUCCESS
|
||||
if [ "$__var_to_set" ]; then
|
||||
eval "$__var_to_set"='"$( awk -v keyword="$__keyword" \
|
||||
"$f_index_file_awk" $__indexes )"' && return $SUCCESS
|
||||
else
|
||||
awk -v keyword="$__keyword" "$f_index_file_awk" $__indexes &&
|
||||
return $SUCCESS
|
||||
fi
|
||||
|
||||
# No match? Fall-thru to `local' libexec sources (add-on modules)
|
||||
|
||||
[ "$BSDCFG_LOCAL_LIBE" ] || return $FAILURE
|
||||
if [ "$lang" ]; then
|
||||
awk -v keyword="$keyword" "$f_index_file_awk" \
|
||||
$BSDCFG_LOCAL_LIBE/*/INDEX.$lang && return $SUCCESS
|
||||
__indexes="$BSDCFG_LOCAL_LIBE/*/INDEX"
|
||||
if [ "$__lang" ]; then
|
||||
if [ "$__var_to_set" ]; then
|
||||
eval "$__var_to_set"='"$( awk -v keyword="$__keyword" \
|
||||
"$f_index_file_awk" $__indexes.$__lang
|
||||
)"' && return $SUCCESS
|
||||
else
|
||||
awk -v keyword="$__keyword" "$f_index_file_awk" \
|
||||
$__indexes.$__lang && return $SUCCESS
|
||||
fi
|
||||
# No match, fall-thru to non-i18n sources
|
||||
fi
|
||||
awk -v keyword="$keyword" "$f_index_file_awk" \
|
||||
$BSDCFG_LOCAL_LIBE/*/INDEX
|
||||
if [ "$__var_to_set" ]; then
|
||||
eval "$__var_to_set"='$( awk -v keyword="$__keyword" \
|
||||
"$f_index_file_awk" $__indexes )"'
|
||||
else
|
||||
awk -v keyword="$__keyword" "$f_index_file_awk" $__indexes
|
||||
fi
|
||||
}
|
||||
|
||||
# f_index_menusel_keyword $indexfile $pgm
|
||||
# f_index_menusel_keyword $indexfile $pgm [$var_to_set]
|
||||
#
|
||||
# Process $indexfile and return only the keyword portion of the menu_selection
|
||||
# line with a command portion matching $pgm.
|
||||
@ -634,6 +659,9 @@ f_index_file()
|
||||
#
|
||||
# If $indexfile does not exist, error status is returned with NULL.
|
||||
#
|
||||
# If $var_to_set is NULL or missing, output is printed to stdout (which is less
|
||||
# recommended due to performance degradation; in a loop for example).
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
@ -664,24 +692,23 @@ END { exit ! found }
|
||||
'
|
||||
f_index_menusel_keyword()
|
||||
{
|
||||
local indexfile="$1" pgm="$2"
|
||||
local lang="${LANG:-$LC_ALL}"
|
||||
local __indexfile="$1" __pgm="$2" __var_to_set="$3"
|
||||
local __lang="${LANG:-$LC_ALL}" __file="$__indexfile"
|
||||
|
||||
[ -f "$__indexfile.$__lang" ] && __file="$__indexfile.$__lang"
|
||||
f_dprintf "f_index_menusel_keyword: index=[%s] pgm=[%s] lang=[%s]" \
|
||||
"$indexfile" "$pgm" "$lang"
|
||||
"$__file" "$__pgm" "$__lang"
|
||||
|
||||
if [ -f "$indexfile.$lang" ]; then
|
||||
awk -v pgm="$pgm" \
|
||||
"$f_index_menusel_keyword_awk" \
|
||||
"$indexfile.$lang"
|
||||
elif [ -f "$indexfile" ]; then
|
||||
awk -v pgm="$pgm" \
|
||||
"$f_index_menusel_keyword_awk" \
|
||||
"$indexfile"
|
||||
if [ "$__var_to_set" ]; then
|
||||
setvar "$__var_to_set" "$( awk \
|
||||
-v pgm="$__pgm" "$f_index_menusel_keyword_awk" "$__file"
|
||||
)"
|
||||
else
|
||||
awk -v pgm="$__pgm" "$f_index_menusel_keyword_awk" "$__file"
|
||||
fi
|
||||
}
|
||||
|
||||
# f_index_menusel_command $indexfile $keyword
|
||||
# f_index_menusel_command $indexfile $keyword [$var_to_set]
|
||||
#
|
||||
# Process $indexfile and return only the command portion of the menu_selection
|
||||
# line with a keyword portion matching $keyword.
|
||||
@ -697,6 +724,9 @@ f_index_menusel_keyword()
|
||||
#
|
||||
# If $indexfile doesn't exist, error status is returned with NULL.
|
||||
#
|
||||
# If $var_to_set is NULL or missing, output is printed to stdout (which is less
|
||||
# recommended due to performance degradation; in a loop for example).
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
@ -727,37 +757,34 @@ END { exit ! found }
|
||||
'
|
||||
f_index_menusel_command()
|
||||
{
|
||||
local indexfile="$1" keyword="$2" command
|
||||
local lang="${LANG:-$LC_ALL}"
|
||||
local __indexfile="$1" __keyword="$2" __var_to_set="$3" __command
|
||||
local __lang="${LANG:-$LC_ALL}" __file="$__indexfile"
|
||||
|
||||
[ -f "$__indexfile.$__lang" ] && __file="$__indexfile.$__lang"
|
||||
f_dprintf "f_index_menusel_command: index=[%s] key=[%s] lang=[%s]" \
|
||||
"$indexfile" "$keyword" "$lang"
|
||||
"$__file" "$__keyword" "$__lang"
|
||||
|
||||
if [ -f "$indexfile.$lang" ]; then
|
||||
command=$( awk -v key="$keyword" \
|
||||
"$f_index_menusel_command_awk" \
|
||||
"$indexfile.$lang" ) || return $FAILURE
|
||||
elif [ -f "$indexfile" ]; then
|
||||
command=$( awk -v key="$keyword" \
|
||||
"$f_index_menusel_command_awk" \
|
||||
"$indexfile" ) || return $FAILURE
|
||||
else
|
||||
return $FAILURE
|
||||
fi
|
||||
[ -f "$__file" ] || return $FAILURE
|
||||
__command=$( awk -v key="$__keyword" \
|
||||
"$f_index_menusel_command_awk" "$__file" ) || return $FAILURE
|
||||
|
||||
#
|
||||
# If the command pathname is not fully qualified fix-up/force to be
|
||||
# relative to the $indexfile directory.
|
||||
#
|
||||
case "$command" in
|
||||
case "$__command" in
|
||||
/*) : already fully qualified ;;
|
||||
*)
|
||||
local indexdir="${indexfile%/*}"
|
||||
[ "$indexdir" != "$indexfile" ] || indexdir="."
|
||||
command="$indexdir/$command"
|
||||
local __indexdir="${__indexfile%/*}"
|
||||
[ "$__indexdir" != "$__indexfile" ] || __indexdir="."
|
||||
__command="$__indexdir/$__command"
|
||||
esac
|
||||
|
||||
echo "$command"
|
||||
if [ "$__var_to_set" ]; then
|
||||
setvar "$__var_to_set" "$__command"
|
||||
else
|
||||
echo "$__command"
|
||||
fi
|
||||
}
|
||||
|
||||
# f_running_as_init
|
||||
@ -784,35 +811,30 @@ f_mounted()
|
||||
mount | grep -Eq " on $dir \([^)]+\)$"
|
||||
}
|
||||
|
||||
# f_eval_catch [-d] $funcname $utility $format [$arguments ...]
|
||||
# f_eval_catch [-de] [-k $var_to_set] $funcname $utility \
|
||||
# $format [$arguments ...]
|
||||
#
|
||||
# Silently evaluate a command in a sub-shell and test for error. If debugging
|
||||
# is enabled a copy of the command and its output is sent to debug (either
|
||||
# stdout or file depending on environment). If an error occurs, output of the
|
||||
# command is displayed in a dialog(1) msgbox using the [above] f_show_err()
|
||||
# function (unless optional `-d' flag is the first argument, then no dialog).
|
||||
# function (unless optional `-d' flag is given, then no dialog).
|
||||
#
|
||||
# The $funcname argument is sent to debugging while the $utility argument is
|
||||
# used in the title of the dialog box. The command that is sent to debugging
|
||||
# along with $funcname is the product of the printf(1) syntax produced by
|
||||
# $format with optional $arguments.
|
||||
# used in the title of the dialog box. The command that is executed as well as
|
||||
# sent to debugging with $funcname is the product of the printf(1) syntax
|
||||
# produced by $format with optional $arguments.
|
||||
#
|
||||
# The following options are supported:
|
||||
#
|
||||
# -d Do not use dialog(1).
|
||||
# -e Produce error text from failed command on stderr.
|
||||
# -k var Save output from the command in var.
|
||||
#
|
||||
# Example 1:
|
||||
#
|
||||
# debug=1
|
||||
# f_eval_catch myfunc cat 'contents=$( cat "%s" )' /some/file
|
||||
# # Error displayed ``cat: /some/file: No such file or directory''
|
||||
#
|
||||
# Produces the following debug output:
|
||||
#
|
||||
# DEBUG: myfunc: cat "/some/file"
|
||||
# DEBUG: myfunc: retval=1 <output below>
|
||||
# cat: /some/file: No such file or directory
|
||||
#
|
||||
# Example 2:
|
||||
#
|
||||
# debug=1
|
||||
# f_eval_catch myfunc echo 'echo "%s"' "Hello, World!"
|
||||
# # No error displayed
|
||||
#
|
||||
# Produces the following debug output:
|
||||
#
|
||||
@ -820,11 +842,23 @@ f_mounted()
|
||||
# DEBUG: myfunc: retval=0 <output below>
|
||||
# Hello, World!
|
||||
#
|
||||
# Example 2:
|
||||
#
|
||||
# debug=1
|
||||
# f_eval_catch -k contents myfunc cat 'cat "%s"' /some/file
|
||||
# # dialog(1) Error ``cat: /some/file: No such file or directory''
|
||||
# # contents=[cat: /some/file: No such file or directory]
|
||||
#
|
||||
# Produces the following debug output:
|
||||
#
|
||||
# DEBUG: myfunc: cat "/some/file"
|
||||
# DEBUG: myfunc: retval=1 <output below>
|
||||
# cat: /some/file: No such file or directory
|
||||
#
|
||||
# Example 3:
|
||||
#
|
||||
# debug=1
|
||||
# echo 123 | f_eval_catch myfunc rev rev
|
||||
# # No error displayed
|
||||
#
|
||||
# Produces the following debug output:
|
||||
#
|
||||
@ -836,34 +870,107 @@ f_mounted()
|
||||
#
|
||||
# debug=1
|
||||
# f_eval_catch myfunc true true
|
||||
# # No error displayed
|
||||
#
|
||||
# Produces the following debug output:
|
||||
#
|
||||
# DEBUG: myfunc: true
|
||||
# DEBUG: myfunc: retval=0 <no output>
|
||||
#
|
||||
# Example 5:
|
||||
#
|
||||
# f_eval_catch -de myfunc ls 'ls "%s"' /some/dir
|
||||
# # Output on stderr ``ls: /some/dir: No such file or directory''
|
||||
#
|
||||
# Example 6:
|
||||
#
|
||||
# f_eval_catch -dek contents myfunc ls 'ls "%s"' /etc
|
||||
# # Output from `ls' sent to stderr and also saved in $contents
|
||||
#
|
||||
f_eval_catch()
|
||||
{
|
||||
local no_dialog=
|
||||
[ "$1" = "-d" ] && no_dialog=1 && shift 1
|
||||
local funcname="$1" utility="$2"; shift 2
|
||||
local cmd output retval
|
||||
cmd=$( printf -- "$@" )
|
||||
f_dprintf "%s: %s" "$funcname" "$cmd" # Log command *before* eval
|
||||
output=$( exec 2>&1; eval "$cmd" )
|
||||
retval=$?
|
||||
if [ "$output" ]; then
|
||||
f_dprintf "%s: retval=%i <output below>\n%s" "$funcname" \
|
||||
$retval "$output"
|
||||
local __no_dialog= __show_err= __var_to_set=
|
||||
|
||||
#
|
||||
# Process local function arguments
|
||||
#
|
||||
local OPTIND __flag
|
||||
while getopts "dek:" __flag > /dev/null; do
|
||||
case "$__flag" in
|
||||
d) __no_dialog=1 ;;
|
||||
e) __show_err=1 ;;
|
||||
k) __var_to_set="$OPTARG" ;;
|
||||
esac
|
||||
done
|
||||
shift $(( $OPTIND - 1 ))
|
||||
|
||||
local __funcname="$1" __utility="$2"; shift 2
|
||||
local __cmd __output __retval
|
||||
|
||||
__cmd=$( printf -- "$@" )
|
||||
f_dprintf "%s: %s" "$__funcname" "$__cmd" # Log command *before* eval
|
||||
__output=$( exec 2>&1; eval "$__cmd" )
|
||||
__retval=$?
|
||||
if [ "$__output" ]; then
|
||||
[ "$__show_err" ] && echo "$__output" >&2
|
||||
f_dprintf "%s: retval=%i <output below>\n%s" "$__funcname" \
|
||||
$__retval "$__output"
|
||||
else
|
||||
f_dprintf "%s: retval=%i <no output>" "$funcname" $retval
|
||||
f_dprintf "%s: retval=%i <no output>" "$__funcname" $__retval
|
||||
fi
|
||||
! [ "$no_dialog" -o "$nonInteractive" -o $retval -eq $SUCCESS ] &&
|
||||
msg_error="${msg_error:-Error}${utility:+: $utility}" \
|
||||
f_show_err "%s" "$output"
|
||||
|
||||
! [ "$__no_dialog" -o "$nonInteractive" -o $__retval -eq $SUCCESS ] &&
|
||||
msg_error="${msg_error:-Error}${__utility:+: $__utility}" \
|
||||
f_show_err "%s" "$__output"
|
||||
# NB: f_show_err will handle NULL output appropriately
|
||||
return $retval
|
||||
|
||||
[ "$__var_to_set" ] && setvar "$__var_to_set" "$__output"
|
||||
|
||||
return $__retval
|
||||
}
|
||||
|
||||
# f_count $var_to_set arguments ...
|
||||
#
|
||||
# Sets $var_to_set to the number of arguments minus one (the effective number
|
||||
# of arguments following $var_to_set).
|
||||
#
|
||||
# Example:
|
||||
# f_count count dog house # count=[2]
|
||||
#
|
||||
f_count()
|
||||
{
|
||||
setvar "$1" $(( $# - 1 ))
|
||||
}
|
||||
|
||||
# f_count_ifs $var_to_set string ...
|
||||
#
|
||||
# Sets $var_to_set to the number of words (split by the internal field
|
||||
# separator, IFS) following $var_to_set.
|
||||
#
|
||||
# Example 1:
|
||||
#
|
||||
# string="word1 word2 word3"
|
||||
# f_count_ifs count "$string" # count=[3]
|
||||
# f_count_ifs count $string # count=[3]
|
||||
#
|
||||
# Example 2:
|
||||
#
|
||||
# IFS=. f_count_ifs count www.freebsd.org # count=[3]
|
||||
#
|
||||
# NB: Make sure to use double-quotes if you are using a custom value for IFS
|
||||
# and you don't want the current value to effect the result. See example 3.
|
||||
#
|
||||
# Example 3:
|
||||
#
|
||||
# string="a-b c-d"
|
||||
# IFS=- f_count_ifs count "$string" # count=[3]
|
||||
# IFS=- f_count_ifs count $string # count=[4]
|
||||
#
|
||||
f_count_ifs()
|
||||
{
|
||||
local __var_to_set="$1"
|
||||
shift 1
|
||||
set -- $*
|
||||
setvar "$__var_to_set" $#
|
||||
}
|
||||
|
||||
############################################################ MAIN
|
||||
|
@ -42,6 +42,7 @@ f_include_lang $BSDCFG_LIBE/include/messages.subr
|
||||
|
||||
DEVICES=
|
||||
DEVICE_NAMES=
|
||||
NDEVICES=0
|
||||
|
||||
# A "device" from sysinstall's point of view
|
||||
f_struct_define DEVICE \
|
||||
@ -100,7 +101,7 @@ f_device_try()
|
||||
{
|
||||
local name="$1" i="$2" var_path="$3" unit
|
||||
if [ "$i" ]; then
|
||||
unit=$( printf "$name" "$i" )
|
||||
f_sprintf unit "$name" "$i"
|
||||
else
|
||||
unit="$name"
|
||||
fi
|
||||
@ -213,7 +214,7 @@ f_device_reset_network()
|
||||
#
|
||||
f_device_get_all()
|
||||
{
|
||||
local devname desc
|
||||
local devname desc capacity
|
||||
|
||||
f_dprintf "f_device_get_all: Probing devices..."
|
||||
f_dialog_info "$msg_probing_devices_please_wait_this_can_take_a_while"
|
||||
@ -225,7 +226,7 @@ f_device_get_all()
|
||||
# as a media source for content
|
||||
#
|
||||
|
||||
local dev desc type max n=0
|
||||
local dev type max n=0
|
||||
for dev in $DEVICE_NAMES; do
|
||||
n=$(( $n + 1 ))
|
||||
# Get the desc, type, and max (with debugging disabled)
|
||||
@ -245,32 +246,32 @@ f_device_get_all()
|
||||
case "$type" in
|
||||
$DEVICE_TYPE_CDROM)
|
||||
f_device_try "$dev" "$i" devname || continue
|
||||
f_device_capacity "$devname" capacity
|
||||
f_device_register "${devname##*/}" "$desc" \
|
||||
"$devname" $DEVICE_TYPE_CDROM 1 \
|
||||
f_media_init_cdrom f_media_get_cdrom \
|
||||
f_media_shutdown_cdrom "" \
|
||||
"$( f_device_capacity "$devname" )"
|
||||
f_media_shutdown_cdrom "" "$capacity"
|
||||
f_dprintf "Found a CDROM device for %s" \
|
||||
"$devname"
|
||||
;;
|
||||
$DEVICE_TYPE_FLOPPY)
|
||||
f_device_try "$dev" "$i" devname || continue
|
||||
f_device_capacity "$devname" capacity
|
||||
f_device_register "${devname##*/}" "$desc" \
|
||||
"$devname" $DEVICE_TYPE_FLOPPY 1 \
|
||||
f_media_init_floppy \
|
||||
f_media_get_floppy \
|
||||
f_media_shutdown_floppy "" \
|
||||
"$( f_device_capacity "$devname" )"
|
||||
f_media_shutdown_floppy "" "$capacity"
|
||||
f_dprintf "Found a floppy device for %s" \
|
||||
"$devname"
|
||||
;;
|
||||
$DEVICE_TYPE_USB)
|
||||
f_device_try "$dev" "$i" devname || continue
|
||||
f_device_capacity "$devname" capacity
|
||||
f_device_register "${devname##*/}" "$desc" \
|
||||
"$devname" $DEVICE_TYPE_USB 1 \
|
||||
f_media_init_usb f_media_get_usb \
|
||||
f_media_shutdown_usb "" \
|
||||
"$( f_device_capacity "$devname" )"
|
||||
f_media_shutdown_usb "" "$capacity"
|
||||
f_dprintf "Found a USB disk for %s" "$devname"
|
||||
;;
|
||||
esac
|
||||
@ -280,11 +281,11 @@ f_device_get_all()
|
||||
# Register ISO9660 providers as CDROM devices
|
||||
for devname in /dev/iso9660/*; do
|
||||
f_device_try "$devname" || continue
|
||||
f_device_capacity "$devname" capacity
|
||||
f_device_register "${devname##*/}" "ISO9660 file system" \
|
||||
"$devname" $DEVICE_TYPE_CDROM 1 \
|
||||
f_media_init_cdrom f_media_get_cdrom \
|
||||
f_media_shutdown_cdrom "" \
|
||||
"$( f_device_capacity "$devname" )"
|
||||
f_media_shutdown_cdrom "" "$capacity"
|
||||
f_dprintf "Found a CDROM device for %s" "$devname"
|
||||
done
|
||||
|
||||
@ -307,12 +308,12 @@ f_device_get_all()
|
||||
' )
|
||||
case "$filename" in
|
||||
*.iso) # Register the device as an ISO9660 provider
|
||||
f_device_capacity "$devname" capacity
|
||||
f_device_register "${devname##*/}" \
|
||||
"md(4) vnode file system" \
|
||||
"$devname" $DEVICE_TYPE_CDROM 1 \
|
||||
f_media_init_cdrom f_media_get_cdrom \
|
||||
f_media_shutdown_cdrom "" \
|
||||
"$( f_device_capacity "$devname" )"
|
||||
f_media_shutdown_cdrom "" "$capacity"
|
||||
f_dprintf "Found a CDROM device for %s" "$devname"
|
||||
;;
|
||||
esac
|
||||
@ -347,10 +348,10 @@ f_device_get_all()
|
||||
# Try and find its description
|
||||
f_device_desc "$diskname" $DEVICE_TYPE_DISK desc
|
||||
|
||||
f_device_capacity "$diskname" capacity
|
||||
f_device_register "$diskname" "$desc" \
|
||||
"/dev/$diskname" $DEVICE_TYPE_DISK 0 \
|
||||
"" "" "" "" \
|
||||
"$( f_device_capacity "$diskname" )"
|
||||
"" "" "" "" "$capacity"
|
||||
f_dprintf "Found a disk device named %s" "$diskname"
|
||||
|
||||
# Look for existing partitions to register
|
||||
@ -360,11 +361,11 @@ f_device_get_all()
|
||||
case "$type" in
|
||||
0x01|0x04|0x06|0x0b|0x0c|0x0e|0xef)
|
||||
# DOS partitions to add as "DOS media devices"
|
||||
f_device_capacity "/dev/$slice" capacity
|
||||
f_device_register "$slice" "" \
|
||||
"/dev/$slice" $DEVICE_TYPE_DOS 1 \
|
||||
f_media_init_dos f_media_get_dos \
|
||||
f_media_shutdown_dos "" \
|
||||
"$( f_device_capacity "/dev/$slice" )"
|
||||
f_media_shutdown_dos "" "$capacity"
|
||||
f_dprintf "Found a DOS partition %s" "$slice"
|
||||
;;
|
||||
0xa5) # FreeBSD partition
|
||||
@ -379,14 +380,15 @@ f_device_get_all()
|
||||
); do
|
||||
f_quietly dumpfs -m /dev/$part ||
|
||||
continue
|
||||
f_device_capacity \
|
||||
"$/dev/$part" capacity
|
||||
f_device_register \
|
||||
"$part" "" "/dev/$part" \
|
||||
$DEVICE_TYPE_UFS 1 \
|
||||
f_media_init_ufs \
|
||||
f_media_get_ufs \
|
||||
f_media_shutdown_ufs "" \
|
||||
"$( f_device_capacity \
|
||||
"$/dev/$part" )"
|
||||
"$capacity"
|
||||
f_dprintf "Found a UFS partition %s" \
|
||||
"$part"
|
||||
done # parts
|
||||
@ -1007,8 +1009,9 @@ f_network "xe" "Xircom/Intel EtherExpress Pro100/16 Ethernet card"
|
||||
f_network "xl" "3COM 3c90x / 3c90xB PCI Ethernet card"
|
||||
f_network "zyd" "ZyDAS ZD1211/ZD1211B USB 802.11 wireless adapter"
|
||||
|
||||
f_count NDEVICES $DEVICE_NAMES
|
||||
f_dprintf "%s: Initialized %u known device names/descriptions." device.subr \
|
||||
"$( set -- $DEVICE_NAMES; echo $# )"
|
||||
$NDEVICES
|
||||
|
||||
#
|
||||
# Scan for the above devices unless requeted otherwise
|
||||
|
@ -296,6 +296,7 @@ f_dialog_backtitle_restore()
|
||||
#
|
||||
f_dialog_max_size()
|
||||
{
|
||||
local funcname=f_dialog_max_size
|
||||
local __var_height="$1" __var_width="$2" __max_size
|
||||
[ "$__var_height" -o "$__var_width" ] || return $FAILURE
|
||||
if [ "$USE_XDIALOG" ]; then
|
||||
@ -304,11 +305,14 @@ f_dialog_max_size()
|
||||
if __max_size=$( $DIALOG --print-maxsize \
|
||||
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD )
|
||||
then
|
||||
f_dprintf "$funcname: %s --print-maxsize = [%s]" \
|
||||
"$DIALOG" "$__max_size"
|
||||
# usually "MaxSize: 24, 80"
|
||||
__max_size="${__max_size#*: }"
|
||||
f_replaceall "$__max_size" "," "" __max_size
|
||||
else
|
||||
__max_size=$( stty size 2> /dev/null )
|
||||
f_eval_catch -dk __max_size $funcname stty \
|
||||
'stty size' || __max_size=
|
||||
# usually "24 80"
|
||||
fi
|
||||
: ${__max_size:=$DEFAULT_TERMINAL_SIZE}
|
||||
@ -2052,6 +2056,8 @@ f_dialog_menutag2index_with_help()
|
||||
#
|
||||
f_dialog_init()
|
||||
{
|
||||
local funcname=f_dialog_init
|
||||
|
||||
DIALOG_SELF_INITIALIZE=
|
||||
USE_DIALOG=1
|
||||
|
||||
@ -2140,7 +2146,7 @@ f_dialog_init()
|
||||
DIALOG=dialog
|
||||
f_die 1 "$msg_no_such_file_or_directory" "$pgm" "xauth"
|
||||
fi
|
||||
HOSTNAME=$(hostname)
|
||||
HOSTNAME=$( hostname )
|
||||
local displaynum="${DISPLAY#*:}"
|
||||
eval xauth -if \~$SUDO_USER/.Xauthority extract - \
|
||||
\"\$HOSTNAME/unix:\$displaynum\" \
|
||||
@ -2154,7 +2160,8 @@ f_dialog_init()
|
||||
#
|
||||
if [ "$USE_XDIALOG" ]; then
|
||||
local maxsize
|
||||
if ! maxsize=$( LANG= LC_ALL= $DIALOG --print-maxsize 2>&1 )
|
||||
if ! f_eval_catch -dk maxsize $funcname "$DIALOG" \
|
||||
'LANG= LC_ALL= %s --print-maxsize' "$DIALOG"
|
||||
then
|
||||
# Xdialog(1) failed, fall back to dialog(1)
|
||||
unset USE_XDIALOG
|
||||
|
@ -44,6 +44,7 @@ f_include $BSDCFG_SHARE/struct.subr
|
||||
############################################################ GLOBALS
|
||||
|
||||
KEYMAPS=
|
||||
NKEYMAPS=0
|
||||
|
||||
# A "keymap" from kbdmap's point of view
|
||||
f_struct_define KEYMAP \
|
||||
@ -254,8 +255,8 @@ case "$KEYMAP_SELF_SCAN_ALL" in
|
||||
*) f_keymap_get_all
|
||||
esac
|
||||
|
||||
f_dprintf "%s: Found %u keymap file(s)." keymap.subr \
|
||||
"$( set -- $KEYMAPS; echo $# )"
|
||||
f_count NKEYMAPS $KEYMAPS
|
||||
f_dprintf "%s: Found %u keymap file(s)." keymap.subr $NKEYMAPS
|
||||
|
||||
f_dprintf "%s: Successfully loaded." keymap.subr
|
||||
|
||||
|
@ -58,7 +58,7 @@ f_media_set_cdrom()
|
||||
|
||||
local devs ndevs
|
||||
f_device_find "" $DEVICE_TYPE_CDROM devs
|
||||
ndevs=$( set -- $devs; echo $# )
|
||||
f_count ndevs $devs
|
||||
|
||||
if [ ${ndevs:=0} -eq 0 ]; then
|
||||
f_interactive && f_show_msg "$msg_no_cd_dvd_devices_found"
|
||||
@ -95,6 +95,7 @@ f_media_set_cdrom()
|
||||
#
|
||||
f_media_init_cdrom()
|
||||
{
|
||||
local funcname=f_media_init_cdrom
|
||||
local dev="$1" devname err
|
||||
|
||||
device_$dev get devname devname || return $FAILURE
|
||||
@ -106,14 +107,13 @@ f_media_init_cdrom()
|
||||
return $SUCCESS
|
||||
fi
|
||||
|
||||
if [ ! -e "$MOUNTPOINT" ] &&
|
||||
! err=$( mkdir -p "$MOUNTPOINT" 2>&1 )
|
||||
then
|
||||
f_dialog_msgbox "$err"
|
||||
return $FAILURE
|
||||
if [ ! -e "$MOUNTPOINT" ]; then
|
||||
f_eval_catch $funcname mkdir 'mkdir -p "%s"' "$MOUNTPOINT" ||
|
||||
return $FAILURE
|
||||
fi
|
||||
|
||||
if ! err=$( mount_cd9660 "$devname" "$MOUNTPOINT" 2>&1 )
|
||||
if ! f_eval_catch -dk err $funcname mount_cd9660 \
|
||||
'mount_cd9660 "%s" "%s"' "$devname" "$MOUNTPOINT"
|
||||
then
|
||||
err="${err#mount_cd9660: }"; err="${err#$devname: }"
|
||||
case "$err" in
|
||||
@ -167,6 +167,7 @@ f_media_get_cdrom()
|
||||
#
|
||||
f_media_shutdown_cdrom()
|
||||
{
|
||||
local funcname=f_media_shutdown_cdrom
|
||||
local dev="$1" err
|
||||
|
||||
[ "$CDROM_MOUNTED" ] || return $FAILURE
|
||||
@ -176,7 +177,9 @@ f_media_shutdown_cdrom()
|
||||
return $SUCCESS
|
||||
fi
|
||||
|
||||
if ! err=$( umount -f "$MOUNTPOINT" 2>&1 ); then
|
||||
if ! f_eval_catch -dk err $funcname umount \
|
||||
'umount -f "%s"' "$MOUNPOINT"
|
||||
then
|
||||
err="${err#umount: }"; err="${err#*: }"
|
||||
f_show_msg "$msg_could_not_unmount_the_cdrom_dvd" \
|
||||
"$MOUNTPOINT" "$err"
|
||||
@ -191,11 +194,14 @@ f_media_shutdown_cdrom()
|
||||
#
|
||||
f_media_eject_cdrom()
|
||||
{
|
||||
local funcname=f_media_eject_cdrom
|
||||
local dev="$1" devname err
|
||||
device_$dev get name devname || return $SUCCESS
|
||||
case "$devname" in /dev/iso9660/*) return $SUCCESS; esac
|
||||
f_dprintf "Ejecting CDROM/DVD at %s" "$devname"
|
||||
if ! err=$( cdcontrol -f "$devname" eject 2>&1 ); then
|
||||
if ! f_eval_catch -dk err $funcname cdcontrol \
|
||||
'cdcontrol -f "%s" eject' "$devname"
|
||||
then
|
||||
f_dprintf "Could not eject the CDROM/DVD from %s: %s" \
|
||||
"$devname" "${err#cdcontrol: }"
|
||||
fi
|
||||
|
@ -99,6 +99,7 @@ f_media_verify()
|
||||
#
|
||||
f_media_generic_get()
|
||||
{
|
||||
local funcname=f_media_generic_get
|
||||
local base="$1" file="$2" probe_type="$3"
|
||||
|
||||
local fname=f_media_generic_get
|
||||
@ -117,13 +118,10 @@ f_media_generic_get()
|
||||
f_dprintf "%s: file exists path=[%s]" $fname "$path"
|
||||
if [ "$probe_type" = "$PROBE_SIZE" ]; then
|
||||
local size
|
||||
if ! size=$( stat -f %z "$path" 2>&1 ); then
|
||||
f_dprintf "stat: %s" "$size"
|
||||
echo "-1"
|
||||
else
|
||||
f_isinteger "$size" || size=-1
|
||||
echo $size
|
||||
fi
|
||||
f_eval_catch -dk size $funcname stat \
|
||||
'stat -f %%z "%s"' "$path" || size=-1
|
||||
f_isinteger "$size" || size=-1
|
||||
echo $size
|
||||
fi
|
||||
[ "$probe_type" ] && return $SUCCESS
|
||||
cat "$path"
|
||||
@ -136,13 +134,10 @@ f_media_generic_get()
|
||||
f_dprintf "%s: file exists path=[%s]" $fname "$path"
|
||||
if [ "$probe_type" = "$PROBE_SIZE" ]; then
|
||||
local size
|
||||
if ! size=$( stat -f %z "$path" 2>&1 ); then
|
||||
f_dprintf "stat: %s" "$size"
|
||||
echo "-1"
|
||||
else
|
||||
f_isinteger "$size" || size=-1
|
||||
echo $size
|
||||
fi
|
||||
f_eval_catch -dk size $funcname stat \
|
||||
'stat -f %%z "%s"' "$path" || size=-1
|
||||
f_isinteger "$size" || size=-1
|
||||
echo $size
|
||||
fi
|
||||
[ "$probe_type" ] && return $SUCCESS
|
||||
elif [ "$probe_type" ]; then
|
||||
|
@ -56,7 +56,7 @@ f_media_set_dos()
|
||||
|
||||
local devs ndevs
|
||||
f_device_find "" $DEVICE_TYPE_DOS devs
|
||||
ndevs=$( set -- $devs; echo $# )
|
||||
f_count ndevs $devs
|
||||
|
||||
if [ ${ndevs:=0} -eq 0 ]; then
|
||||
f_show_msg "$msg_no_dos_primary_partitions_found"
|
||||
@ -93,6 +93,7 @@ f_media_set_dos()
|
||||
#
|
||||
f_media_init_dos()
|
||||
{
|
||||
local funcname=f_media_init_dos
|
||||
local dev="$1" devname err
|
||||
|
||||
device_$dev get devname devname || return $FAILURE
|
||||
@ -104,14 +105,13 @@ f_media_init_dos()
|
||||
return $SUCCESS
|
||||
fi
|
||||
|
||||
if [ ! -e "$MOUNTPOINT" ] &&
|
||||
! err=$( mkdir -p "$MOUNTPOINT" 2>&1 )
|
||||
then
|
||||
f_dialog_msgbox "$err"
|
||||
return $FAILURE
|
||||
if [ ! -e "$MOUNTPOINT" ]; then
|
||||
f_eval_catch $funcname mkdir 'mkdir -p "%s"' "$MOUNTPOINT" ||
|
||||
return $FAILURE
|
||||
fi
|
||||
|
||||
if ! err=$( mount_msdosfs "$devname" "$MOUNTPOINT" 2>&1 )
|
||||
if ! f_eval_catch -dk err $funcname mount_msdosfs \
|
||||
'mount_msdosfs "%s" "%s"' "$devname" "$MOUNTPOINT"
|
||||
then
|
||||
err="${err#mount_msdosfs: }"; err="${err#$devname: }"
|
||||
f_show_msg "$msg_error_mounting_device" \
|
||||
@ -146,11 +146,14 @@ f_media_get_dos()
|
||||
#
|
||||
f_media_shutdown_dos()
|
||||
{
|
||||
local funcname=f_media_shutdown_dos
|
||||
local dev="$1" err
|
||||
|
||||
[ "$DOS_MOUNTED" ] || return $FAILURE
|
||||
|
||||
if ! err=$( umount -f "$MOUNTPOINT" 2>&1 ); then
|
||||
if ! f_eval_catch -dk err $funcname umount \
|
||||
'umount -f "%s"' "$MOUNTPOINT"
|
||||
then
|
||||
err="${err#umount: }"; err="${err#*: }"
|
||||
f_show_msg "$msg_could_not_unmount_the_dos_partition" \
|
||||
"$MOUNTPOINT" "$err"
|
||||
|
@ -57,7 +57,7 @@ f_media_set_floppy()
|
||||
|
||||
local devs ndevs
|
||||
f_device_find "" $DEVICE_TYPE_FLOPPY devs
|
||||
ndevs=$( set -- $devs; echo $# )
|
||||
f_count ndevs $devs
|
||||
|
||||
if [ ${ndevs:=0} -eq 0 ]; then
|
||||
f_interactive && f_show_msg "$msg_no_floppy_devices_found"
|
||||
@ -98,6 +98,7 @@ f_media_set_floppy()
|
||||
#
|
||||
f_media_init_floppy()
|
||||
{
|
||||
local funcname=f_media_init_floppy
|
||||
local dev="$1" devname err
|
||||
|
||||
device_$dev get devname devname || return $FAILURE
|
||||
@ -129,8 +130,11 @@ f_media_init_floppy()
|
||||
fi
|
||||
|
||||
if ! {
|
||||
f_quietly mount_msdosfs -o ro -m 0777 -u 0 -g 0 "$devname" "$mp" ||
|
||||
err=$( mount -o ro "$devname" "$mp" 2>&1 )
|
||||
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
|
||||
@ -153,6 +157,7 @@ f_media_init_floppy()
|
||||
#
|
||||
f_media_get_floppy()
|
||||
{
|
||||
local funcname=f_media_get_floppy
|
||||
local dev="$1" file="$2" probe_type="$3"
|
||||
|
||||
f_dprintf "f_media_get_floppy: dev=[%s] file=[%s] probe_type=%s" \
|
||||
@ -188,7 +193,7 @@ f_media_get_floppy()
|
||||
#
|
||||
if [ "$probe_type" = "$PROBE_SIZE" ]; then
|
||||
local size
|
||||
size=$( stat -f %z "$fp" 2>&1 ) || f_dprintf "stat: %s" "$size"
|
||||
f_eval_catch -dk size $funcname stat 'stat -f %%z "%s"' "$fp"
|
||||
f_isinteger "$size" || size=-1
|
||||
echo "$size"
|
||||
fi
|
||||
@ -203,15 +208,15 @@ f_media_get_floppy()
|
||||
#
|
||||
f_media_shutdown_floppy()
|
||||
{
|
||||
local funcname=f_media_shutdown_floppy
|
||||
local dev="$1" err mp
|
||||
|
||||
[ "$FLOPPY_MOUNTED" ] || return $FAILURE
|
||||
|
||||
device_$dev get private mp
|
||||
if ! err=$( umount -f "${mp:=$MOUNTPOINT}" 2>&1 ); then
|
||||
err="${err#umount: }"; err="${err#*:}"
|
||||
f_dprintf "Umount of floppy on %s failed: %s" "$mp" "$err"
|
||||
else
|
||||
if f_eval_catch -d $funcname umount \
|
||||
'umount -f "%s"' "${mp:=$MOUNTPOINT}"
|
||||
then
|
||||
FLOPPY_MOUNTED=
|
||||
if f_interactive && [ "$_systemState" != "fixit" ]; then
|
||||
local desc
|
||||
|
@ -794,6 +794,7 @@ f_media_init_ftp()
|
||||
#
|
||||
f_media_get_ftp()
|
||||
{
|
||||
local funcname=f_media_get_ftp
|
||||
local dev="$1" file="$2" probe_type="$3" hosts=
|
||||
|
||||
f_dprintf "f_media_get_ftp: dev=[%s] file=[%s] probe_type=%s" \
|
||||
@ -870,9 +871,10 @@ f_media_get_ftp()
|
||||
if [ "$probe_type" ]; then
|
||||
local url="ftp://$userpass$host$port/$dir/$file" size
|
||||
[ "$use_anon" ] && url="ftp://$host$port/$dir/$file"
|
||||
if ! size=$( fetch -s "$url" 2>&1 ) || ! f_isinteger "$size"
|
||||
if ! f_eval_catch -dk size $funcname fetch \
|
||||
'fetch -s "%s"' "$url" || ! f_isinteger "$size"
|
||||
then
|
||||
f_dprintf "request failed! size response=[%s]" "$size"
|
||||
f_dprintf "size request failed!"
|
||||
[ "$probe_type" = "$PROBE_SIZE" ] && echo "-1"
|
||||
return $FAILURE
|
||||
fi
|
||||
|
@ -154,6 +154,7 @@ f_media_set_nfs()
|
||||
#
|
||||
f_media_init_nfs()
|
||||
{
|
||||
local funcname=f_media_init_nfs
|
||||
local dev="$1" name err
|
||||
|
||||
device_$dev get name name || return $FAILURE
|
||||
@ -170,11 +171,9 @@ f_media_init_nfs()
|
||||
return $FAILURE
|
||||
fi
|
||||
|
||||
if [ ! -e "$MOUNTPOINT" ] &&
|
||||
! err=$( mkdir -p "$MOUNTPOINT" 2>&1 )
|
||||
then
|
||||
f_dialog_msgbox "$err"
|
||||
return $FAILURE
|
||||
if [ ! -e "$MOUNTPOINT" ]; then
|
||||
f_eval_catch $funcname mkdir 'mkdir -p "%s"' "$MOUNTPOINT" ||
|
||||
return $FAILURE
|
||||
fi
|
||||
|
||||
local cp tcp="" use3="" secure="" readsize=4096 writesize=4096
|
||||
@ -191,8 +190,9 @@ f_media_init_nfs()
|
||||
[ "$use3" ] && options="$options,nfsv3"
|
||||
[ "$tcp" ] && options="$options,tcp"
|
||||
|
||||
if ! err=$( mount_nfs \
|
||||
${secure:+-P} -o "$options" "$name" "$MOUNTPOINT" 2>&1 )
|
||||
if ! f_eval_catch -dk err $funcname mount_nfs \
|
||||
'mount_nfs %s -o "%s" "%s" "%s"' \
|
||||
"${secure:+-P}" "$options" "$name" "$MOUNTPOINT"
|
||||
then
|
||||
err="${err#mount_nfs: }"
|
||||
f_show_msg "$msg_error_mounting_device" \
|
||||
@ -231,12 +231,15 @@ f_media_get_nfs()
|
||||
#
|
||||
f_media_shutdown_nfs()
|
||||
{
|
||||
local funcname=f_media_shutdown_nfs
|
||||
local dev="$1" err
|
||||
|
||||
[ "$NFS_MOUNTED" ] || return $FAILURE
|
||||
|
||||
f_dprintf "Unmounting NFS partition on %s" "$MOUNTPOINT"
|
||||
if ! err=$( umount -f "$MOUNTPOINT" 2>&1 ); then
|
||||
if ! f_eval_catch -dk err $funcname umount \
|
||||
'umount -f "%s"' "$MOUNTPOINT"
|
||||
then
|
||||
err="${err#umount: }"; err="${err#*: }"
|
||||
f_show_msg "$msg_could_not_unmount_the_nfs_partition" \
|
||||
"$MOUNTPOINT" "$err"
|
||||
|
@ -33,6 +33,7 @@ BSDCFG_SHARE="/usr/share/bsdconfig"
|
||||
f_dprintf "%s: loading includes..." media/tcpip.subr
|
||||
f_include $BSDCFG_SHARE/device.subr
|
||||
f_include $BSDCFG_SHARE/dialog.subr
|
||||
f_include $BSDCFG_SHARE/strings.subr
|
||||
f_include $BSDCFG_SHARE/struct.subr
|
||||
f_include $BSDCFG_SHARE/variable.subr
|
||||
|
||||
@ -168,8 +169,9 @@ f_inet_atoi()
|
||||
{
|
||||
local __addr="$1" __var_to_set="$2" __num=0
|
||||
if f_validate_ipaddr "$__addr"; then
|
||||
__num=$( IFS=.; set -- $__addr; \
|
||||
echo $(( ($1 << 24) + ($2 << 16) + ($3 << 8) + $4 )) )
|
||||
IFS=.
|
||||
set -- $__addr
|
||||
__num=$(( ($1 << 24) + ($2 << 16) + ($3 << 8) + $4 ))
|
||||
fi
|
||||
if [ "$__var_to_set" ]; then
|
||||
setvar "$__var_to_set" $__num
|
||||
@ -574,7 +576,7 @@ f_ifconfig_netmask()
|
||||
|
||||
local __octet __netmask=
|
||||
for __octet in $__octets; do
|
||||
__netmask="$__netmask.$( printf "%u" "0x$__octet" )"
|
||||
f_sprintf __netmask "%s.%u" "$__netmask" "0x$__octet"
|
||||
done
|
||||
__netmask="${__netmask#.}"
|
||||
if [ "$__var_to_set" ]; then
|
||||
@ -1035,10 +1037,11 @@ f_host_lookup()
|
||||
|
||||
# Calculate wait time as dividend of total time and host(1) invocations
|
||||
local __host_runs __wait
|
||||
f_count __host_runs $__srvtypes
|
||||
if [ "$__ip6" = "YES" ]; then
|
||||
__host_runs=$(( 2 + $( set -- $__srvtypes; echo $# ) ))
|
||||
__host_runs=$(( $__host_runs + 2 ))
|
||||
else
|
||||
__host_runs=$(( 1 + $( set -- $__srvtypes; echo $# ) ))
|
||||
__host_runs=$(( $__host_runs + 1 ))
|
||||
fi
|
||||
f_getvar $VAR_MEDIA_TIMEOUT __wait
|
||||
[ "$__wait" ] && __wait="-W $(( $__wait / $__host_runs ))"
|
||||
@ -1614,7 +1617,7 @@ f_device_select_tcp()
|
||||
esac
|
||||
|
||||
f_device_find "$dev" $DEVICE_TYPE_NETWORK devs
|
||||
cnt=$( set -- $devs; echo $# )
|
||||
f_count cnt $devs
|
||||
|
||||
if [ ${cnt:=0} -gt 0 ]; then
|
||||
dev="${devs%%[$IFS]*}"
|
||||
@ -1632,7 +1635,7 @@ f_device_select_tcp()
|
||||
fi # $network_dev
|
||||
|
||||
f_device_find "" $DEVICE_TYPE_NETWORK devs
|
||||
cnt=$( set -- $devs; echo $# )
|
||||
f_count cnt $devs
|
||||
dev="${devs%%[$IFS]*}"
|
||||
|
||||
f_quietly f_getvar NETWORK_CONFIGURED # for debugging info
|
||||
|
@ -67,7 +67,7 @@ f_media_set_ufs()
|
||||
|
||||
local devs ndevs
|
||||
f_device_find "" $DEVICE_TYPE_UFS devs
|
||||
ndevs=$( set -- $devs; echo $# )
|
||||
f_count ndevs $devs
|
||||
|
||||
if [ ${ndevs:=0} -eq 0 ]; then
|
||||
f_variable_get_value $VAR_UFS_PATH \
|
||||
@ -117,6 +117,7 @@ f_media_set_ufs()
|
||||
#
|
||||
f_media_init_ufs()
|
||||
{
|
||||
local funcname=f_media_init_ufs
|
||||
local dev="$1" devname err
|
||||
|
||||
device_$dev get devname devname || return $FAILURE
|
||||
@ -134,14 +135,13 @@ f_media_init_ufs()
|
||||
return $FAILURE
|
||||
fi
|
||||
|
||||
if [ ! -e "$MOUNTPOINT" ] &&
|
||||
! err=$( mkdir -p "$MOUNTPOINT" 2>&1 )
|
||||
then
|
||||
f_dialog_msgbox "$err"
|
||||
return $FAILURE
|
||||
if [ ! -e "$MOUNTPOINT" ]; then
|
||||
f_eval_catch $funcname mkdir 'mkdir -p "%s"' "$MOUNTPOINT" ||
|
||||
return $FAILURE
|
||||
fi
|
||||
|
||||
if ! err=$( mount "$devname" "$MOUNTPOINT" 2>&1 )
|
||||
if ! f_eval_catch -dk err $funcname mount \
|
||||
'mount "%s" "%s"' "$devname" "$MOUNTPOINT"
|
||||
then
|
||||
err="${err#mount: }"; err="${err#$devname : }"
|
||||
f_show_msg "$msg_error_mounting_device" \
|
||||
@ -175,11 +175,14 @@ f_media_get_ufs()
|
||||
#
|
||||
f_media_shutdown_ufs()
|
||||
{
|
||||
local funcname=f_media_shutdown_ufs
|
||||
local dev="$1" err
|
||||
|
||||
[ "$UFS_MOUNTED" ] || return $FAILURE
|
||||
|
||||
if ! err=$( umount -f "$MOUNTPOINT" 2>&1 ); then
|
||||
if ! f_eval_catch -dk err $funcname umount \
|
||||
'umount -f "%s"' "$MOUNTPOINT"
|
||||
then
|
||||
err="${err#umount: }"; err="${err#*: }"
|
||||
f_show_msg "$msg_could_not_unmount_the_ufs_partition" \
|
||||
"$MOUNTPOINT" "$err"
|
||||
|
@ -57,7 +57,7 @@ f_media_set_usb()
|
||||
|
||||
local devs ndevs
|
||||
f_device_find "" $DEVICE_TYPE_USB devs
|
||||
ndevs=$( set -- $devs; echo $# )
|
||||
f_count ndevs $devs
|
||||
|
||||
if [ ${ndevs:=0} -eq 0 ]; then
|
||||
f_show_msg "$msg_no_usb_devices_found"
|
||||
@ -103,6 +103,7 @@ f_media_set_usb()
|
||||
#
|
||||
f_media_init_usb()
|
||||
{
|
||||
local funcname=f_media_init_usb
|
||||
local dev="$1" devname err
|
||||
|
||||
device_$dev get devname devname || return $FAILURE
|
||||
@ -114,14 +115,14 @@ f_media_init_usb()
|
||||
return $SUCCESS
|
||||
fi
|
||||
|
||||
if [ ! -e "$MOUNTPOINT" ] &&
|
||||
! err=$( mkdir -p "$MOUNTPOINT" 2>&1 )
|
||||
then
|
||||
f_dialog_msgbox "$err"
|
||||
return $FAILURE
|
||||
if [ ! -e "$MOUNTPOINT" ]; then
|
||||
f_eval_catch $funcname mkdir 'mkdir -p "%s"' "$MOUNTPOINT" ||
|
||||
return $FAILURE
|
||||
fi
|
||||
|
||||
if err=$( mount "$devname" "$MOUNTPOINT" 2>&1 ); then
|
||||
if f_eval_catch -dk err $funcname mount \
|
||||
'mount "%s" "%s"' "$devname" "$MOUNTPOINT"
|
||||
then
|
||||
USB_MOUNTED=1
|
||||
return $SUCCESS
|
||||
fi
|
||||
@ -156,11 +157,14 @@ f_media_get_usb()
|
||||
#
|
||||
f_media_shutdown_usb()
|
||||
{
|
||||
local funcname=f_media_shutdown_usb
|
||||
local dev="$1" err
|
||||
|
||||
[ "$USB_MOUNTED" ] || return $FAILURE
|
||||
|
||||
if ! err=$( umount -f "$MOUNTPOINT" 2>&1 ); then
|
||||
if ! f_eval_catch -dk err $funcname umount \
|
||||
'umount -f "%s"' "$MOUNTPOINT"
|
||||
then
|
||||
err="${err#umount: }"; err="${err#*: }"
|
||||
f_show_msg "$msg_could_not_unmount_the_ufs_partition" \
|
||||
"$MOUNTPOINT" "$err"
|
||||
|
@ -32,6 +32,7 @@ BSDCFG_SHARE="/usr/share/bsdconfig"
|
||||
. $BSDCFG_SHARE/common.subr || exit 1
|
||||
f_dprintf "%s: loading includes..." mustberoot.subr
|
||||
f_include $BSDCFG_SHARE/dialog.subr
|
||||
f_include $BSDCFG_SHARE/strings.subr
|
||||
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig"
|
||||
f_include_lang $BSDCFG_LIBE/include/messages.subr
|
||||
@ -77,6 +78,7 @@ SECURE_DIVULGE_UNKNOWN_USER=
|
||||
#
|
||||
f_become_root_via_sudo()
|
||||
{
|
||||
local funcname=f_become_root_via_sudo
|
||||
local prompt hline height width rows msg
|
||||
|
||||
[ "$( id -u )" = "0" ] && return $SUCCESS
|
||||
@ -90,8 +92,8 @@ f_become_root_via_sudo()
|
||||
#
|
||||
local checkpath="${HOME%/}/.bsdconfig_uses_sudo"
|
||||
if [ ! -e "$checkpath" ]; then
|
||||
prompt=$( printf "$msg_you_are_not_root_but" bsdconfig )
|
||||
msg=$( printf "$msg_always_try_sudo_when_run_as" "$USER" )
|
||||
f_sprintf prompt "$msg_you_are_not_root_but" bsdconfig
|
||||
f_sprintf msg "$msg_always_try_sudo_when_run_as" "$USER"
|
||||
local menu_list="
|
||||
'X' '$msg_cancel_exit'
|
||||
'1' '$msg'
|
||||
@ -124,12 +126,9 @@ f_become_root_via_sudo()
|
||||
X) # Cancel/Exit
|
||||
f_die ;;
|
||||
1) # Always try sudo(8) when run as $user
|
||||
local err
|
||||
if ! err=$( touch "$checkpath" 2>&1 ); then
|
||||
f_dialog_msgbox "$err"
|
||||
else
|
||||
f_eval_catch $funcname touch \
|
||||
'touch "%s"' "$checkpath" &&
|
||||
f_show_msg "$msg_created_path" "$checkpath"
|
||||
fi
|
||||
esac
|
||||
else
|
||||
#
|
||||
@ -225,7 +224,7 @@ f_become_root_via_sudo()
|
||||
# the security event and exit immediately.
|
||||
#
|
||||
if [ $nfailures -ge $PASSWD_TRIES ]; then
|
||||
msg=$( printf "$msg_nfailed_attempts" "$nfailures" )
|
||||
f_sprintf msg "$msg_nfailed_attempts" "$nfailures"
|
||||
logger -p auth.notice -t sudo " " \
|
||||
"$USER : $msg" \
|
||||
"; TTY=$(tty)" \
|
||||
@ -387,7 +386,7 @@ f_authenticate_some_user()
|
||||
# the security event and exit immediately.
|
||||
#
|
||||
if [ $nfailures -ge $PASSWD_TRIES ]; then
|
||||
msg=$( printf "$msg_nfailed_attempts" "$nfailures" )
|
||||
f_sprintf msg "$msg_nfailed_attempts" "$nfailures"
|
||||
logger -p auth.notice -t sudo " " \
|
||||
"${SUDO_USER:-$USER} : $msg" \
|
||||
"; TTY=$(tty)" \
|
||||
|
@ -39,6 +39,7 @@ f_include_lang $BSDCFG_LIBE/include/messages.subr
|
||||
############################################################ GLOBALS
|
||||
|
||||
CATEGORIES=
|
||||
NCATEGORIES=0
|
||||
|
||||
############################################################ FUNCTIONS
|
||||
|
||||
@ -199,8 +200,9 @@ f_category x11-wm "$msg_x11_wm_desc"
|
||||
f_category xfce "$msg_xfce_desc"
|
||||
f_category zope "$msg_zope_desc"
|
||||
|
||||
f_count NCATEGORIES $CATEGORIES
|
||||
f_dprintf "%s: Initialized %u package category descriptions." \
|
||||
packages/categories.subr "$( set -- $CATEGORIES; echo $# )"
|
||||
packages/categories.subr $NCATEGORIES
|
||||
|
||||
f_dprintf "%s: Successfully loaded." packages/categories.subr
|
||||
|
||||
|
@ -245,17 +245,21 @@ f_index_initialize()
|
||||
#
|
||||
|
||||
# Create a new temporary file to write to
|
||||
local __tmpfile="$( mktemp -t "$pgm" )"
|
||||
if [ "$__tmpfile" ]; then
|
||||
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_quietly mkdir -p "${PACKAGES_INDEX_CACHEFILE%/*}"
|
||||
*/*) f_eval_catch -d $funcname mkdir \
|
||||
'mkdir -p "%s"' "${PACKAGES_INDEX_CACHEFILE%/*}"
|
||||
esac
|
||||
f_quietly mv -f "$__tmpfile" "$PACKAGES_INDEX_CACHEFILE"
|
||||
f_eval_catch -d $__funcname mv 'mv -f "%s" "%s"' \
|
||||
"$__tmpfile" "$PACKAGES_INDEX_CACHEFILE"
|
||||
fi
|
||||
|
||||
f_show_info "$msg_located_index_now_reading_package_data_from_it"
|
||||
|
@ -472,8 +472,7 @@ f_package_menu_select()
|
||||
"$msg_all"|"") f_category_desc_get "All" prompt ;;
|
||||
*) f_category_desc_get "$category" prompt ;;
|
||||
esac
|
||||
prompt="$prompt $( printf "$msg_page_of_npages" \
|
||||
"$page" "$npages" )"
|
||||
f_sprintf prompt "%s $msg_page_of_npages" "$prompt" "$page" "$npages"
|
||||
|
||||
local mheight mwidth mrows
|
||||
eval f_dialog_menu${SHOW_DESC:+_with_help}_size mheight mwidth mrows \
|
||||
@ -536,7 +535,7 @@ f_package_menu_deselect()
|
||||
" # End-Quote
|
||||
local hline="$hline_alnum_arrows_punc_tab_enter"
|
||||
|
||||
prompt=$( printf "$msg_what_would_you_like_to_do_with" "$package" )
|
||||
f_sprintf prompt "$msg_what_would_you_like_to_do_with" "$package"
|
||||
|
||||
local height width rows
|
||||
eval f_dialog_menu_size height width rows \
|
||||
@ -578,7 +577,7 @@ f_package_review()
|
||||
|
||||
f_dprintf "$funcname: SELECTED_PACKAGES=[%s]" "$SELECTED_PACKAGES"
|
||||
|
||||
prompt=$( printf "$msg_reviewing_selected_packages" "$_All_nselected" )
|
||||
f_sprintf prompt "$msg_reviewing_selected_packages" "$_All_nselected"
|
||||
|
||||
local package varpkg mark
|
||||
for package in $SELECTED_PACKAGES; do
|
||||
|
@ -188,15 +188,8 @@ f_number_of_lines()
|
||||
#
|
||||
f_isinteger()
|
||||
{
|
||||
local arg="$1"
|
||||
|
||||
# Prevent division-by-zero
|
||||
[ "$arg" = "0" ] && return $SUCCESS
|
||||
|
||||
# Attempt to perform arithmetic divison (an operation which will exit
|
||||
# with error unless arg is a valid positive/negative whole integer).
|
||||
#
|
||||
( : $((0/$arg)) ) > /dev/null 2>&1
|
||||
local arg="${1#-}"
|
||||
[ "${arg:-x}" = "${arg#[!0-9]*}" ]
|
||||
}
|
||||
|
||||
# f_uriencode [$text]
|
||||
|
@ -428,6 +428,7 @@ END { exit retval }
|
||||
'
|
||||
f_sysrc_set()
|
||||
{
|
||||
local funcname=f_sysrc_set
|
||||
local varname="$1" new_value="$2"
|
||||
|
||||
# Check arguments
|
||||
@ -478,8 +479,12 @@ f_sysrc_set()
|
||||
#
|
||||
# Create a new temporary file to write to.
|
||||
#
|
||||
local tmpfile="$( mktemp -t "$pgm" )"
|
||||
[ "$tmpfile" ] || return $FAILURE
|
||||
local tmpfile
|
||||
if ! f_eval_catch -dk tmpfile $funcname mktemp 'mktemp -t "%s"' "$pgm"
|
||||
then
|
||||
echo "$tmpfile" >&2
|
||||
return $FAILURE
|
||||
fi
|
||||
|
||||
#
|
||||
# Fixup permissions (else we're in for a surprise, as mktemp(1) creates
|
||||
@ -488,8 +493,9 @@ f_sysrc_set()
|
||||
# permissions from the temporary file).
|
||||
#
|
||||
local mode
|
||||
mode=$( stat -f '%#Lp' "$file" 2> /dev/null )
|
||||
f_quietly chmod "${mode:-0644}" "$tmpfile"
|
||||
f_eval_catch -dk mode $funcname stat 'stat -f "%%#Lp" "%s"' "$file" ||
|
||||
mode=0644
|
||||
f_eval_catch -d $funcname chmod 'chmod "%s" "%s"' "$mode" "$tmpfile"
|
||||
|
||||
#
|
||||
# Fixup ownership. The destination file _is_ writable (we tested
|
||||
@ -497,8 +503,9 @@ f_sysrc_set()
|
||||
# permissions (so we throw stderr into the bit-bucket).
|
||||
#
|
||||
local owner
|
||||
owner=$( stat -f '%u:%g' "$file" 2> /dev/null )
|
||||
f_quietly chown "${owner:-root:wheel}" "$tmpfile"
|
||||
f_eval_catch -dk owner $funcname stat \
|
||||
'stat -f "%%u:%%g" "%s"' "$file" || owner="root:wheel"
|
||||
f_eval_catch -d $funcname chown 'chown "%s" "%s"' "$owner" "$tmpfile"
|
||||
|
||||
#
|
||||
# Operate on the matching file, replacing only the last occurrence.
|
||||
@ -520,7 +527,7 @@ f_sysrc_set()
|
||||
#
|
||||
# Taint-check our results.
|
||||
#
|
||||
if ! /bin/sh -n "$tmpfile"; then
|
||||
if ! f_eval_catch -d $funcname sh '/bin/sh -n "%s"' "$tmpfile"; then
|
||||
f_err "$msg_previous_syntax_errors\n" "$pgm" "$file"
|
||||
rm -f "$tmpfile"
|
||||
return $FAILURE
|
||||
@ -529,7 +536,7 @@ f_sysrc_set()
|
||||
#
|
||||
# Finally, move the temporary file into place.
|
||||
#
|
||||
mv "$tmpfile" "$file"
|
||||
f_eval_catch -de $funcname mv 'mv "%s" "%s"' "$tmpfile" "$file"
|
||||
}
|
||||
|
||||
# f_sysrc_delete $varname
|
||||
@ -560,6 +567,7 @@ END { exit ! found }
|
||||
'
|
||||
f_sysrc_delete()
|
||||
{
|
||||
local funcname=f_sysrc_delete
|
||||
local varname="$1"
|
||||
local file
|
||||
|
||||
@ -569,24 +577,33 @@ f_sysrc_delete()
|
||||
#
|
||||
# Operate on each of the specified files
|
||||
#
|
||||
local tmpfile
|
||||
for file in ${RC_CONFS-$( f_sysrc_get rc_conf_files )}; do
|
||||
[ -e "$file" ] || continue
|
||||
|
||||
#
|
||||
# Create a new temporary file to write to.
|
||||
#
|
||||
local tmpfile="$( mktemp -t "$pgm" )"
|
||||
[ "$tmpfile" ] || return $FAILURE
|
||||
if ! f_eval_catch -dk tmpfile $funcname mktemp \
|
||||
'mktemp -t "%s"' "$pgm"
|
||||
then
|
||||
echo "$tmpfile" >&2
|
||||
return $FAILURE
|
||||
fi
|
||||
|
||||
#
|
||||
# Fixup permissions and ownership (mktemp(1) defaults to 0600
|
||||
# permissions) to instead match the destination file.
|
||||
#
|
||||
local mode owner
|
||||
mode=$( stat -f '%#Lp' "$file" 2> /dev/null )
|
||||
owner=$( stat -f '%u:%g' "$file" 2> /dev/null )
|
||||
f_quietly chmod "${mode:-0644}" "$tmpfile"
|
||||
f_quietly chown "${owner:-root:wheel}" "$tmpfile"
|
||||
f_eval_catch -dk mode $funcname stat \
|
||||
'stat -f "%%#Lp" "%s"' "$file" || mode=0644
|
||||
f_eval_catch -dk owner $funcname stat \
|
||||
'stat -f "%%u:%%g" "%s"' "$file" || owner="root:wheel"
|
||||
f_eval_catch -d $funcname chmod \
|
||||
'chmod "%s" "%s"' "$mode" "$tmpfile"
|
||||
f_eval_catch -d $funcname chown \
|
||||
'chown "%s" "%s"' "$owner" "$tmpfile"
|
||||
|
||||
#
|
||||
# Operate on the file, removing all occurrences, saving the
|
||||
@ -603,7 +620,8 @@ f_sysrc_delete()
|
||||
#
|
||||
# Taint-check our results.
|
||||
#
|
||||
if ! /bin/sh -n "$tmpfile"; then
|
||||
if ! f_eval_catch -d $funcname sh '/bin/sh -n "%s"' "$tmpfile"
|
||||
then
|
||||
f_err "$msg_previous_syntax_errors\n" \
|
||||
"$pgm" "$file"
|
||||
rm -f "$tmpfile"
|
||||
@ -622,7 +640,8 @@ f_sysrc_delete()
|
||||
#
|
||||
# Finally, move the temporary file into place.
|
||||
#
|
||||
mv "$tmpfile" "$file"
|
||||
f_eval_catch -de $funcname mv \
|
||||
'mv "%s" "%s"' "$tmpfile" "$file" || return $FAILURE
|
||||
done
|
||||
}
|
||||
|
||||
|
@ -38,15 +38,8 @@ f_include $BSDCFG_SHARE/sysrc.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="140.startup"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
|
||||
############################################################ GLOBALS
|
||||
|
||||
#
|
||||
# Operating environment
|
||||
#
|
||||
UNAME_P=$( uname -p ) # Processor Architecture (i.e. i386)
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ FUNCTIONS
|
||||
|
||||
@ -346,87 +339,61 @@ while :; do
|
||||
|
||||
case "$mtag" in
|
||||
"X $msg_exit") break ;;
|
||||
?" [X] "*) toggled=1 ;;
|
||||
*) toggled=
|
||||
?" [X] "*) toggled=1 reverse=NO ;;
|
||||
*) toggled= reverse=YES
|
||||
esac
|
||||
|
||||
case "$mtag" in
|
||||
# Simple On/Off toggle bits
|
||||
?" ["?"] $msg_apm")
|
||||
if [ "$toggled" ]; then
|
||||
err=$( f_sysrc_set apm_enable NO 2>&1 )
|
||||
else
|
||||
err=$( f_sysrc_set apm_enable YES 2>&1 )
|
||||
fi
|
||||
;;
|
||||
f_eval_catch -dk err "$0" f_sysrc_set \
|
||||
'f_sysrc_set apm_enable "%s"' "$reverse" ;;
|
||||
?" ["?"] $msg_named")
|
||||
if [ "$toggled" ]; then
|
||||
err=$( f_sysrc_set named_enable NO 2>&1 )
|
||||
else
|
||||
err=$( f_sysrc_set named_enable YES 2>&1 )
|
||||
fi
|
||||
;;
|
||||
f_eval_catch -dk err "$0" f_sysrc_set \
|
||||
'f_sysrc_set named_enable "%s"' "$reverse" ;;
|
||||
?" ["?"] $msg_accounting")
|
||||
if [ "$toggled" ]; then
|
||||
err=$( f_sysrc_set accounting_enable NO 2>&1 )
|
||||
else
|
||||
err=$( f_sysrc_set accounting_enable YES 2>&1 )
|
||||
fi
|
||||
;;
|
||||
f_eval_catch -dk err "$0" f_sysrc_set \
|
||||
'f_sysrc_set accounting_enable "%s"' "$reverse" ;;
|
||||
?" ["?"] $msg_lpd")
|
||||
if [ "$toggled" ]; then
|
||||
err=$( f_sysrc_set lpd_enable NO 2>&1 )
|
||||
else
|
||||
err=$( f_sysrc_set lpd_enable YES 2>&1 )
|
||||
fi
|
||||
;;
|
||||
f_eval_catch -dk err "$0" f_sysrc_set \
|
||||
'f_sysrc_set lpd_enable "%s"' "$reverse" ;;
|
||||
?" ["?"] $msg_sco")
|
||||
if [ "$toggled" ]; then
|
||||
err=$( f_sysrc_set ibcs2_enable NO 2>&1 )
|
||||
else
|
||||
err=$( f_sysrc_set ibcs2_enable YES 2>&1 )
|
||||
fi
|
||||
;;
|
||||
f_eval_catch -dk err "$0" f_sysrc_set \
|
||||
'f_sysrc_set ibcs2_enable "%s"' "$reverse" ;;
|
||||
?" ["?"] $msg_svr4")
|
||||
if [ "$toggled" ]; then
|
||||
err=$( f_sysrc_set svr4_enable NO 2>&1 )
|
||||
else
|
||||
err=$( f_sysrc_set svr4_enable YES 2>&1 )
|
||||
fi
|
||||
;;
|
||||
f_eval_catch -dk err "$0" f_sysrc_set \
|
||||
'f_sysrc_set svr4_enable "%s"' "$reverse" ;;
|
||||
# Multi-variable On/Off toggle bits
|
||||
?" ["?"] $msg_nis_client")
|
||||
if [ "$toggled" ]; then
|
||||
err=$( f_sysrc_set nis_client_enable NO 2>&1 )
|
||||
else
|
||||
err=$( f_sysrc_set nis_client_enable YES 2>&1 ) \
|
||||
&& err=$( f_sysrc_set rpcbind_enable YES 2>&1 )
|
||||
fi
|
||||
;;
|
||||
if f_eval_catch -dk err "$0" f_sysrc_set \
|
||||
'f_sysrc_set nis_client_enable "%s"' "$reverse"
|
||||
then
|
||||
[ "$reverse" = "NO" ] || f_eval_catch -dk err "$0" \
|
||||
f_sysrc_set 'f_sysrc_set rpcbind_enable YES'
|
||||
fi ;;
|
||||
?" ["?"] $msg_nis_server")
|
||||
if [ "$toggled" ]; then
|
||||
err=$( f_sysrc_set nis_server_enable NO 2>&1 )
|
||||
else
|
||||
err=$( f_sysrc_set nis_server_enable YES 2>&1 ) \
|
||||
&& err=$( f_sysrc_set rpcbind_enable YES 2>&1 )
|
||||
fi
|
||||
;;
|
||||
if f_eval_catch -dk err "$0" f_sysrc_set \
|
||||
'f_sysrc_set nis_server_enable "%s"' "$reverse"
|
||||
then
|
||||
[ "$reverse" = "NO" ] || f_eval_catch -dk err "$0" \
|
||||
f_sysrc_set 'f_sysrc_set rpcbind_enable YES'
|
||||
fi ;;
|
||||
# Checkboxes for non-boolean options
|
||||
?" ["?"] $msg_nis_domainname")
|
||||
dialog_input_value "$msg_nis_domainname_desc" \
|
||||
"$( f_sysrc_get nisdomainname )" || continue
|
||||
err=$( f_sysrc_set nisdomainname "$value" 2>&1 )
|
||||
;;
|
||||
f_eval_catch -dk err "$0" f_sysrc_set \
|
||||
'f_sysrc_set nisdomainname "%s"' "$value" ;;
|
||||
?" ["?"] $msg_startup_dirs")
|
||||
dialog_input_value "$msg_startup_dirs_desc" \
|
||||
"$( f_sysrc_get local_startup )" || continue
|
||||
err=$( f_sysrc_set local_startup "$value" 2>&1 )
|
||||
;;
|
||||
f_eval_catch -dk err "$0" f_sysrc_set \
|
||||
'f_sysrc_set local_startup "%s"' "$value" ;;
|
||||
?" ["?"] $msg_named_flags")
|
||||
dialog_input_value "$msg_named_flags_desc" \
|
||||
"$( f_sysrc_get named_flags )" || continue
|
||||
err=$( f_sysrc_set named_flags "$value" 2>&1 )
|
||||
;;
|
||||
f_eval_catch -dk err "$0" f_sysrc_set \
|
||||
'f_sysrc_set named_flags "%s"' "$value" ;;
|
||||
esac
|
||||
|
||||
[ $? -eq $DIALOG_OK ] || f_dialog_msgbox "$err\n"
|
||||
|
@ -38,8 +38,8 @@ f_include $BSDCFG_SHARE/startup/rcconf.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="140.startup"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ GLOBALS
|
||||
|
||||
|
@ -39,8 +39,8 @@ f_include $BSDCFG_SHARE/startup/rcconf.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="140.startup"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ GLOBALS
|
||||
|
||||
|
@ -39,8 +39,8 @@ f_include $BSDCFG_SHARE/startup/rcconf.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="140.startup"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ GLOBALS
|
||||
|
||||
@ -364,18 +364,17 @@ while :; do
|
||||
"> $msg_delete_selected")
|
||||
delete_vars=
|
||||
for var in $( f_startup_rcconf_list ); do
|
||||
[ "$( eval echo \$_${var}_delete )" ] || continue
|
||||
delete_vars="$delete_vars${delete_vars:+ }$var"
|
||||
f_getvar _${var}_delete _delete
|
||||
[ "$_delete" ] || continue
|
||||
delete_vars="$delete_vars $var"
|
||||
done
|
||||
if dialog_menu_confirm_delete $delete_vars; then
|
||||
f_dialog_title "$msg_info"
|
||||
f_dialog_info "$msg_deleting_selected_directives"
|
||||
f_dialog_title_restore
|
||||
for var in $delete_vars; do
|
||||
if ! err=$( f_sysrc_delete $var 2>&1 ); then
|
||||
f_dialog_msgbox "$err\n"
|
||||
break
|
||||
fi
|
||||
f_eval_catch "$0" f_sysrc_delete \
|
||||
'f_sysrc_delete "%s"' "$var" || break
|
||||
done
|
||||
dialog_create_main
|
||||
fi
|
||||
|
@ -38,8 +38,8 @@ f_include $BSDCFG_SHARE/startup/rcedit.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="140.startup"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ MAIN
|
||||
|
||||
|
@ -39,8 +39,8 @@ f_include $BSDCFG_SHARE/startup/rcvar.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="140.startup"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ GLOBALS
|
||||
|
||||
@ -210,7 +210,7 @@ while :; do
|
||||
*) value="YES"
|
||||
esac
|
||||
|
||||
err=$( f_sysrc_set "$rcvar" "$value" 2>&1 ) || f_dialog_msgbox "$err"
|
||||
f_eval_catch "$0" f_sysrc_set 'f_sysrc_set "%s" "%s"' "$rcvar" "$value"
|
||||
done
|
||||
|
||||
exit $SUCCESS
|
||||
|
@ -106,6 +106,7 @@ f_startup_rcconf_list()
|
||||
#
|
||||
f_startup_rcconf_map()
|
||||
{
|
||||
local __funcname=f_startup_rcconf_map
|
||||
local __var_to_set="$1"
|
||||
|
||||
# If the in-memory cached value is available, return it immediately
|
||||
@ -128,7 +129,7 @@ f_startup_rcconf_map()
|
||||
# can be used to quickly populate the cache value for immediate return.
|
||||
#
|
||||
local __rc_defaults_digest
|
||||
__rc_defaults_digest=$( md5 < "$RC_DEFAULTS" )
|
||||
__rc_defaults_digest=$( exec 2> /dev/null; md5 < "$RC_DEFAULTS" )
|
||||
|
||||
#
|
||||
# Check to see if the global persistant cache file exists
|
||||
@ -218,8 +219,9 @@ f_startup_rcconf_map()
|
||||
#
|
||||
|
||||
# Create a new temporary file to write to
|
||||
local __tmpfile="$( mktemp -t "$pgm" )"
|
||||
[ "$__tmpfile" ] || return $FAILURE
|
||||
local __tmpfile
|
||||
f_eval_catch -dk __tmpfile $__funcname mktemp \
|
||||
'mktemp -t "%s"' "$pgm" || return $FAILURE
|
||||
|
||||
# Write the temporary file contents
|
||||
echo "$__rc_defaults_digest" > "$__tmpfile"
|
||||
@ -227,9 +229,11 @@ f_startup_rcconf_map()
|
||||
|
||||
# Finally, move the temporary file into place
|
||||
case "$STARTUP_RCCONF_MAP_CACHEFILE" in
|
||||
*/*) f_quietly mkdir -p "${STARTUP_RCCONF_MAP_CACHEFILE%/*}"
|
||||
*/*) f_eval_catch -d $__funcname mkdir \
|
||||
'mkdir -p "%s"' "${STARTUP_RCCONF_MAP_CACHEFILE%/*}"
|
||||
esac
|
||||
mv "$__tmpfile" "$STARTUP_RCCONF_MAP_CACHEFILE"
|
||||
f_eval_catch -d $__funcname mv \
|
||||
'mv "%s" "%s"' "$__tmpfile" "$STARTUP_RCCONF_MAP_CACHEFILE"
|
||||
}
|
||||
|
||||
# f_startup_rcconf_map_expand $var_to_get
|
||||
@ -243,7 +247,7 @@ f_startup_rcconf_map()
|
||||
f_startup_rcconf_map_expand()
|
||||
{
|
||||
local var_to_get="$1"
|
||||
eval "$( f_getvar "$var_to_get" | awk '
|
||||
eval "$( debug= f_getvar "$var_to_get" | awk '
|
||||
BEGIN {
|
||||
rword = "^[[:space:]]*[^[:space:]]*[[:space:]]*"
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ BSDCFG_SHARE="/usr/share/bsdconfig"
|
||||
. $BSDCFG_SHARE/common.subr || exit 1
|
||||
f_dprintf "%s: loading includes..." startup/rcedit.subr
|
||||
f_include $BSDCFG_SHARE/dialog.subr
|
||||
f_include $BSDCFG_SHARE/strings.subr
|
||||
f_include $BSDCFG_SHARE/sysrc.subr
|
||||
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="140.startup"
|
||||
@ -54,10 +55,11 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
#
|
||||
f_dialog_rcedit()
|
||||
{
|
||||
local funcname=f_dialog_rcedit
|
||||
local msg var="$1" _input
|
||||
|
||||
msg=$( printf "$msg_please_enter_a_new_value" \
|
||||
"$var" "$( f_sysrc_get_default "$var" )" )
|
||||
f_sprintf msg "$msg_please_enter_a_new_value" \
|
||||
"$var" "$( f_sysrc_get_default "$var" )"
|
||||
|
||||
shift 1 # var
|
||||
if [ "$1" ]; then
|
||||
@ -77,7 +79,8 @@ f_dialog_rcedit()
|
||||
|
||||
f_dprintf "%s: [%s]->[%s]" "$var" "$cur_val" "$_input"
|
||||
|
||||
err=$( f_sysrc_set "$var" "$_input" 2>&1 ) || f_dialog_msgbox "$err"
|
||||
f_eval_catch $funcname f_sysrc_set \
|
||||
'f_sysrc_set "%s" "%s"' "$var" "$_input"
|
||||
}
|
||||
|
||||
############################################################ MAIN
|
||||
|
@ -85,6 +85,7 @@ STARTUP_RCVAR_MAP_CACHEFILE="/var/run/bsdconfig/startup_rcvar_map.cache"
|
||||
#
|
||||
f_startup_rcvar_map()
|
||||
{
|
||||
local __funcname=f_startup_rcvar_map
|
||||
local __var_to_set="$1"
|
||||
|
||||
# If the in-memory cached value is available, return it immediately
|
||||
@ -125,8 +126,8 @@ f_startup_rcvar_map()
|
||||
# value for immediate return.
|
||||
#
|
||||
local __rc_script_list_digest
|
||||
__rc_script_list_digest=$( cd "$ETC_RC_D" &&
|
||||
cksum "$RC_DEFAULTS" $__rc_script_list | md5 )
|
||||
__rc_script_list_digest=$( cd "$ETC_RC_D" 2> /dev/null &&
|
||||
cksum "$RC_DEFAULTS" $__rc_script_list 2> /dev/null | md5 )
|
||||
|
||||
#
|
||||
# Check to see if the global persistant cache file exists
|
||||
@ -179,7 +180,7 @@ f_startup_rcvar_map()
|
||||
|
||||
STARTUP_RCVAR_MAP=$(
|
||||
for script in $__rc_script_list; do
|
||||
rcvar_list=$( $script rcvar | awk -F= \
|
||||
rcvar_list=$( $script rcvar 2> /dev/null | awk -F= \
|
||||
-v script="$script" '
|
||||
/^'"$STARTUP_RCVAR_REGEX"'/ {
|
||||
if ( $2 ~ /^"[Yy][Ee][Ss]"$/ )
|
||||
@ -211,8 +212,9 @@ f_startup_rcvar_map()
|
||||
#
|
||||
|
||||
# Create a new temporary file to write to
|
||||
local __tmpfile="$( mktemp -t "$pgm" )"
|
||||
[ "$__tmpfile" ] || return $FAILURE
|
||||
local __tmpfile
|
||||
f_eval_catch -dk __tmpfile $__funcname mktemp \
|
||||
'mktemp -t "%s"' "$__tmpfile" || return $FAILURE
|
||||
|
||||
# Write the temporary file contents
|
||||
echo "$__rc_script_list_digest" > "$__tmpfile"
|
||||
@ -220,9 +222,11 @@ f_startup_rcvar_map()
|
||||
|
||||
# Finally, move the temporary file into place
|
||||
case "$STARTUP_RCVAR_MAP_CACHEFILE" in
|
||||
*/*) f_quietly mkdir -p "${STARTUP_RCVAR_MAP_CACHEFILE%/*}"
|
||||
*/*) f_eval_catch -d $__funcname mkdir \
|
||||
'mkdir -p "%s"' "${STARTUP_RCVAR_MAP_CACHEFILE%/*}"
|
||||
esac
|
||||
mv "$__tmpfile" "$STARTUP_RCVAR_MAP_CACHEFILE"
|
||||
f_eval_catch -d $__funcname mv \
|
||||
'mv "%s" "%s"' "$__tmpfile" "$STARTUP_RCVAR_MAP_CACHEFILE"
|
||||
}
|
||||
|
||||
############################################################ MAIN
|
||||
|
@ -37,8 +37,8 @@ f_include $BSDCFG_SHARE/mustberoot.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="140.startup"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ FUNCTIONS
|
||||
|
||||
|
@ -32,6 +32,7 @@ BSDCFG_SHARE="/usr/share/bsdconfig"
|
||||
. $BSDCFG_SHARE/common.subr || exit 1
|
||||
f_dprintf "%s: loading includes..." timezone/zones.subr
|
||||
f_include $BSDCFG_SHARE/dialog.subr
|
||||
f_include $BSDCFG_SHARE/strings.subr
|
||||
f_include $BSDCFG_SHARE/timezone/continents.subr
|
||||
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="090.timezone"
|
||||
@ -347,8 +348,9 @@ f_read_zones()
|
||||
#
|
||||
f_install_zoneinfo_file()
|
||||
{
|
||||
local funcname=f_install_zoneinfo_file
|
||||
local zoneinfo_file="$1"
|
||||
local copymode title msg err height width
|
||||
local copymode title msg height width
|
||||
|
||||
if [ -L "$_PATH_LOCALTIME" ]; then
|
||||
copymode=
|
||||
@ -361,13 +363,13 @@ f_install_zoneinfo_file()
|
||||
|
||||
if [ "$VERBOSE" ]; then
|
||||
if [ ! "$zoneinfo_file" ]; then
|
||||
msg=$( printf "$msg_removing_file" "$_PATH_LOCALTIME" )
|
||||
f_sprintf msg "$msg_removing_file" "$_PATH_LOCALTIME"
|
||||
elif [ "$copymode" ]; then
|
||||
msg=$( printf "$msg_copying_file" \
|
||||
"$zoneinfo_file" "$_PATH_LOCALTIME" )
|
||||
f_sprintf msg "$msg_copying_file" \
|
||||
"$zoneinfo_file" "$_PATH_LOCALTIME"
|
||||
else
|
||||
msg=$( printf "$msg_creating_symlink" \
|
||||
"$_PATH_LOCALTIME" "$zoneinfo_file" )
|
||||
f_sprintf msg "$msg_creating_symlink" \
|
||||
"$_PATH_LOCALTIME" "$zoneinfo_file"
|
||||
fi
|
||||
if [ "$USEDIALOG" ]; then
|
||||
f_dialog_title "$msg_info"
|
||||
@ -380,33 +382,17 @@ f_install_zoneinfo_file()
|
||||
|
||||
[ "$REALLYDOIT" ] || return $SUCCESS
|
||||
|
||||
if [ ! "$zoneinfo_file" ]; then
|
||||
err=$( rm -f "$_PATH_LOCALTIME" 2>&1 )
|
||||
if [ "$err" ]; then
|
||||
if [ "$USEDIALOG" ]; then
|
||||
f_dialog_title "$msg_error"
|
||||
f_dialog_msgbox "$err"
|
||||
f_dialog_title_restore
|
||||
else
|
||||
f_err "%s\n" "$err"
|
||||
fi
|
||||
return $FAILURE
|
||||
fi
|
||||
local catch_args="-de"
|
||||
[ "$USEDIALOG" ] && catch_args=
|
||||
|
||||
err=$( rm -f "$_PATH_DB" 2>&1 )
|
||||
if [ "$err" ]; then
|
||||
if [ "$USEDIALOG" ]; then
|
||||
f_dialog_title "$msg_error"
|
||||
f_dialog_msgbox "$err"
|
||||
f_dialog_title_restore
|
||||
else
|
||||
f_err "%s\n" "$err"
|
||||
fi
|
||||
return $FAILURE
|
||||
fi
|
||||
if [ ! "$zoneinfo_file" ]; then
|
||||
f_eval_catch $catch_args $funcname rm \
|
||||
'rm -f "%s"' "$_PATH_LOCALTIME" || return $FAILURE
|
||||
f_eval_catch $catch_args $funcname rm \
|
||||
'rm -f "%s"' "$_PATH_DB" || return $FAILURE
|
||||
|
||||
if [ "$VERBOSE" ]; then
|
||||
msg=$( printf "$msg_removed_file" "$_PATH_LOCALTIME" )
|
||||
f_sprintf msg "$msg_removed_file" "$_PATH_LOCALTIME"
|
||||
if [ "$USEDIALOG" ]; then
|
||||
f_dialog_title "$msg_done"
|
||||
f_dialog_msgbox "$msg"
|
||||
@ -415,96 +401,35 @@ f_install_zoneinfo_file()
|
||||
printf "%s\n" "$msg"
|
||||
fi
|
||||
fi
|
||||
|
||||
return $SUCCESS
|
||||
|
||||
fi # ! zoneinfo_file
|
||||
|
||||
if [ "$copymode" ]; then
|
||||
|
||||
err=$( rm -f "$_PATH_LOCALTIME" 2>&1 )
|
||||
if [ "$err" ]; then
|
||||
if [ "$USEDIALOG" ]; then
|
||||
f_dialog_title "$msg_error"
|
||||
f_dialog_msgbox "$err"
|
||||
f_dialog_title_restore
|
||||
else
|
||||
f_err "%s\n" "$err"
|
||||
fi
|
||||
f_eval_catch $catch_args $funcname rm \
|
||||
'rm -f "%s"' "$_PATH_LOCALTIME" || return $FAILURE
|
||||
f_eval_catch $catch_args $funcname sh \
|
||||
'umask 222 && :> "%s"' "$_PATH_LOCALTIME" ||
|
||||
return $FAILURE
|
||||
fi
|
||||
|
||||
err=$( umask 222 && : 2>&1 > "$_PATH_LOCALTIME" )
|
||||
if [ "$err" ]; then
|
||||
if [ "$USEDIALOG" ]; then
|
||||
f_dialog_title "$msg_error"
|
||||
f_dialog_msgbox "$err"
|
||||
f_dialog_title_restore
|
||||
else
|
||||
f_err "%s\n" "$err"
|
||||
fi
|
||||
return $FAILURE
|
||||
fi
|
||||
|
||||
err=$( cat "$zoneinfo_file" 2>&1 > "$_PATH_LOCALTIME" )
|
||||
if [ "$err" ]; then
|
||||
if [ "$USEDIALOG" ]; then
|
||||
f_dialog_title "$msg_error"
|
||||
f_dialog_msgbox "$err"
|
||||
f_dialog_title_restore
|
||||
else
|
||||
f_err "%s\n" "$err"
|
||||
fi
|
||||
return $FAILURE
|
||||
fi
|
||||
|
||||
else # ! copymode
|
||||
|
||||
err=$( ( :< "$zoneinfo_file" ) 2>&1 )
|
||||
if [ "$err" ]; then
|
||||
if [ "$USEDIALOG" ]; then
|
||||
f_dialog_title "$msg_error"
|
||||
f_dialog_msgbox "$err"
|
||||
f_dialog_title_restore
|
||||
else
|
||||
f_err "%s\n" "$err"
|
||||
fi
|
||||
return $FAILURE
|
||||
fi
|
||||
|
||||
err=$( rm -f "$_PATH_LOCALTIME" 2>&1 )
|
||||
if [ "$err" ]; then
|
||||
if [ "$USEDIALOG" ]; then
|
||||
f_dialog_title "$msg_error"
|
||||
f_dialog_msgbox "$err"
|
||||
f_dialog_title_restore
|
||||
else
|
||||
f_err "%s\n" "$err"
|
||||
fi
|
||||
return $FAILURE
|
||||
fi
|
||||
|
||||
err=$( ln -s "$zoneinfo_file" "$_PATH_LOCALTIME" 2>&1 )
|
||||
if [ "$err" ]; then
|
||||
if [ "$USEDIALOG" ]; then
|
||||
f_dialog_title "$msg_error"
|
||||
f_dialog_msgbox "$err"
|
||||
f_dialog_title_restore
|
||||
else
|
||||
f_err "%s\n" "$err"
|
||||
fi
|
||||
return $FAILURE
|
||||
fi
|
||||
|
||||
f_eval_catch $catch_args $funcname sh \
|
||||
'cat "%s" > "%s"' \
|
||||
"$zoneinfo_file" "$_PATH_LOCALTIME" || return $FAILURE
|
||||
else
|
||||
f_eval_catch $catch_args $funcname sh \
|
||||
'( :< "%s" )' "$zoneinfo_file" || return $FAILURE
|
||||
f_eval_catch $catch_args $funcname rm \
|
||||
'rm -f "%s"' "$_PATH_LOCALTIME" || return $FAILURE
|
||||
f_eval_catch $catch_args $funcname ln \
|
||||
'ln -s "%s" "%s"' \
|
||||
"$zoneinfo_file" "$_PATH_LOCALTIME" || return $FAILURE
|
||||
fi # copymode
|
||||
|
||||
if [ "$VERBOSE" ]; then
|
||||
if [ "$copymode" ]; then
|
||||
msg=$( printf "$msg_copied_timezone_file" \
|
||||
"$zoneinfo_file" "$_PATH_LOCALTIME" )
|
||||
f_sprintf msg "$msg_copied_timezone_file" \
|
||||
"$zoneinfo_file" "$_PATH_LOCALTIME"
|
||||
else
|
||||
msg=$( printf "$msg_created_symlink" \
|
||||
"$_PATH_LOCALTIME" "$zoneinfo_file" )
|
||||
f_sprintf msg "$msg_created_symlink" \
|
||||
"$_PATH_LOCALTIME" "$zoneinfo_file"
|
||||
fi
|
||||
if [ "$USEDIALOG" ]; then
|
||||
f_dialog_title "$msg_done"
|
||||
@ -559,16 +484,17 @@ f_confirm_zone()
|
||||
local title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE"
|
||||
f_dialog_title_restore
|
||||
local tm_zone="$( TZ="$filename" date +%Z )"
|
||||
local prompt="$( printf "$msg_look_reasonable" "$tm_zone" )"
|
||||
local prompt # Calculated below
|
||||
local height=5 width=72
|
||||
|
||||
f_sprintf prompt "$msg_look_reasonable" "$tm_zone"
|
||||
if [ "$USE_XDIALOG" ]; then
|
||||
height=$(( $height + 4 ))
|
||||
$DIALOG \
|
||||
--title "$title" \
|
||||
--backtitle "$btitle" \
|
||||
--ok-label "$msg_yes" \
|
||||
--cancel-label "$msg_no" \
|
||||
--title "$title" \
|
||||
--backtitle "$btitle" \
|
||||
--ok-label "$msg_yes" \
|
||||
--cancel-label "$msg_no" \
|
||||
--yesno "$prompt" $height $width
|
||||
else
|
||||
$DIALOG \
|
||||
|
@ -43,8 +43,8 @@ f_include $BSDCFG_SHARE/timezone/zones.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="090.timezone"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ CONFIGURATION
|
||||
|
||||
@ -164,7 +164,7 @@ fi
|
||||
if [ "$REINSTALL" ]; then
|
||||
[ -f "$_PATH_DB" -a -r "$_PATH_DB" ] ||
|
||||
f_die 1 "$msg_cannot_open_for_reading" "$_PATH_DB"
|
||||
zoneinfo=$( cat "$_PATH_DB" ) ||
|
||||
f_eval_catch -dk zoneinfo "$0" cat 'cat "%s"' "$_PATH_DB" ||
|
||||
f_die 1 "$msg_error_reading" "$_PATH_DB"
|
||||
[ "$zoneinfo" ] ||
|
||||
f_die 1 "$msg_unable_to_determine_name_from_db" "$_PATH_DB"
|
||||
@ -244,7 +244,7 @@ if [ $# -ge 1 ]; then
|
||||
default="$1"
|
||||
|
||||
f_dialog_title "$msg_default_zone_provided"
|
||||
msg=$( printf "\n$msg_use_default_zone" "$default" )
|
||||
f_sprintf msg "\n$msg_use_default_zone" "$default"
|
||||
hline=
|
||||
f_dialog_yesno "$msg" "$hline"
|
||||
result=$?
|
||||
@ -322,16 +322,16 @@ while :; do
|
||||
# It's amazing how much good grammar really matters...
|
||||
#
|
||||
if [ ! "$isocean" ]; then
|
||||
title=$( printf "$msg_country_title" \
|
||||
"$cont_title" )
|
||||
f_sprintf title "$msg_country_title" \
|
||||
"$cont_title"
|
||||
f_dialog_title "$title"
|
||||
title="$DIALOG_TITLE"
|
||||
btitle="$DIALOG_BACKTITLE"
|
||||
f_dialog_title_restore
|
||||
prompt="$msg_select_country"
|
||||
else
|
||||
title=$( printf "$msg_island_and_group_title" \
|
||||
"$cont_title" )
|
||||
f_sprintf title "$msg_island_and_group_title" \
|
||||
"$cont_title"
|
||||
f_dialog_title "$title"
|
||||
title="$DIALOG_TITLE"
|
||||
btitle="$DIALOG_BACKTITLE"
|
||||
@ -397,11 +397,10 @@ while :; do
|
||||
continue
|
||||
fi
|
||||
else
|
||||
title=$( printf "$msg_country_time_zones" \
|
||||
"$( f_country $tlc name )" )
|
||||
f_sprintf title "$msg_country_time_zones" \
|
||||
"$( f_country $tlc name )"
|
||||
f_dialog_title "$title"
|
||||
title="$DIALOG_TITLE"
|
||||
btitle="$DIALOG_BACKTITLE"
|
||||
title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE"
|
||||
f_dialog_title_restore
|
||||
prompt="$msg_select_zone"
|
||||
menu_list=$( f_country $tlc menu_list )
|
||||
|
@ -37,8 +37,8 @@ f_include $BSDCFG_SHARE/mustberoot.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="150.ttys"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ CONFIGURATION
|
||||
|
||||
|
@ -36,8 +36,8 @@ f_include $BSDCFG_SHARE/dialog.subr
|
||||
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ MAIN
|
||||
|
||||
|
@ -39,8 +39,8 @@ f_include $BSDCFG_SHARE/usermgmt/group_input.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ MAIN
|
||||
|
||||
|
@ -39,8 +39,8 @@ f_include $BSDCFG_SHARE/usermgmt/group_input.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ MAIN
|
||||
|
||||
|
@ -39,8 +39,8 @@ f_include $BSDCFG_SHARE/usermgmt/group_input.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ CONFIGURATION
|
||||
|
||||
@ -56,16 +56,12 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
#
|
||||
save_changes()
|
||||
{
|
||||
local err retval=$SUCCESS
|
||||
local funcname=save_changes
|
||||
|
||||
case "$mode" in
|
||||
Delete)
|
||||
err=$( pw groupdel "$group_name" 2>&1 )
|
||||
retval=$?
|
||||
if [ $retval -ne $SUCCESS ]; then
|
||||
f_dialog_msgbox "$msg_error $err\n"
|
||||
return $retval
|
||||
fi
|
||||
f_eval_catch $funcname pw 'pw groupdel "%s"' "$group_name" ||
|
||||
return $?
|
||||
f_show_msg "$msg_group_deleted"
|
||||
;;
|
||||
Add)
|
||||
@ -74,17 +70,13 @@ save_changes()
|
||||
[ "$group_members" != "$cur_group_members" ] &&
|
||||
cmd="$cmd -M '$group_members'"
|
||||
if [ "$pw_group_password_disable" ]; then
|
||||
cmd="$cmd -h -"
|
||||
f_eval_catch $funcname pw '%s -h -' "$cmd"
|
||||
elif [ "$group_password" ]; then
|
||||
cmd="echo \"\$group_password\" | $cmd -h 0"
|
||||
fi
|
||||
f_dprintf "cmd=%s" "$cmd"
|
||||
err=$( eval $cmd 2>&1 )
|
||||
retval=$?
|
||||
if [ $retval -ne $SUCCESS ]; then
|
||||
f_dialog_msgbox "$msg_error $err\n"
|
||||
return $retval
|
||||
fi
|
||||
echo "$group_password" |
|
||||
f_eval_catch $funcname pw '%s -h 0' "$cmd"
|
||||
else
|
||||
f_eval_catch $funcname pw '%s' "$cmd"
|
||||
fi || return $?
|
||||
f_show_msg "$msg_group_added"
|
||||
;;
|
||||
Edit/View)
|
||||
@ -93,17 +85,13 @@ save_changes()
|
||||
[ "$group_members" != "$cur_group_members" ] &&
|
||||
cmd="$cmd -M '$group_members'"
|
||||
if [ "$pw_group_password_disable" ]; then
|
||||
cmd="$cmd -h -"
|
||||
f_eval_catch $funcname pw '%s -h -' "$cmd"
|
||||
elif [ "$group_password" ]; then
|
||||
cmd="echo \"\$group_password\" | $cmd -h 0"
|
||||
fi
|
||||
f_dprintf "cmd=%s" "$cmd"
|
||||
err=$( eval $cmd 2>&1 )
|
||||
retval=$?
|
||||
if [ $retval -ne $SUCCESS ]; then
|
||||
f_dialog_msgbox "$msg_error $err\n"
|
||||
return $retval
|
||||
fi
|
||||
echo "$group_password" |
|
||||
f_eval_catch $funcname pw '%s -h 0' "$cmd"
|
||||
else
|
||||
f_eval_catch $funcname pw '%s' "$cmd"
|
||||
fi || return $?
|
||||
f_show_msg "$msg_group_updated"
|
||||
;;
|
||||
esac
|
||||
|
@ -371,15 +371,12 @@ f_dialog_input_group_members()
|
||||
# pressed ESC or chose Cancel/No
|
||||
f_dialog_data_sanitize _group_members
|
||||
|
||||
#
|
||||
# Convert the newline separated list into a comma-
|
||||
# separated one so that if the user switches over to
|
||||
# manual editing, list reflects checklist selections
|
||||
_group_members=$( echo "$_group_members" |
|
||||
tr '\n' ' ' |
|
||||
sed -e 's/[[:space:]]\{1,\}/,/g;s/^,//;s/,$//'
|
||||
)
|
||||
|
||||
_input="$_group_members"
|
||||
#
|
||||
f_replaceall "$_group_members" "[$IFS]" "," _input
|
||||
;;
|
||||
2) # Enter Group Members manually
|
||||
local p="$msg_group_members ($msg_separated_by_commas)"
|
||||
|
@ -599,8 +599,8 @@ f_dialog_input_expire_password()
|
||||
|
||||
4) # Enter value manually
|
||||
local msg ret_secs
|
||||
msg=$( printf "$msg_number_of_seconds_since_epoch" \
|
||||
"$( date -r 1 "+%c %Z" )" )
|
||||
f_sprintf msg "$msg_number_of_seconds_since_epoch" \
|
||||
"$( date -r 1 "+%c %Z" )"
|
||||
|
||||
# Return to menu if either ESC or Cancel/No
|
||||
f_dialog_input ret_secs \
|
||||
@ -783,8 +783,8 @@ f_dialog_input_expire_account()
|
||||
|
||||
4) # Enter value manually
|
||||
local msg ret_secs
|
||||
msg=$( printf "$msg_number_of_seconds_since_epoch" \
|
||||
"$( date -r 1 "+%c %Z" )" )
|
||||
f_sprintf msg "$msg_number_of_seconds_since_epoch" \
|
||||
"$( date -r 1 "+%c %Z" )"
|
||||
|
||||
# Return to menu if either ESC or Cancel/No
|
||||
f_dialog_input ret_secs "$msg" \
|
||||
|
@ -36,8 +36,8 @@ f_include $BSDCFG_SHARE/dialog.subr
|
||||
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ MAIN
|
||||
|
||||
|
@ -39,8 +39,8 @@ f_include $BSDCFG_SHARE/usermgmt/user_input.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ MAIN
|
||||
|
||||
|
@ -39,8 +39,8 @@ f_include $BSDCFG_SHARE/usermgmt/user_input.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ MAIN
|
||||
|
||||
|
@ -39,8 +39,8 @@ f_include $BSDCFG_SHARE/usermgmt/user_input.subr
|
||||
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
|
||||
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ CONFIGURATION
|
||||
|
||||
@ -74,29 +74,24 @@ copy_dotfiles()
|
||||
#
|
||||
save_changes()
|
||||
{
|
||||
local err retval=$SUCCESS
|
||||
local funcname=save_changes
|
||||
|
||||
case "$mode" in
|
||||
Delete)
|
||||
err=$( pw userdel -u "$pw_uid" 2>&1 )
|
||||
retval=$?
|
||||
if [ $retval -ne $SUCCESS ]; then
|
||||
f_dialog_msgbox "$msg_error $err\n"
|
||||
return $retval
|
||||
fi
|
||||
f_eval_catch $funcname pw 'pw userdel -u "%s"' "$pw_uid" ||
|
||||
return $?
|
||||
f_show_msg "$msg_login_deleted"
|
||||
|
||||
if [ "$pw_group_delete" = "$msg_yes" ] &&
|
||||
f_quietly pw groupshow -g "$pw_gid"
|
||||
then
|
||||
err=$( pw groupdel -g "$pw_gid" 2>&1 ) ||
|
||||
f_dialog_msgbox "$msg_warning $err\n"
|
||||
f_eval_catch $funcname pw \
|
||||
'pw groupdel -g "%s"' "$pw_gid"
|
||||
fi
|
||||
|
||||
if [ "$pw_home_delete" = "$msg_yes" ]; then
|
||||
f_dialog_info "$msg_deleting_home_directory"
|
||||
err=$( rm -Rf "$pw_home_dir" 2>&1 ) ||
|
||||
f_dialog_msgbox "$msg_warning $err\n"
|
||||
f_eval_catch $funcname rm 'rm -Rf "%s"' "$pw_home_dir"
|
||||
fi
|
||||
;;
|
||||
Add)
|
||||
@ -111,35 +106,27 @@ save_changes()
|
||||
[ "$pw_shell" ] && cmd="$cmd -s '$pw_shell'"
|
||||
[ "$pw_uid" ] && cmd="$cmd -u '$pw_uid'"
|
||||
if [ "$pw_password_disable" ]; then
|
||||
cmd="$cmd -h -"
|
||||
f_eval_catch $funcname pw '%s -h -' "$cmd"
|
||||
elif [ "$pw_password" ]; then
|
||||
cmd="echo \"\$pw_password\" | $cmd -h 0"
|
||||
fi
|
||||
f_dprintf "cmd=%s" "$cmd"
|
||||
err=$( eval $cmd 2>&1 )
|
||||
retval=$?
|
||||
if [ $retval -ne $SUCCESS ]; then
|
||||
f_dialog_msgbox "$msg_error $err\n"
|
||||
return $retval
|
||||
fi
|
||||
echo "$pw_password" |
|
||||
f_eval_catch $funcname pw '%s -h 0' "$cmd"
|
||||
else
|
||||
f_eval_catch $funcname pw '%s' "$cmd"
|
||||
fi || return $?
|
||||
f_show_msg "$msg_login_added"
|
||||
|
||||
if [ "$pw_home_create" = "$msg_yes" ]; then
|
||||
err=$( mkdir -p "$pw_home_dir" 2>&1 )
|
||||
if [ $? -ne $SUCCESS ]; then
|
||||
f_dialog_msgbox "$msg_warning $err\n"
|
||||
elif [ -e "$pw_home_dir" ]; then
|
||||
err=$( chown -R "$pw_uid:$pw_gid" \
|
||||
"$pw_home_dir" 2>&1 )
|
||||
[ $? -eq $SUCCESS ] ||
|
||||
f_dialog_msgbox "$msg_warning $err\n"
|
||||
if f_eval_catch $funcname mkdir \
|
||||
'mkdir -p "%s"' "$pw_home_dir"
|
||||
then
|
||||
f_eval_catch $funcname chown \
|
||||
'chown -R "%s" "%s"' \
|
||||
"$pw_uid:$pw_gid" "$pw_home_dir"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$pw_dotfiles_create" = "$msg_yes" ]; then
|
||||
err=$( copy_dotfiles 2>&1 ) ||
|
||||
f_dialog_msgbox "$msg_warning $err\n"
|
||||
fi
|
||||
[ "$pw_dotfiles_create" = "$msg_yes" ] &&
|
||||
f_eval_catch $funcname copy_dotfiles copy_dotfiles
|
||||
|
||||
user="$pw_name"
|
||||
f_quietly pw usershow -n "$pw_name" &&
|
||||
@ -157,35 +144,27 @@ save_changes()
|
||||
[ "$pw_shell" ] && cmd="$cmd -s '$pw_shell'"
|
||||
[ "$pw_uid" ] && cmd="$cmd -u '$pw_uid'"
|
||||
if [ "$pw_password_disable" ]; then
|
||||
cmd="$cmd -h -"
|
||||
f_eval_catch $funcname pw '%s -h -' "$cmd"
|
||||
elif [ "$pw_password" ]; then
|
||||
cmd="echo \"\$pw_password\" | $cmd -h 0"
|
||||
fi
|
||||
f_dprintf "cmd=%s" "$cmd"
|
||||
err=$( eval $cmd 2>&1 )
|
||||
retval=$?
|
||||
if [ $retval -ne $SUCCESS ]; then
|
||||
f_dialog_msgbox "$msg_error $err\n"
|
||||
return $retval
|
||||
fi
|
||||
echo "$pw_password" |
|
||||
f_eval_catch $funcname pw '%s -h 0' "$cmd"
|
||||
else
|
||||
f_eval_catch $funcname pw '%s' "$cmd"
|
||||
fi || return $?
|
||||
f_show_msg "$msg_login_updated"
|
||||
|
||||
if [ "$pw_home_create" = "$msg_yes" ]; then
|
||||
err=$( mkdir -p "$pw_home_dir" )
|
||||
if [ $? -ne $SUCCESS ]; then
|
||||
f_dialog_msgbox "$msg_warning $err\n"
|
||||
elif [ -e "$pw_home_dir" ]; then
|
||||
err=$( chown -R "$pw_uid:$pw_gid" \
|
||||
"$pw_home_dir" 2>&1 )
|
||||
[ $? -eq $SUCCESS ] ||
|
||||
f_dialog_msgbox "$msg_warning $err\n"
|
||||
if f_eval_catch $funcname mkdir \
|
||||
'mkdir -p "%s"' "$pw_home_dir"
|
||||
then
|
||||
f_eval_catch $funcname chown \
|
||||
'chown -R "%i:%i" "%s"' \
|
||||
"$pw_uid" "$pw_gid" "$pw_home_dir"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$pw_dotfiles_create" = "$msg_yes" ]; then
|
||||
err=$( copy_dotfiles 2>&1 ) ||
|
||||
f_dialog_msgbox "$msg_warning $err\n"
|
||||
fi
|
||||
[ "$pw_dotfiles_create" = "$msg_yes" ] &&
|
||||
f_eval_catch $funcname copy_dotfiles copy_dotfiles
|
||||
;;
|
||||
esac
|
||||
|
||||
|
@ -40,8 +40,8 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
|
||||
|
||||
USERMGMT_HELPFILE=$BSDCFG_LIBE/$APP_DIR/include/usermgmt.hlp
|
||||
|
||||
ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
|
||||
[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
|
||||
f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
|
||||
pgm="${ipgm:-$pgm}"
|
||||
|
||||
############################################################ FUNCTIONS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user