Introduce centralized [X]dialog(1) exit codes to `dialog.subr' and make-use
throughout the bsdconfig(8) code. While we're here, add an explicit argument to lvalue-seeking invocations of "return" that previously had no argument. Also, consolidate a single instance of double-newline and remove some comments that are no longer required (given increased readability with new exit codes). Approved by: re (glebius)
This commit is contained in:
parent
cb53fc2dad
commit
f677a9e267
@ -300,7 +300,7 @@ dialog_menu_main()
|
||||
f_dialog_menutag_store "$menu_choice"
|
||||
|
||||
# Only update default-item on success
|
||||
[ $retval -eq 0 ] && f_dialog_default_store "$menu_choice"
|
||||
[ $retval -eq $DIALOG_OK ] && f_dialog_default_store "$menu_choice"
|
||||
|
||||
return $retval
|
||||
}
|
||||
@ -396,11 +396,10 @@ while :; do
|
||||
f_dialog_menutag_fetch mtag
|
||||
f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
|
||||
|
||||
if [ $retval -eq 2 ]; then
|
||||
# The Help button was pressed
|
||||
if [ $retval -eq $DIALOG_HELP ]; then
|
||||
f_show_help "$BSDCONFIG_HELPFILE"
|
||||
continue
|
||||
elif [ $retval -ne 0 ]; then
|
||||
elif [ $retval -ne $DIALOG_OK ]; then
|
||||
f_die
|
||||
fi
|
||||
|
||||
|
@ -92,7 +92,7 @@ dialog_menu_main()
|
||||
local retval=$?
|
||||
f_dialog_menutag_store -s "$menu_choice"
|
||||
|
||||
if [ $retval -eq $SUCCESS ]; then
|
||||
if [ $retval -eq $DIALOG_OK ]; then
|
||||
local item
|
||||
item=$( eval f_dialog_menutag2item \
|
||||
\"\$menu_choice\" $menu_list )
|
||||
|
@ -102,7 +102,7 @@ f_dialog_title_restore
|
||||
# Stop the mouse daemon
|
||||
#
|
||||
f_quietly vidcontrol -m off
|
||||
if [ $retval -eq $SUCCESS ]; then
|
||||
if [ $retval -eq $DIALOG_OK ]; then
|
||||
f_sysrc_set moused_enable "YES" || f_die
|
||||
ln -fs /dev/sysmouse /dev/mouse || f_die # backwards compat
|
||||
else
|
||||
|
@ -148,7 +148,7 @@ while :; do
|
||||
"$interface" "$_ipaddr" "$_netmask" "$_options" $dhcp
|
||||
|
||||
# Return to root menu if above returns success
|
||||
[ $? -eq $SUCCESS ] && break
|
||||
[ $? -eq $DIALOG_OK ] && break
|
||||
done
|
||||
|
||||
exit $SUCCESS
|
||||
|
@ -125,7 +125,7 @@ f_dialog_menu_netdev()
|
||||
)
|
||||
if [ ! "$interfaces" ]; then
|
||||
f_show_msg "$msg_no_network_interfaces"
|
||||
return $FAILURE
|
||||
return $DIALOG_CANCEL
|
||||
fi
|
||||
|
||||
#
|
||||
@ -242,12 +242,10 @@ f_dialog_menu_netdev_edit()
|
||||
local retval=$?
|
||||
f_dialog_data_sanitize tag
|
||||
|
||||
if [ $retval -eq 2 ]; then
|
||||
# The Help button was pressed
|
||||
if [ $retval -eq $DIALOG_HELP ]; then
|
||||
f_show_help "$TCP_HELPFILE"
|
||||
continue
|
||||
elif [ $retval -ne $SUCCESS ]; then
|
||||
# "Cancel" was chosen (-1) or ESC was pressed (255)
|
||||
elif [ $retval -ne $DIALOG_OK ]; then
|
||||
return $retval
|
||||
else
|
||||
# Only update default-item on success
|
||||
@ -298,7 +296,7 @@ f_dialog_menu_netdev_edit()
|
||||
)
|
||||
retval=$?
|
||||
trap 'interrupt' SIGINT
|
||||
if [ $retval -eq $SUCCESS ]; then
|
||||
if [ $retval -eq $DIALOG_OK ]; then
|
||||
dhcp=1
|
||||
ipaddr=$( f_ifconfig_inet $interface )
|
||||
netmask=$( f_ifconfig_netmask $interface )
|
||||
@ -312,11 +310,11 @@ f_dialog_menu_netdev_edit()
|
||||
fi
|
||||
;;
|
||||
3\ *) f_dialog_input_ipaddr "$interface" "$ipaddr"
|
||||
[ $? -eq $SUCCESS ] && dhcp= ;;
|
||||
[ $? -eq $DIALOG_OK ] && dhcp= ;;
|
||||
4\ *) f_dialog_input_netmask "$interface" "$netmask"
|
||||
[ $? -eq $SUCCESS -a "$_netmask" ] && dhcp= ;;
|
||||
[ $? -eq $DIALOG_OK -a "$_netmask" ] && dhcp= ;;
|
||||
5\ *) f_dialog_menu_media_options "$interface" "$options"
|
||||
[ $? -eq $SUCCESS ] && dhcp= ;;
|
||||
[ $? -eq $DIALOG_OK ] && dhcp= ;;
|
||||
esac
|
||||
done
|
||||
|
||||
@ -383,7 +381,7 @@ f_dialog_menu_netdev_edit()
|
||||
fi
|
||||
fi
|
||||
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
############################################################ MAIN
|
||||
|
@ -110,7 +110,7 @@ f_dialog_input_hostname()
|
||||
#
|
||||
while :; do
|
||||
f_dialog_input hostname "$msg" "$hostname" \
|
||||
"$hline_alnum_punc_tab_enter" || return
|
||||
"$hline_alnum_punc_tab_enter" || return $?
|
||||
# Taint-check the user's input
|
||||
f_dialog_validate_hostname "$hostname" && break
|
||||
done
|
||||
@ -150,7 +150,7 @@ f_dialog_input_hostname()
|
||||
fi
|
||||
fi
|
||||
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
############################################################ MAIN
|
||||
|
@ -147,7 +147,7 @@ f_dialog_input_ipaddr()
|
||||
local setting="$( printf "$msg_current_ipaddr" \
|
||||
"$interface" "$_ipaddr" )"
|
||||
f_noyes "$msg_nfs_mounts_may_cause_hang" "$setting" ||
|
||||
return $FAILURE
|
||||
return $DIALOG_CANCEL
|
||||
fi
|
||||
|
||||
local msg="$( printf "$msg_please_enter_new_ip_addr" "$interface" )"
|
||||
@ -163,11 +163,11 @@ f_dialog_input_ipaddr()
|
||||
# - User has not made any changes to the given value
|
||||
#
|
||||
f_dialog_input _input "$msg" "$_ipaddr" \
|
||||
"$hline_num_punc_tab_enter" || return
|
||||
[ "$_ipaddr" = "$_input" ] && return $FAILURE
|
||||
"$hline_num_punc_tab_enter" || return $?
|
||||
[ "$_ipaddr" = "$_input" ] && return $DIALOG_CANCEL
|
||||
|
||||
# Return success if NULL value was entered
|
||||
[ "$_input" ] || return $SUCCESS
|
||||
[ "$_input" ] || return $DIALOG_OK
|
||||
|
||||
# Take only the first "word" of the user's input
|
||||
_ipaddr="$_input"
|
||||
@ -208,7 +208,7 @@ f_dialog_input_ipaddr()
|
||||
ipaddr="$_ipaddr"
|
||||
[ "$_netmask" ] && netmask="$_netmask"
|
||||
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
############################################################ MAIN
|
||||
|
@ -118,7 +118,7 @@ f_dialog_input_options()
|
||||
local setting="$( printf "$msg_current_options" \
|
||||
"$interface" "$options" )"
|
||||
f_noyes "$msg_nfs_mounts_may_cause_hang" "$setting" ||
|
||||
return $FAILURE
|
||||
return $DIALOG_CANCEL
|
||||
fi
|
||||
|
||||
local msg="$( printf "$msg_please_enter_mediaopts" "$interface" )"
|
||||
@ -138,7 +138,7 @@ f_dialog_input_options()
|
||||
local retval=$?
|
||||
f_dialog_line_sanitize _options
|
||||
|
||||
[ $retval -eq $SUCCESS ] && options="$_options"
|
||||
[ $retval -eq $DIALOG_OK ] && options="$_options"
|
||||
|
||||
return $retval
|
||||
}
|
||||
@ -165,7 +165,7 @@ f_dialog_menu_media_options()
|
||||
local setting="$( printf "$msg_current_options" \
|
||||
"$interface" "$_options" )"
|
||||
f_noyes "$msg_nfs_mounts_may_cause_hang" "$setting" ||
|
||||
return $FAILURE
|
||||
return $DIALOG_CANCEL
|
||||
fi
|
||||
|
||||
#
|
||||
@ -219,7 +219,7 @@ f_dialog_menu_media_options()
|
||||
local retval=$?
|
||||
f_dialog_data_sanitize tag
|
||||
|
||||
if [ $retval -eq $SUCCESS ]; then
|
||||
if [ $retval -eq $DIALOG_OK ]; then
|
||||
options=$( eval f_dialog_menutag2item \"\$tag\" \
|
||||
$supported_media )
|
||||
case "$options" in
|
||||
|
@ -97,7 +97,7 @@ f_dialog_input_netmask()
|
||||
local setting="$( printf "$msg_current_subnet" \
|
||||
"$interface" "$_netmask" )"
|
||||
f_noyes "$msg_nfs_mounts_may_cause_hang" "$setting" ||
|
||||
return $FAILURE
|
||||
return $DIALOG_CANCEL
|
||||
fi
|
||||
|
||||
#
|
||||
@ -111,11 +111,11 @@ f_dialog_input_netmask()
|
||||
# - User has not made any changes to the given value
|
||||
#
|
||||
f_dialog_input _input "$msg" "$_netmask" \
|
||||
"$hline_num_punc_tab_enter" || return
|
||||
[ "$_netmask" = "$_input" ] && return $FAILURE
|
||||
"$hline_num_punc_tab_enter" || return $?
|
||||
[ "$_netmask" = "$_input" ] && return $DIALOG_CANCEL
|
||||
|
||||
# Return success if NULL value was entered
|
||||
[ "$_input" ] || return $SUCCESS
|
||||
[ "$_input" ] || return $DIALOG_OK
|
||||
|
||||
# Take only the first "word" of the user's input
|
||||
_netmask="$_input"
|
||||
|
@ -195,7 +195,7 @@ f_dialog_resolv_conf_update()
|
||||
# update with our new `domain' and `search' directives.
|
||||
#
|
||||
local tmpfile="$( mktemp -t "$pgm" )"
|
||||
[ "$tmpfile" ] || return $FAILURE
|
||||
[ "$tmpfile" ] || return $DIALOG_CANCEL
|
||||
|
||||
#
|
||||
# Fixup permissions and ownership (mktemp(1) creates the
|
||||
@ -235,7 +235,8 @@ f_dialog_resolv_conf_update()
|
||||
# Write the temporary file contents and move the temporary
|
||||
# file into place.
|
||||
#
|
||||
echo "$new_contents" | tail -r > "$tmpfile" || return $FAILURE
|
||||
echo "$new_contents" | tail -r > "$tmpfile" ||
|
||||
return $DIALOG_CANCEL
|
||||
f_quietly mv "$tmpfile" "$RESOLV_CONF"
|
||||
|
||||
fi
|
||||
@ -293,8 +294,8 @@ f_dialog_input_nameserver()
|
||||
#
|
||||
# Perform sanity checks
|
||||
#
|
||||
f_isinteger "$index" || return $FAILURE
|
||||
[ $index -ge 0 ] || return $FAILURE
|
||||
f_isinteger "$index" || return $DIALOG_CANCEL
|
||||
[ $index -ge 0 ] || return $DIALOG_CANCEL
|
||||
|
||||
local msg
|
||||
if [ $index -gt 0 ]; then
|
||||
@ -312,7 +313,7 @@ f_dialog_input_nameserver()
|
||||
#
|
||||
while :; do
|
||||
f_dialog_input new_ns "$msg" "$ns" \
|
||||
"$hline_num_punc_tab_enter" || return
|
||||
"$hline_num_punc_tab_enter" || return $?
|
||||
|
||||
# Take only the first "word" of the user's input
|
||||
new_ns="${new_ns%%[$IFS]*}"
|
||||
@ -331,7 +332,7 @@ f_dialog_input_nameserver()
|
||||
if [ $index -eq "0" -a "$new_ns" ]; then
|
||||
f_dialog_info "$msg_saving_nameserver"
|
||||
printf "nameserver\t%s\n" "$new_ns" >> "$RESOLV_CONF"
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
elif [ $index -gt 0 -a "$old_ns" != "$new_ns" ]; then
|
||||
if [ "$new_ns" ]; then
|
||||
msg="$msg_saving_nameserver_existing"
|
||||
@ -344,7 +345,7 @@ f_dialog_input_nameserver()
|
||||
# Create a new temporary file to write our new resolv.conf(5)
|
||||
#
|
||||
local tmpfile="$( mktemp -t "$pgm" )"
|
||||
[ "$tmpfile" ] || return $FAILURE
|
||||
[ "$tmpfile" ] || return $DIALOG_CANCEL
|
||||
|
||||
#
|
||||
# Quietly fixup permissions and ownership
|
||||
@ -381,7 +382,7 @@ f_dialog_input_nameserver()
|
||||
# Write the temporary file contents and move the temporary
|
||||
# file into place.
|
||||
#
|
||||
echo "$new_contents" > "$tmpfile" || return $FAILURE
|
||||
echo "$new_contents" > "$tmpfile" || return $DIALOG_CANCEL
|
||||
f_quietly mv "$tmpfile" "$RESOLV_CONF"
|
||||
fi
|
||||
}
|
||||
@ -452,7 +453,7 @@ f_dialog_menu_nameservers()
|
||||
f_dialog_data_sanitize tag
|
||||
|
||||
# Return if "Cancel" was chosen (-1) or ESC was pressed (255)
|
||||
if [ $retval -ne $SUCCESS ]; then
|
||||
if [ $retval -ne $DIALOG_OK ]; then
|
||||
return $retval
|
||||
else
|
||||
# Only update default-item on success
|
||||
|
@ -75,7 +75,7 @@ f_dialog_input_defaultrouter()
|
||||
local setting="$( printf "$msg_current_default_router" \
|
||||
"$defaultrouter" )"
|
||||
f_noyes "$msg_nfs_mounts_may_cause_hang" "$setting" ||
|
||||
return $FAILURE
|
||||
return $DIALOG_CANCEL
|
||||
fi
|
||||
|
||||
#
|
||||
@ -87,8 +87,8 @@ f_dialog_input_defaultrouter()
|
||||
"$msg_please_enter_default_router" \
|
||||
"$defaultrouter" "$hline_num_punc_tab_enter"
|
||||
retval=$?
|
||||
[ "$defaultrouter" ] || return $SUCCESS
|
||||
[ $retval -eq $SUCCESS ] || return $retval
|
||||
[ "$defaultrouter" ] || return $DIALOG_OK
|
||||
[ $retval -eq $DIALOG_OK ] || return $retval
|
||||
|
||||
# Taint-check the user's input
|
||||
f_dialog_validate_ipaddr "$defaultrouter" && break
|
||||
@ -112,7 +112,7 @@ f_dialog_input_defaultrouter()
|
||||
f_dialog_clear
|
||||
f_yesno "$msg_activate_default_router" \
|
||||
"$( f_route_get_default )" "$defaultrouter"
|
||||
if [ $? -eq $SUCCESS ]; then
|
||||
if [ $? -eq $DIALOG_OK ]; then
|
||||
local err
|
||||
|
||||
# Apply the default router/gateway
|
||||
@ -120,7 +120,7 @@ f_dialog_input_defaultrouter()
|
||||
err=$( route add default "$defaultrouter" 2>&1 )
|
||||
if [ $? -ne $SUCCESS ]; then
|
||||
f_dialog_msgbox "$err"
|
||||
return $FAILURE
|
||||
return $DIALOG_CANCEL
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
@ -114,7 +114,7 @@ f_dialog_input_password()
|
||||
break
|
||||
done
|
||||
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
############################################################ MAIN
|
||||
|
@ -131,11 +131,10 @@ while :; do
|
||||
retval=$?
|
||||
f_dialog_menutag_fetch mtag
|
||||
|
||||
if [ $retval -eq 2 ]; then
|
||||
# The Help button was pressed
|
||||
if [ $retval -eq $DIALOG_HELP ]; then
|
||||
f_show_help "$SECURELEVEL_HELPFILE"
|
||||
continue
|
||||
elif [ $retval -ne 0 ]; then
|
||||
elif [ $retval -ne $DIALOG_OK ]; then
|
||||
f_die
|
||||
fi
|
||||
|
||||
|
@ -123,7 +123,7 @@ dialog_menu_main()
|
||||
f_dialog_menutag_store "$menu_choice"
|
||||
|
||||
# Only update default-item on success
|
||||
[ $retval -eq 0 ] && f_dialog_default_store "$menu_choice"
|
||||
[ $retval -eq $DIALOG_OK ] && f_dialog_default_store "$menu_choice"
|
||||
|
||||
return $retval
|
||||
}
|
||||
|
@ -560,18 +560,19 @@ f_index_file()
|
||||
|
||||
if [ "$lang" ]; then
|
||||
awk -v keyword="$keyword" "$f_index_file_awk" \
|
||||
$BSDCFG_LIBE${BSDCFG_LIBE:+/}*/INDEX.$lang && return
|
||||
$BSDCFG_LIBE${BSDCFG_LIBE:+/}*/INDEX.$lang &&
|
||||
return $SUCCESS
|
||||
# No match, fall-thru to non-i18n sources
|
||||
fi
|
||||
awk -v keyword="$keyword" "$f_index_file_awk" \
|
||||
$BSDCFG_LIBE${BSDCFG_LIBE:+/}*/INDEX && return
|
||||
$BSDCFG_LIBE${BSDCFG_LIBE:+/}*/INDEX && return $SUCCESS
|
||||
|
||||
# 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
|
||||
$BSDCFG_LOCAL_LIBE/*/INDEX.$lang && return $SUCCESS
|
||||
# No match, fall-thru to non-i18n sources
|
||||
fi
|
||||
awk -v keyword="$keyword" "$f_index_file_awk" \
|
||||
|
@ -552,7 +552,7 @@ f_device_find()
|
||||
f_device_init()
|
||||
{
|
||||
local name="$1" init_func
|
||||
device_$name get init init_func || return
|
||||
device_$name get init init_func || return $?
|
||||
${init_func:-:} $name
|
||||
}
|
||||
|
||||
@ -564,7 +564,7 @@ f_device_init()
|
||||
f_device_get()
|
||||
{
|
||||
local name="$1" file="$2" probe="$3" get_func
|
||||
device_$name get get get_func || return
|
||||
device_$name get get get_func || return $?
|
||||
${get_func:-:} $name "$file" ${3+"$probe"}
|
||||
}
|
||||
|
||||
@ -575,7 +575,7 @@ f_device_get()
|
||||
f_device_shutdown()
|
||||
{
|
||||
local name="$1" shutdown_func
|
||||
device_$name get shutdown shutdown_func || return
|
||||
device_$name get shutdown shutdown_func || return $?
|
||||
${shutdown_func:-:} $name
|
||||
}
|
||||
|
||||
@ -597,7 +597,7 @@ f_device_menu()
|
||||
[ "$devtype" = "$type" ] || continue
|
||||
devs="$devs $dev"
|
||||
done
|
||||
[ "$devs" ] || return $FAILURE
|
||||
[ "$devs" ] || return $DIALOG_CANCEL
|
||||
|
||||
local desc menu_list=
|
||||
for dev in $devs; do
|
||||
@ -637,7 +637,7 @@ f_device_menu()
|
||||
)
|
||||
local retval=$?
|
||||
|
||||
[ $retval -ne 2 ] && break
|
||||
[ $retval -ne $DIALOG_HELP ] && break
|
||||
# Otherwise, the Help button was pressed
|
||||
f_show_help "$helpfile"
|
||||
# ...then loop back to menu
|
||||
@ -646,7 +646,7 @@ f_device_menu()
|
||||
|
||||
[ "$errexit" ] && set -e
|
||||
|
||||
if [ $retval -eq 0 ]; then
|
||||
if [ $retval -eq $DIALOG_OK ]; then
|
||||
# Clean up the output of [X]dialog(1) and return it
|
||||
f_dialog_data_sanitize mtag
|
||||
echo "$mtag" >&2
|
||||
|
@ -73,6 +73,18 @@ unset XDIALOG_HIGH_DIALOG_COMPAT
|
||||
unset XDIALOG_FORCE_AUTOSIZE
|
||||
unset XDIALOG_INFOBOX_TIMEOUT
|
||||
|
||||
#
|
||||
# Exit codes for [X]dialog(1)
|
||||
#
|
||||
DIALOG_OK=${SUCCESS:-0}
|
||||
DIALOG_CANCEL=${FAILURE:-1}
|
||||
DIALOG_HELP=2
|
||||
DIALOG_ITEM_HELP=2
|
||||
DIALOG_EXTRA=3
|
||||
DIALOG_ITEM_HELP=4
|
||||
export DIALOG_ERROR=254 # sh(1) can't handle the default of `-1'
|
||||
DIALOG_ESC=255
|
||||
|
||||
#
|
||||
# Default behavior is to call f_dialog_init() automatically when loaded.
|
||||
#
|
||||
|
@ -113,11 +113,10 @@ f_media_get_type()
|
||||
f_dialog_data_sanitize mtag
|
||||
f_dprintf "retval=%s mtag=[%s]" $retval "$mtag"
|
||||
|
||||
if [ $retval -eq 2 ]; then
|
||||
# The Help button was pressed
|
||||
if [ $retval -eq $DIALOG_HELP ]; then
|
||||
f_show_help "$MEDIA_HELPFILE"
|
||||
continue
|
||||
elif [ $retval -ne 0 ]; then
|
||||
elif [ $retval -ne $DIALOG_OK ]; then
|
||||
return $FAILURE
|
||||
fi
|
||||
|
||||
|
@ -170,7 +170,7 @@ f_media_shutdown_cdrom()
|
||||
{
|
||||
local dev="$1" err
|
||||
|
||||
[ "$CDROM_MOUNTED" ] || return
|
||||
[ "$CDROM_MOUNTED" ] || return $FAILURE
|
||||
|
||||
if [ "$CDROM_PREVIOUSLY_MOUNTED" ]; then
|
||||
CDROM_MOUNTED=
|
||||
|
@ -127,7 +127,7 @@ f_media_generic_get()
|
||||
fi
|
||||
[ "$probe_type" ] && return $SUCCESS
|
||||
cat "$path"
|
||||
return
|
||||
return $?
|
||||
fi
|
||||
done
|
||||
|
||||
|
@ -148,7 +148,7 @@ f_media_shutdown_dos()
|
||||
{
|
||||
local dev="$1" err
|
||||
|
||||
[ "$DOS_MOUNTED" ] || return
|
||||
[ "$DOS_MOUNTED" ] || return $FAILURE
|
||||
|
||||
if ! err=$( umount -f "$MOUNTPOINT" 2>&1 ); then
|
||||
err="${err#umount: }"; err="${err#*: }"
|
||||
|
@ -205,7 +205,7 @@ f_media_shutdown_floppy()
|
||||
{
|
||||
local dev="$1" err mp
|
||||
|
||||
[ "$FLOPPY_MOUNTED" ] || return
|
||||
[ "$FLOPPY_MOUNTED" ] || return $FAILURE
|
||||
|
||||
device_$dev get private mp
|
||||
if ! err=$( umount -f "${mp:=$MOUNTPOINT}" 2>&1 ); then
|
||||
|
@ -213,7 +213,7 @@ f_dialog_menu_media_ftp()
|
||||
$height $width $rows \
|
||||
$menu_list \
|
||||
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
|
||||
) || return $FAILURE
|
||||
) || return $DIALOG_CANCEL
|
||||
f_dialog_data_sanitize mtag
|
||||
|
||||
case "$mtag" in
|
||||
@ -224,7 +224,7 @@ f_dialog_menu_media_ftp()
|
||||
setvar $VAR_FTP_PATH "ftp://$value"
|
||||
esac
|
||||
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
# f_media_set_ftp
|
||||
@ -740,7 +740,7 @@ f_media_init_ftp()
|
||||
else
|
||||
f_yesno "$msg_cant_find_distribution" \
|
||||
"$rel" "$ftp_host"
|
||||
if [ $? -eq $SUCCESS ]; then
|
||||
if [ $? -eq $DIALOG_OK ]; then
|
||||
unset $VAR_FTP_PATH
|
||||
f_media_set_ftp && continue
|
||||
fi
|
||||
|
@ -101,7 +101,7 @@ f_dialog_menu_media_http()
|
||||
$height $width $rows \
|
||||
$menu_list \
|
||||
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
|
||||
) || return $FAILURE
|
||||
) || return $DIALOG_CANCEL
|
||||
f_dialog_data_sanitize mtag
|
||||
|
||||
case "$mtag" in
|
||||
@ -112,7 +112,7 @@ f_dialog_menu_media_http()
|
||||
setvar $VAR_HTTP_PATH "http://$value"
|
||||
esac
|
||||
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
# f_media_set_http
|
||||
|
@ -233,7 +233,7 @@ f_media_shutdown_nfs()
|
||||
{
|
||||
local dev="$1" err
|
||||
|
||||
[ "$NFS_MOUNTED" ] || return
|
||||
[ "$NFS_MOUNTED" ] || return $FAILURE
|
||||
|
||||
f_dprintf "Unmounting NFS partition on %s" "$MOUNTPOINT"
|
||||
if ! err=$( umount -f "$MOUNTPOINT" 2>&1 ); then
|
||||
|
@ -224,11 +224,10 @@ f_media_options_menu()
|
||||
defaultitem="$mtag"
|
||||
f_dprintf "retval=%s mtag=[%s]" $retval "$mtag"
|
||||
|
||||
if [ $retval -eq 2 ]; then
|
||||
# The Help button was pressed
|
||||
if [ $retval -eq $DIALOG_HELP ]; then
|
||||
f_show_help "$OPTIONS_HELPFILE"
|
||||
continue
|
||||
elif [ $retval -ne 0 ]; then
|
||||
elif [ $retval -ne $DIALOG_OK ]; then
|
||||
break # to success
|
||||
fi
|
||||
|
||||
|
@ -471,10 +471,10 @@ f_dialog_validate_tcpip()
|
||||
! f_validate_gateway "$gateway" "$ipaddr" "$netmask"; then
|
||||
f_show_msg "$msg_invalid_gateway_ipv4_address_specified"
|
||||
else
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
fi
|
||||
|
||||
return $FAILURE
|
||||
return $DIALOG_CANCEL
|
||||
}
|
||||
|
||||
# f_ifconfig_inet $interface [$var_to_set]
|
||||
@ -1102,7 +1102,7 @@ f_device_dialog_tcp()
|
||||
local use_dhcp="" use_rtsol=""
|
||||
local _ipaddr _netmask _extras
|
||||
|
||||
[ "$dev" ] || return $FAILURE
|
||||
[ "$dev" ] || return $DIALOG_CANCEL
|
||||
|
||||
# Initialize vars from previous device values
|
||||
local private
|
||||
@ -1125,7 +1125,6 @@ f_device_dialog_tcp()
|
||||
unset $VAR_NONINTERACTIVE
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Try a RTSOL scan if such behavior is desired.
|
||||
# If the variable was configured and is YES, do it.
|
||||
@ -1321,7 +1320,7 @@ f_device_dialog_tcp()
|
||||
if [ ! "$cp" ]; then
|
||||
# User either chose "Cancel", pressed
|
||||
# ESC, or blanked every form field
|
||||
return $FAILURE
|
||||
return $DIALOG_CANCEL
|
||||
else
|
||||
n=$( echo "$cp" | f_number_of_lines )
|
||||
[ $n -eq 1 ] && case "$cp" in HELP*)
|
||||
@ -1404,14 +1403,12 @@ f_device_dialog_tcp()
|
||||
f_dialog_data_sanitize cp
|
||||
f_dprintf "retval=%u mtag=[%s]" $retval "$cp"
|
||||
|
||||
if [ $retval -eq 2 ]; then
|
||||
# The Help button was pressed
|
||||
if [ $retval -eq $DIALOG_HELP ]; then
|
||||
f_show_help "$TCP_HELPFILE"
|
||||
continue
|
||||
elif [ $retval -ne 0 ]; then
|
||||
# User chose "Cancel" or pressed ESC
|
||||
elif [ $retval -ne $DIALOG_OK ]; then
|
||||
f_dialog_title_restore
|
||||
return $FAILURE
|
||||
return $DIALOG_CANCEL
|
||||
fi
|
||||
|
||||
case "$cp" in
|
||||
@ -1490,7 +1487,7 @@ f_device_dialog_tcp()
|
||||
[ "$use_dhcp" ] ||
|
||||
f_config_resolv # XXX this will do it on the MFS copy
|
||||
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
# f_device_scan_tcp [$var_to_set]
|
||||
@ -1586,15 +1583,15 @@ f_device_select_tcp()
|
||||
if [ ${cnt:=0} -gt 0 ]; then
|
||||
dev="${devs%%[$IFS]*}"
|
||||
f_device_dialog_tcp $dev
|
||||
if [ $? -eq $SUCCESS ]; then
|
||||
if [ $? -eq $DIALOG_OK ]; then
|
||||
setvar $VAR_NETWORK_DEVICE $dev
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
f_interactive && f_show_msg "$msg_no_network_devices"
|
||||
return $FAILURE
|
||||
return $DIALOG_CANCEL
|
||||
|
||||
fi # $network_dev
|
||||
|
||||
@ -1610,18 +1607,18 @@ f_device_select_tcp()
|
||||
if f_dialog_yesno "$msg_assume_network_is_already_configured"
|
||||
then
|
||||
setvar $VAR_NETWORK_DEVICE $dev
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
fi
|
||||
fi
|
||||
|
||||
local retval=$SUCCESS
|
||||
if [ ${cnt:=0} -eq 0 ]; then
|
||||
f_show_msg "$msg_no_network_devices"
|
||||
retval=$FAILURE
|
||||
retval=$DIALOG_CANCEL
|
||||
elif [ $cnt -eq 1 ]; then
|
||||
f_device_dialog_tcp $dev
|
||||
retval=$?
|
||||
[ $retval -eq $SUCCESS ] && setvar $VAR_NETWORK_DEVICE $dev
|
||||
[ $retval -eq $DIALOG_OK ] && setvar $VAR_NETWORK_DEVICE $dev
|
||||
else
|
||||
local title="$msg_network_interface_information_required"
|
||||
local prompt="$msg_please_select_ethernet_device_to_configure"
|
||||
@ -1632,15 +1629,15 @@ f_device_select_tcp()
|
||||
"$NETWORK_DEVICE_HELPFILE" \
|
||||
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD )
|
||||
retval=$?
|
||||
[ "$dev" ] || return $FAILURE
|
||||
[ "$dev" ] || return $DIALOG_CANCEL
|
||||
|
||||
f_device_find "$dev" $DEVICE_TYPE_NETWORK devs
|
||||
[ "$devs" ] || return $FAILURE
|
||||
[ "$devs" ] || return $DIALOG_CANCEL
|
||||
dev="${devs%%[$IFS]*}"
|
||||
|
||||
f_device_dialog_tcp $dev
|
||||
retval=$?
|
||||
if [ $retval -eq $SUCCESS ]; then
|
||||
if [ $retval -eq $DIALOG_OK ]; then
|
||||
f_struct_copy device_$dev device_network
|
||||
setvar $VAR_NETWORK_DEVICE network
|
||||
else
|
||||
@ -1675,7 +1672,7 @@ f_dialog_menu_select_tcp()
|
||||
"$name"
|
||||
fi
|
||||
fi
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
############################################################ MAIN
|
||||
|
@ -177,7 +177,7 @@ f_media_shutdown_ufs()
|
||||
{
|
||||
local dev="$1" err
|
||||
|
||||
[ "$UFS_MOUNTED" ] || return
|
||||
[ "$UFS_MOUNTED" ] || return $FAILURE
|
||||
|
||||
if ! err=$( umount -f "$MOUNTPOINT" 2>&1 ); then
|
||||
err="${err#umount: }"; err="${err#*: }"
|
||||
|
@ -158,7 +158,7 @@ f_media_shutdown_usb()
|
||||
{
|
||||
local dev="$1" err
|
||||
|
||||
[ "$USB_MOUNTED" ] || return
|
||||
[ "$USB_MOUNTED" ] || return $FAILURE
|
||||
|
||||
if ! err=$( umount -f "$MOUNTPOINT" 2>&1 ); then
|
||||
err="${err#umount: }"; err="${err#*: }"
|
||||
|
@ -176,9 +176,9 @@ f_become_root_via_sudo()
|
||||
retval=$?
|
||||
|
||||
# Catch X11-related errors
|
||||
if [ $retval -eq 255 ]; then
|
||||
if [ $retval -eq $DIALOG_ESC ]; then
|
||||
f_die $retval "$password"
|
||||
elif [ $retval -ne 0 ]; then
|
||||
elif [ $retval -ne $DIALOG_OK ]; then
|
||||
# User cancelled
|
||||
exit $retval
|
||||
fi
|
||||
@ -316,10 +316,10 @@ f_authenticate_some_user()
|
||||
retval=$?
|
||||
|
||||
# Catch X11-related errors
|
||||
[ $retval -eq 255 ] && f_die $retval "$user_pass"
|
||||
[ $retval -eq $DIALOG_ESC ] && f_die $retval "$user_pass"
|
||||
|
||||
# Exit if the user cancelled.
|
||||
[ $retval -eq $SUCCESS ] || exit $retval
|
||||
[ $retval -eq $DIALOG_OK ] || exit $retval
|
||||
|
||||
#
|
||||
# Make sure the user exists and is non-root
|
||||
|
@ -132,7 +132,7 @@ f_package_select()
|
||||
package="$1"
|
||||
shift 1 # package
|
||||
for pkgsel in $SELECTED_PACKAGES; do
|
||||
[ "$package" = "$pkgsel" ] && return
|
||||
[ "$package" = "$pkgsel" ] && return $SUCCESS
|
||||
done
|
||||
SELECTED_PACKAGES="$SELECTED_PACKAGES $package"
|
||||
f_dprintf "Added %s to selection list" "$package"
|
||||
@ -312,7 +312,7 @@ f_package_menu_categories()
|
||||
# creates _{varcat}_ninstalled and _{varcat}_nselected
|
||||
|
||||
local category_list
|
||||
debug= f_getvar "$var_to_get" category_list || return $FAILURE
|
||||
debug= f_getvar "$var_to_get" category_list || return $DIALOG_CANCEL
|
||||
|
||||
# Accent the category menu list with ninstalled/nselected
|
||||
eval f_package_accent_category_menu category_list $category_list
|
||||
@ -395,7 +395,7 @@ f_package_menu_select()
|
||||
local defaultitem="$3"
|
||||
local hline="$hline_arrows_tab_punc_enter"
|
||||
|
||||
f_isinteger "$page" || return $FAILURE
|
||||
f_isinteger "$page" || return $DIALOG_CANCEL
|
||||
|
||||
local varcat
|
||||
f_str2varname "$category" varcat
|
||||
@ -518,7 +518,7 @@ f_package_menu_select()
|
||||
f_dialog_data_sanitize menu_choice
|
||||
f_dialog_menutag_store "$menu_choice"
|
||||
|
||||
if [ $retval -eq $SUCCESS ]; then
|
||||
if [ $retval -eq $DIALOG_OK ]; then
|
||||
local item
|
||||
item=$( eval f_dialog_menutag2item${SHOW_DESC:+_with_help} \
|
||||
\"\$menu_choice\" $menu_list )
|
||||
@ -603,7 +603,7 @@ f_package_review()
|
||||
done
|
||||
if [ ! "$menu_list" ]; then
|
||||
f_show_msg "$msg_no_packages_were_selected_for_extraction"
|
||||
return $FAILURE # They might have selected this by accident
|
||||
return $DIALOG_CANCEL # Might have selected this by accident
|
||||
fi
|
||||
menu_list=$( echo "$menu_list" | sort )
|
||||
|
||||
@ -660,7 +660,7 @@ f_package_review()
|
||||
f_package_deselect "$package"
|
||||
done
|
||||
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
# f_package_config
|
||||
@ -693,7 +693,7 @@ f_package_config()
|
||||
f_dprintf "retval=%u mtag=[%s]" $retval "$category"
|
||||
category_defaultitem="$category"
|
||||
|
||||
[ $retval -eq $SUCCESS ] || break
|
||||
[ $retval -eq $DIALOG_OK ] || break
|
||||
|
||||
# Maybe the user chose an action (like `Review')
|
||||
case "$category" in
|
||||
@ -729,14 +729,14 @@ f_package_config()
|
||||
# the Cancel button because stdout will be NULL.
|
||||
# Alternatively, Xdialog(1) will terminate with 1
|
||||
# if/when Cancel is chosen on any widget.
|
||||
if [ $retval -eq 255 -o ! "$menu_choice" ]; then
|
||||
# User pressed ESC or chose Cancel
|
||||
if [ $retval -eq $DIALOG_ESC -o ! "$menu_choice" ]
|
||||
then
|
||||
break
|
||||
elif [ $retval -eq 1 ]; then
|
||||
elif [ $retval -eq $DIALOG_CANCEL ]; then
|
||||
# Using X11, Xdialog(1) returned 1 for Cancel
|
||||
f_show_msg "%s" "$menu_choice"
|
||||
break
|
||||
elif [ $retval -ne $SUCCESS ]; then
|
||||
elif [ $retval -ne $DIALOG_OK ]; then
|
||||
# X11-related error occurred using Xdialog(1)
|
||||
f_show_msg "%s" "$menu_choice"
|
||||
break
|
||||
|
@ -309,10 +309,10 @@ dialog_input_value()
|
||||
f_dialog_title_restore
|
||||
|
||||
# Return if user has either pressed ESC or chosen Cancel/No
|
||||
[ $retval -eq $SUCCESS ] || return $retval
|
||||
[ $retval -eq $DIALOG_OK ] || return $retval
|
||||
|
||||
value="$_input"
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
############################################################ MAIN
|
||||
@ -429,7 +429,7 @@ while :; do
|
||||
;;
|
||||
esac
|
||||
|
||||
[ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n"
|
||||
[ $? -eq $DIALOG_OK ] || f_dialog_msgbox "$err\n"
|
||||
done
|
||||
|
||||
exit $SUCCESS
|
||||
|
@ -195,7 +195,7 @@ dialog_menu_main()
|
||||
f_dialog_menutag_store "$menu_choice"
|
||||
|
||||
# Only update default-item on success
|
||||
[ $retval -eq 0 ] && f_dialog_default_store "$menu_choice"
|
||||
[ $retval -eq $DIALOG_OK ] && f_dialog_default_store "$menu_choice"
|
||||
|
||||
return $retval
|
||||
}
|
||||
@ -236,13 +236,13 @@ while :; do
|
||||
f_dialog_input_view_details
|
||||
continue
|
||||
esac
|
||||
elif [ $retval -eq 2 ]; then
|
||||
elif [ $retval -eq $DIALOG_HELP ]; then
|
||||
# The ``Help'' button (labeled "Details") was pressed
|
||||
f_dialog_input_view_details
|
||||
continue
|
||||
fi
|
||||
|
||||
[ $retval -eq 0 ] || f_die
|
||||
[ $retval -eq $DIALOG_OK ] || f_die
|
||||
|
||||
case "$mtag" in
|
||||
"X $msg_exit") break ;;
|
||||
|
@ -232,7 +232,7 @@ dialog_menu_main()
|
||||
f_dialog_menutag_store "$menu_choice"
|
||||
|
||||
# Only update default-item on success
|
||||
[ $retval -eq 0 ] && f_dialog_default_store "$menu_choice"
|
||||
[ $retval -eq $DIALOG_OK ] && f_dialog_default_store "$menu_choice"
|
||||
|
||||
return $retval
|
||||
}
|
||||
@ -249,7 +249,7 @@ dialog_menu_confirm_delete()
|
||||
local menu_list # Calculated below
|
||||
local hline="$hline_arrows_tab_enter"
|
||||
|
||||
[ $# -ge 1 ] || return $FAILURE
|
||||
[ $# -ge 1 ] || return $DIALOG_CANCEL
|
||||
|
||||
# If asked to delete only one variable, simply ask and return
|
||||
if [ $# -eq 1 ]; then
|
||||
@ -351,13 +351,13 @@ while :; do
|
||||
f_dialog_input_view_details && dialog_create_main
|
||||
continue
|
||||
esac
|
||||
elif [ $retval -eq 2 ]; then
|
||||
elif [ $retval -eq $DIALOG_HELP ]; then
|
||||
# The ``Help'' button (labeled "Details") was pressed
|
||||
f_dialog_input_view_details && dialog_create_main
|
||||
continue
|
||||
fi
|
||||
|
||||
[ $retval -eq 0 ] || f_die
|
||||
[ $retval -eq $DIALOG_OK ] || f_die
|
||||
|
||||
case "$mtag" in
|
||||
"X $msg_exit_cancel") break ;;
|
||||
|
@ -158,7 +158,7 @@ dialog_menu_main()
|
||||
f_dialog_menutag_store "$menu_choice"
|
||||
f_dialog_default_store "$menu_choice"
|
||||
|
||||
if [ $retval -eq $SUCCESS ]; then
|
||||
if [ $retval -eq $DIALOG_OK ]; then
|
||||
local item
|
||||
item=$( eval f_dialog_menutag2item${SHOW_DESC:+_with_help} \
|
||||
\"\$menu_choice\" $menu_list )
|
||||
|
@ -336,7 +336,7 @@ f_dialog_input_view_details()
|
||||
|
||||
f_dialog_title_restore
|
||||
|
||||
[ $retval -eq 0 ] || return $FAILURE
|
||||
[ $retval -eq $DIALOG_OK ] || return $DIALOG_CANCEL
|
||||
|
||||
case "$mtag" in
|
||||
"R $msg_reset")
|
||||
@ -465,7 +465,7 @@ f_dialog_input_rcvar()
|
||||
|
||||
# Return if user either pressed ESC or chosen Cancel/No
|
||||
f_dialog_input _input "$msg_please_enter_rcvar_name" \
|
||||
"$_input" "$hline_alnum_tab_enter" || return
|
||||
"$_input" "$hline_alnum_tab_enter" || return $?
|
||||
|
||||
# Check for invalid entry (1of2)
|
||||
if ! echo "$_input" | grep -q "^[[:alpha:]_]"; then
|
||||
@ -486,7 +486,7 @@ f_dialog_input_rcvar()
|
||||
|
||||
f_dprintf "f_dialog_input_rcvar: rcvar->[%s]" "$rcvar"
|
||||
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
############################################################ MAIN
|
||||
|
@ -69,11 +69,11 @@ f_dialog_rcedit()
|
||||
|
||||
# Return if user has either pressed ESC or chosen Cancel/No
|
||||
f_dialog_input _input "$msg" "$_input" \
|
||||
"$hline_alnum_punc_tab_enter" || return
|
||||
"$hline_alnum_punc_tab_enter" || return $?
|
||||
|
||||
# Return if the value has not changed from current
|
||||
local cur_val="$( f_sysrc_get "$var" )"
|
||||
[ "$_input" = "$cur_val" ] && return $SUCCESS
|
||||
[ "$_input" = "$cur_val" ] && return $DIALOG_OK
|
||||
|
||||
f_dprintf "%s: [%s]->[%s]" "$var" "$cur_val" "$_input"
|
||||
|
||||
|
@ -226,7 +226,7 @@ if [ "$_PATH_WALL_CMOS_CLOCK" -a ! "$SKIPUTC" ]; then
|
||||
result=$?
|
||||
fi
|
||||
|
||||
if [ $result -eq 0 ]; then
|
||||
if [ $result -eq $DIALOG_OK ]; then
|
||||
# User chose YES
|
||||
[ "$REALLYDOIT" ] &&
|
||||
f_quietly rm -f "$_PATH_WALL_CMOS_CLOCK"
|
||||
@ -250,7 +250,7 @@ if [ $# -ge 1 ]; then
|
||||
result=$?
|
||||
f_dialog_title_restore
|
||||
|
||||
if [ $result -eq 0 ]; then
|
||||
if [ $result -eq $DIALOG_OK ]; then
|
||||
# User chose YES
|
||||
f_install_zoneinfo_file "$default"
|
||||
result=$?
|
||||
@ -287,7 +287,7 @@ while :; do
|
||||
retval=$?
|
||||
f_dialog_menutag_fetch mtag
|
||||
|
||||
if [ $retval -ne 0 ]; then
|
||||
if [ $retval -ne $DIALOG_OK ]; then
|
||||
[ "$TZ_OR_FAIL" ] && f_die
|
||||
exit $SUCCESS
|
||||
fi
|
||||
@ -368,7 +368,7 @@ while :; do
|
||||
f_dialog_data_sanitize tag
|
||||
defaultctry="$tag"
|
||||
|
||||
if [ $retval -ne 0 ]; then
|
||||
if [ $retval -ne $DIALOG_OK ]; then
|
||||
NEED_CONTINENT=1
|
||||
continue # back to main menu
|
||||
fi
|
||||
@ -427,7 +427,7 @@ while :; do
|
||||
f_dialog_data_sanitize n
|
||||
defaultzone="$n"
|
||||
|
||||
if [ $retval -ne 0 ]; then
|
||||
if [ $retval -ne $DIALOG_OK ]; then
|
||||
[ $nitems -eq 1 ] && NEED_CONTINENT=1
|
||||
NEED_COUNTRY=1
|
||||
continue
|
||||
@ -441,7 +441,7 @@ while :; do
|
||||
f_confirm_zone "$real_continent/$filename" || continue
|
||||
fi
|
||||
|
||||
[ $retval -eq 0 ] || continue # back to main menu
|
||||
[ $retval -eq $DIALOG_OK ] || continue # back to main menu
|
||||
|
||||
if ! f_install_zoneinfo "$real_continent/$filename"; then
|
||||
[ $nzones -lt 0 ] && NEED_COUNTRY=1
|
||||
|
@ -75,7 +75,7 @@ while :; do
|
||||
f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
|
||||
defaultitem="$mtag"
|
||||
|
||||
[ $retval -eq 0 ] || f_die
|
||||
[ $retval -eq $DIALOG_OK ] || f_die
|
||||
|
||||
[ "$mtag" = "X $msg_exit" ] && break
|
||||
|
||||
|
@ -75,7 +75,7 @@ while :; do
|
||||
f_dprintf "retval=%s mtag=[%s]" $retval "$mtag"
|
||||
defaultitem="$mtag"
|
||||
|
||||
[ $retval -eq 0 ] || f_die
|
||||
[ $retval -eq $DIALOG_OK ] || f_die
|
||||
|
||||
[ "$mtag" = "X $msg_exit" ] && break
|
||||
|
||||
|
@ -162,9 +162,9 @@ if [ "$mode" = "Add" ]; then
|
||||
f_dialog_noyes "$msg_use_default_values_for_all_account_details"
|
||||
retval=$?
|
||||
|
||||
if [ $retval -eq 255 ]; then # User pressed ESC
|
||||
if [ $retval -eq $DIALOG_ESC ]; then
|
||||
exit $SUCCESS
|
||||
elif [ $retval -ne $SUCCESS ]; then
|
||||
elif [ $retval -ne $DIALOG_OK ]; then
|
||||
#
|
||||
# Ask a series of questions to pre-fill the editor screen.
|
||||
#
|
||||
@ -174,9 +174,9 @@ if [ "$mode" = "Add" ]; then
|
||||
#
|
||||
|
||||
[ "$passwdtype" = "yes" ] &&
|
||||
{ f_dialog_input_group_password || exit 0; }
|
||||
f_dialog_input_group_gid || exit 0
|
||||
f_dialog_input_group_members || exit 0
|
||||
{ f_dialog_input_group_password || exit $SUCCESS; }
|
||||
f_dialog_input_group_gid || exit $SUCCESS
|
||||
f_dialog_input_group_members || exit $SUCCESS
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -255,13 +255,11 @@ while :; do
|
||||
f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
|
||||
|
||||
# Exit if user has either pressed ESC or chosen Cancel/No
|
||||
[ $retval -eq $SUCCESS ] || f_die
|
||||
[ $retval -eq $DIALOG_OK ] || f_die
|
||||
|
||||
case "$mtag" in
|
||||
X) # Exit
|
||||
if [ "$save_flag" ]; then
|
||||
save_changes || continue
|
||||
fi
|
||||
[ "$save_flag" ] && { save_changes || continue; }
|
||||
break
|
||||
;;
|
||||
1) # Group Name
|
||||
@ -274,7 +272,7 @@ while :; do
|
||||
f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
|
||||
|
||||
# Loop if user has either pressed ESC or chosen Cancel/No
|
||||
[ $retval -eq $SUCCESS ] || continue
|
||||
[ $retval -eq $DIALOG_OK ] || continue
|
||||
|
||||
[ "$mtag" = "X $msg_exit" ] && continue
|
||||
|
||||
|
@ -125,15 +125,15 @@ f_dialog_input_group_name()
|
||||
|
||||
# Return if user has either pressed ESC or chosen Cancel/No
|
||||
f_dialog_input _input "$msg_group" "$_input" \
|
||||
"$hline_alnum_tab_enter" || return
|
||||
"$hline_alnum_tab_enter" || return $?
|
||||
|
||||
# Check for no-change
|
||||
[ "$_input" = "$_name" ] && return $SUCCESS
|
||||
[ "$_input" = "$_name" ] && return $DIALOG_OK
|
||||
|
||||
# Check for reversion
|
||||
if [ "$_input" = "$cur_group_name" ]; then
|
||||
group_name="$cur_group_name"
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
fi
|
||||
|
||||
# Check for NULL entry
|
||||
@ -161,7 +161,7 @@ f_dialog_input_group_name()
|
||||
|
||||
f_dprintf "group_name: [%s]->[%s]" "$cur_group_name" "$group_name"
|
||||
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
# f_dialog_input_group_password
|
||||
@ -210,7 +210,7 @@ f_dialog_input_group_password()
|
||||
debug= f_dialog_line_sanitize _password1
|
||||
|
||||
# Return if user has either pressed ESC or chosen Cancel/No
|
||||
[ $retval -eq $SUCCESS ] || return $retval
|
||||
[ $retval -eq $DIALOG_OK ] || return $retval
|
||||
|
||||
_password2=$( $DIALOG \
|
||||
--title "$DIALOG_TITLE" \
|
||||
@ -227,7 +227,7 @@ f_dialog_input_group_password()
|
||||
debug= f_dialog_line_sanitize _password2
|
||||
|
||||
# Return if user has either pressed ESC or chosen Cancel/No
|
||||
[ $retval -eq $SUCCESS ] || return $retval
|
||||
[ $retval -eq $DIALOG_OK ] || return $retval
|
||||
|
||||
# Check for password mismatch
|
||||
if [ "$_password1" != "$_password2" ]; then
|
||||
@ -239,9 +239,9 @@ f_dialog_input_group_password()
|
||||
if [ ! "$_password1" ]; then
|
||||
f_dialog_yesno "$msg_disable_password_auth_for_group"
|
||||
local retval=$?
|
||||
if [ $retval -eq 255 ]; then # ESC was pressed
|
||||
if [ $retval -eq $DIALOG_ESC ]; then
|
||||
return $retval
|
||||
elif [ $retval -eq $SUCCESS ]; then
|
||||
elif [ $retval -eq $DIALOG_OK ]; then
|
||||
pw_group_password_disable=1
|
||||
else
|
||||
continue # back to password prompt
|
||||
@ -258,7 +258,7 @@ f_dialog_input_group_password()
|
||||
f_dprintf "group_password: [%s]->[%s]" \
|
||||
"$cur_group_password" "$group_password"
|
||||
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
# f_dialog_input_group_gid [$group_gid]
|
||||
@ -273,14 +273,14 @@ f_dialog_input_group_gid()
|
||||
|
||||
# Return if user has either pressed ESC or chosen Cancel/No
|
||||
f_dialog_input _input "$msg_group_id_leave_empty_for_default" \
|
||||
"$_input" "$hline_num_tab_enter" || return
|
||||
"$_input" "$hline_num_tab_enter" || return $?
|
||||
|
||||
group_gid="$_input"
|
||||
save_flag=1
|
||||
|
||||
f_dprintf "group_gid: [%s]->[%s]" "$cur_group_gid" "$group_gid"
|
||||
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
# f_dialog_input_group_members [$group_members]
|
||||
@ -329,7 +329,7 @@ f_dialog_input_group_members()
|
||||
f_dprintf "retval=%u menu_choice=[%s]" $retval "$menu_choice"
|
||||
|
||||
# Return if user has either pressed ESC or chosen Cancel/No
|
||||
[ $retval -eq $SUCCESS ] || return $retval
|
||||
[ $retval -eq $DIALOG_OK ] || return $retval
|
||||
|
||||
local _group_members
|
||||
case "$menu_choice" in
|
||||
@ -399,7 +399,7 @@ f_dialog_input_group_members()
|
||||
f_dprintf "group_members: [%s]->[%s]" \
|
||||
"$cur_group_members" "$group_members"
|
||||
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
############################################################ MAIN
|
||||
|
@ -206,7 +206,7 @@ f_dialog_input_member_groups()
|
||||
f_dprintf "pw_member_groups: [%s]->[%s]" \
|
||||
"$cur_pw_member_groups" "$pw_member_groups"
|
||||
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
# f_dialog_input_name [$name]
|
||||
@ -229,15 +229,15 @@ f_dialog_input_name()
|
||||
|
||||
# Return if user has either pressed ESC or chosen Cancel/No
|
||||
f_dialog_input _input "$msg_login" "$_input" \
|
||||
"$hline_alnum_tab_enter" || return
|
||||
"$hline_alnum_tab_enter" || return $?
|
||||
|
||||
# Check for no-change
|
||||
[ "$_input" = "$_name" ] && return $SUCCESS
|
||||
[ "$_input" = "$_name" ] && return $DIALOG_OK
|
||||
|
||||
# Check for reversion
|
||||
if [ "$_input" = "$cur_pw_name" ]; then
|
||||
pw_name="$cur_pw_name"
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
fi
|
||||
|
||||
# Check for NULL entry
|
||||
@ -265,7 +265,7 @@ f_dialog_input_name()
|
||||
|
||||
f_dprintf "pw_name: [%s]->[%s]" "$cur_pw_name" "$pw_name"
|
||||
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
# f_dialog_input_password
|
||||
@ -336,9 +336,9 @@ f_dialog_input_password()
|
||||
if [ ! "$_password1" ]; then
|
||||
f_dialog_yesno "$msg_disable_password_auth_for_account"
|
||||
local retval=$?
|
||||
if [ $retval -eq 255 ]; then # ESC was pressed
|
||||
if [ $retval -eq $DIALOG_ESC ]; then
|
||||
return $retval
|
||||
elif [ $retval -eq $SUCCESS ]; then
|
||||
elif [ $retval -eq $DIALOG_OK ]; then
|
||||
pw_password_disable=1
|
||||
else
|
||||
continue # back to password prompt
|
||||
@ -354,7 +354,7 @@ f_dialog_input_password()
|
||||
|
||||
f_dprintf "pw_password: [%s]->[%s]" "$cur_pw_password" "$pw_password"
|
||||
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
# f_dialog_input_gecos [$gecos]
|
||||
@ -370,14 +370,14 @@ f_dialog_input_gecos()
|
||||
|
||||
# Return if user has either pressed ESC or chosen Cancel/No
|
||||
f_dialog_input _input "$msg_full_name" "$_input" \
|
||||
"$hline_alnum_punc_tab_enter" || return
|
||||
"$hline_alnum_punc_tab_enter" || return $?
|
||||
|
||||
pw_gecos="$_input"
|
||||
save_flag=1
|
||||
|
||||
f_dprintf "pw_gecos: [%s]->[%s]" "$cur_pw_gecos" "$pw_gecos"
|
||||
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
# f_dialog_input_uid [$uid]
|
||||
@ -392,14 +392,14 @@ f_dialog_input_uid()
|
||||
|
||||
# Return if user has either pressed ESC or chosen Cancel/No
|
||||
f_dialog_input _input "$msg_user_id_leave_empty_for_default" \
|
||||
"$_input" "$hline_num_tab_enter" || return
|
||||
"$_input" "$hline_num_tab_enter" || return $?
|
||||
|
||||
pw_uid="$_input"
|
||||
save_flag=1
|
||||
|
||||
f_dprintf "pw_uid: [%s]->[%s]" "$cur_pw_uid" "$pw_uid"
|
||||
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
# f_dialog_input_gid [$gid]
|
||||
@ -414,14 +414,14 @@ f_dialog_input_gid()
|
||||
|
||||
# Return if user has either pressed ESC or chosen Cancel/No
|
||||
f_dialog_input _input "$msg_group_id_leave_empty_for_default" \
|
||||
"$_input" "$hline_num_tab_enter" || return
|
||||
"$_input" "$hline_num_tab_enter" || return $?
|
||||
|
||||
pw_gid="$_input"
|
||||
save_flag=1
|
||||
|
||||
f_dprintf "pw_gid: [%s]->[%s]" "$cur_pw_gid" "$pw_gid"
|
||||
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
# f_dialog_input_class [$class]
|
||||
@ -436,14 +436,14 @@ f_dialog_input_class()
|
||||
|
||||
# Return if user has either pressed ESC or chosen Cancel/No
|
||||
f_dialog_input _input "$msg_login_class" "$_input" \
|
||||
"$hline_alnum_tab_enter" || return
|
||||
"$hline_alnum_tab_enter" || return $?
|
||||
|
||||
pw_class="$_input"
|
||||
save_flag=1
|
||||
|
||||
f_dprintf "pw_class: [%s]->[%s]" "$cur_pw_class" "$pw_class"
|
||||
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
# f_dialog_input_expire_password [$seconds]
|
||||
@ -508,7 +508,7 @@ f_dialog_input_expire_password()
|
||||
f_dprintf "retval=%u date_type=[%s]" $retval "$date_type"
|
||||
|
||||
# Return if user has either pressed ESC or chosen Cancel/No
|
||||
[ $retval -eq $SUCCESS ] || return $retval
|
||||
[ $retval -eq $DIALOG_OK ] || return $retval
|
||||
|
||||
case "$date_type" in
|
||||
1) # Password does not expire
|
||||
@ -538,7 +538,7 @@ f_dialog_input_expire_password()
|
||||
f_dprintf "retval=%u ret_date=[%s]" $retval "$ret_date"
|
||||
|
||||
# Return to menu if either ESC or Cancel/No
|
||||
[ $retval -eq $SUCCESS ] || continue
|
||||
[ $retval -eq $DIALOG_OK ] || continue
|
||||
|
||||
_input_time=
|
||||
[ "$secs" ] && _input_time=$( date -j \
|
||||
@ -559,7 +559,7 @@ f_dialog_input_expire_password()
|
||||
f_dprintf "retval=%u ret_time=[%s]" $retval "$ret_time"
|
||||
|
||||
# Return to menu if either ESC or Cancel/No
|
||||
[ $retval -eq $SUCCESS ] || continue
|
||||
[ $retval -eq $DIALOG_OK ] || continue
|
||||
|
||||
_input=$( date \
|
||||
-j -f "%d/%m/%Y %T" \
|
||||
@ -627,7 +627,7 @@ f_dialog_input_expire_password()
|
||||
f_dprintf "pw_password_expire: [%s]->[%s]" \
|
||||
"$cur_pw_password_expire" "$pw_password_expire"
|
||||
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
# f_dialog_input_expire_account [$seconds]
|
||||
@ -692,7 +692,7 @@ f_dialog_input_expire_account()
|
||||
f_dprintf "retval=%u date_type=[%s]" $retval "$date_type"
|
||||
|
||||
# Return if user has either pressed ESC or chosen Cancel/No
|
||||
[ $retval -eq $SUCCESS ] || return $retval
|
||||
[ $retval -eq $DIALOG_OK ] || return $retval
|
||||
|
||||
case "$date_type" in
|
||||
1) # Account does not expire
|
||||
@ -722,7 +722,7 @@ f_dialog_input_expire_account()
|
||||
f_dprintf "retval=%u ret_date=[%s]" $retval "$ret_date"
|
||||
|
||||
# Return to menu if either ESC or Cancel/No
|
||||
[ $retval -eq $SUCCESS ] || continue
|
||||
[ $retval -eq $DIALOG_OK ] || continue
|
||||
|
||||
_input_time=
|
||||
[ "$secs" ] && _input_time=$( date -j \
|
||||
@ -743,7 +743,7 @@ f_dialog_input_expire_account()
|
||||
f_dprintf "retval=%u ret_time=[%s]" $retval "$ret_time"
|
||||
|
||||
# Return to menu if either ESC or Cancel/No
|
||||
[ $retval -eq $SUCCESS ] || continue
|
||||
[ $retval -eq $DIALOG_OK ] || continue
|
||||
|
||||
_input=$( date \
|
||||
-j -f "%d/%m/%Y %T" \
|
||||
@ -811,7 +811,7 @@ f_dialog_input_expire_account()
|
||||
f_dprintf "pw_account_expire: [%s]->[%s]" \
|
||||
"$cur_pw_account_expire" "$pw_account_expire"
|
||||
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
# f_dialog_input_home_dir [$home_dir]
|
||||
@ -826,14 +826,14 @@ f_dialog_input_home_dir()
|
||||
|
||||
# Return if user has either pressed ESC or chosen Cancel/No
|
||||
f_dialog_input _input "$msg_home_directory" "$_input" \
|
||||
"$hline_alnum_punc_tab_enter" || return
|
||||
"$hline_alnum_punc_tab_enter" || return $?
|
||||
|
||||
pw_home_dir="$_input"
|
||||
save_flag=1
|
||||
|
||||
f_dprintf "pw_home_dir: [%s]->[%s]" "$cur_pw_home_dir" "$pw_home_dir"
|
||||
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
# f_dialog_input_home_create
|
||||
@ -850,7 +850,7 @@ f_dialog_input_home_create()
|
||||
f_dialog_yesno "$msg_create_home_directory"
|
||||
retval=$?
|
||||
|
||||
if [ $retval -eq $SUCCESS ]; then
|
||||
if [ $retval -eq $DIALOG_OK ]; then
|
||||
pw_home_create="$msg_yes"
|
||||
else
|
||||
pw_home_create="$msg_no"
|
||||
@ -860,7 +860,7 @@ f_dialog_input_home_create()
|
||||
f_dprintf "pw_home_create: [%s]->[%s]" \
|
||||
"$cur_pw_home_create" "$pw_home_create"
|
||||
|
||||
[ $retval -ne 255 ] # return failure if user pressed ESC
|
||||
[ $retval -ne $DIALOG_ESC ] # return failure if user pressed ESC
|
||||
}
|
||||
|
||||
# f_dialog_input_group_delete
|
||||
@ -893,7 +893,7 @@ f_dialog_input_group_delete()
|
||||
fi
|
||||
retval=$?
|
||||
|
||||
if [ $retval -eq $SUCCESS ]; then
|
||||
if [ $retval -eq $DIALOG_OK ]; then
|
||||
pw_group_delete="$msg_yes"
|
||||
else
|
||||
pw_group_delete="$msg_no"
|
||||
@ -903,7 +903,7 @@ f_dialog_input_group_delete()
|
||||
f_dprintf "pw_group_delete: [%s]->[%s]" \
|
||||
"$cur_pw_group_delete" "$pw_group_delete"
|
||||
|
||||
[ $retval -ne 255 ] # return failure if user pressed ESC
|
||||
[ $retval -ne $DIALOG_ESC ] # return failure if user pressed ESC
|
||||
}
|
||||
|
||||
# f_dialog_input_home_delete
|
||||
@ -920,7 +920,7 @@ f_dialog_input_home_delete()
|
||||
f_dialog_yesno "$msg_delete_home_directory"
|
||||
retval=$?
|
||||
|
||||
if [ $retval -eq $SUCCESS ]; then
|
||||
if [ $retval -eq $DIALOG_OK ]; then
|
||||
pw_home_delete="$msg_yes"
|
||||
else
|
||||
pw_home_delete="$msg_no"
|
||||
@ -930,7 +930,7 @@ f_dialog_input_home_delete()
|
||||
f_dprintf "pw_home_delete: [%s]->[%s]" \
|
||||
"$cur_pw_home_delete" "$pw_home_delete"
|
||||
|
||||
[ $retval -ne 255 ] # return failure if user pressed ESC
|
||||
[ $retval -ne $DIALOG_ESC ] # return failure if user pressed ESC
|
||||
}
|
||||
|
||||
# f_dialog_input_dotfiles_create
|
||||
@ -948,7 +948,7 @@ f_dialog_input_dotfiles_create()
|
||||
f_dialog_yesno "$msg_create_dotfiles"
|
||||
retval=$?
|
||||
|
||||
if [ $retval -eq $SUCCESS ]; then
|
||||
if [ $retval -eq $DIALOG_OK ]; then
|
||||
pw_dotfiles_create="$msg_yes"
|
||||
else
|
||||
pw_dotfiles_create="$msg_no"
|
||||
@ -958,7 +958,7 @@ f_dialog_input_dotfiles_create()
|
||||
f_dprintf "pw_dotfiles_create: [%s]->[%s]" \
|
||||
"$cur_pw_dotfiles_create" "$pw_dotfiles_create"
|
||||
|
||||
[ $retval -ne 255 ] # return failure if user pressed ESC
|
||||
[ $retval -ne $DIALOG_ESC ] # return failure if user pressed ESC
|
||||
}
|
||||
|
||||
# f_dialog_input_shell [$shell]
|
||||
@ -1015,7 +1015,7 @@ f_dialog_input_shell()
|
||||
|
||||
f_dprintf "pw_shell: [%s]->[%s]" "$cur_pw_shell" "$pw_shell"
|
||||
|
||||
return $SUCCESS
|
||||
return $DIALOG_OK
|
||||
}
|
||||
|
||||
############################################################ MAIN
|
||||
|
@ -75,7 +75,7 @@ while :; do
|
||||
f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
|
||||
defaultitem="$mtag"
|
||||
|
||||
[ $retval -eq 0 ] || f_die
|
||||
[ $retval -eq $DIALOG_OK ] || f_die
|
||||
|
||||
[ "$mtag" = "X $msg_exit" ] && break
|
||||
|
||||
|
@ -75,7 +75,7 @@ while :; do
|
||||
f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
|
||||
defaultitem="$mtag"
|
||||
|
||||
[ $retval -eq 0 ] || f_die
|
||||
[ $retval -eq $DIALOG_OK ] || f_die
|
||||
|
||||
[ "$mtag" = "X $msg_exit" ] && break
|
||||
|
||||
|
@ -257,9 +257,9 @@ if [ "$mode" = "Add" ]; then
|
||||
f_dialog_noyes "$msg_use_default_values_for_all_account_details"
|
||||
retval=$?
|
||||
|
||||
if [ $retval -eq 255 ]; then # User pressed ESC
|
||||
if [ $retval -eq $DIALOG_ESC ]; then
|
||||
exit $SUCCESS
|
||||
elif [ $retval -ne $SUCCESS ]; then
|
||||
elif [ $retval -ne $DIALOG_OK ]; then
|
||||
#
|
||||
# Ask a series of questions to pre-fill the editor screen.
|
||||
#
|
||||
@ -431,7 +431,7 @@ while :; do
|
||||
f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
|
||||
|
||||
# Exit if user has either pressed ESC or chosen Cancel/No
|
||||
[ $retval -eq $SUCCESS ] || f_die
|
||||
[ $retval -eq $DIALOG_OK ] || f_die
|
||||
|
||||
case "$mtag" in
|
||||
X) # Exit
|
||||
@ -450,7 +450,7 @@ while :; do
|
||||
f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
|
||||
|
||||
# Loop if user has either pressed ESC or chosen Cancel/No
|
||||
[ $retval -eq $SUCCESS ] || continue
|
||||
[ $retval -eq $DIALOG_OK ] || continue
|
||||
|
||||
[ "$mtag" = "X $msg_exit" ] && continue
|
||||
|
||||
|
@ -100,7 +100,7 @@ dialog_menu_main()
|
||||
f_dialog_menutag_store "$menu_choice"
|
||||
|
||||
# Only update default-item on success
|
||||
[ $retval -eq 0 ] && f_dialog_default_store "$menu_choice"
|
||||
[ $retval -eq $DIALOG_OK ] && f_dialog_default_store "$menu_choice"
|
||||
|
||||
return $retval
|
||||
}
|
||||
@ -136,11 +136,10 @@ while :; do
|
||||
f_dialog_menutag_fetch mtag
|
||||
f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
|
||||
|
||||
if [ $retval -eq 2 ]; then
|
||||
# The Help button was pressed
|
||||
if [ $retval -eq $DIALOG_HELP ]; then
|
||||
f_show_help "$USERMGMT_HELPFILE"
|
||||
continue
|
||||
elif [ $retval -ne $SUCCESS ]; then
|
||||
elif [ $retval -ne $DIALOG_OK ]; then
|
||||
f_die
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user