1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-27 11:55:06 +00:00

Perform some code consolidation and replace nested case-statements with

more logical if-else statements for each menu selection.
This commit is contained in:
Devin Teske 2013-06-18 23:18:32 +00:00
parent fcd71b75c9
commit aaeba1c1ea
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=251975

View File

@ -346,86 +346,90 @@ while :; do
case "$mtag" in
"X $msg_exit") break ;;
?" [X] "*) toggled=1 ;;
*) toggled= ;;
esac
case "$mtag" in
# Simple On/Off toggle bits
?" ["?"] $msg_apm")
case "$mtag" in
?" [X] "*) err=$( f_sysrc_set apm_enable NO 2>&1 ) ;;
?" [ ] "*) err=$( f_sysrc_set apm_enable YES 2>&1 ) ;;
esac
[ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" ;;
?" ["?"] $msg_startup_dirs")
dialog_input_value \
"$msg_startup_dirs_desc" \
"$( f_sysrc_get local_startup )"
if [ $? -eq $SUCCESS ]; then
err=$( f_sysrc_set local_startup "$value" ) ||
f_dialog_msgbox "$err\n"
if [ "$toggled" ]; then
err=$( f_sysrc_set apm_enable NO 2>&1 )
else
err=$( f_sysrc_set apm_enable YES 2>&1 )
fi
;;
?" ["?"] $msg_named")
case "$mtag" in
?" [X] "*) err=$( f_sysrc_set named_enable NO 2>&1 ) ;;
?" [ ] "*) err=$( f_sysrc_set named_enable YES 2>&1 ) ;;
esac
[ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" ;;
?" ["?"] $msg_named_flags")
dialog_input_value \
"$msg_named_flags_desc" \
"$( f_sysrc_get named_flags )"
if [ $? -eq $SUCCESS ]; then
err=$( f_sysrc_set named_flags "$value" ) ||
f_dialog_msgbox "$err\n"
if [ "$toggled" ]; then
err=$( f_sysrc_set named_enable NO 2>&1 )
else
err=$( f_sysrc_set named_enable YES 2>&1 )
fi
;;
?" ["?"] $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
;;
?" ["?"] $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
;;
?" ["?"] $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
;;
?" ["?"] $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
;;
# Multi-variable On/Off toggle bits
?" ["?"] $msg_nis_client")
case "$mtag" in
?" [X] "*) err=$( f_sysrc_set nis_client_enable NO 2>&1 ) ;;
?" [ ] "*)
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 ) ;;
esac
[ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" ;;
?" ["?"] $msg_nis_domainname")
dialog_input_value \
"$msg_nis_domainname_desc" \
"$( f_sysrc_get nisdomainname )"
if [ $? -eq $SUCCESS ]; then
err=$( f_sysrc_set nisdomainname "$value" ) ||
f_dialog_msgbox "$err\n"
&& err=$( f_sysrc_set rpcbind_enable YES 2>&1 )
fi
;;
?" ["?"] $msg_nis_server")
case "$mtag" in
?" [X] "*) err=$( f_sysrc_set nis_server_enable NO 2>&1 ) ;;
?" [ ] "*)
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 ) ;;
esac
[ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" ;;
?" ["?"] $msg_accounting")
case "$mtag" in
?" [X] "*) err=$( f_sysrc_set accounting_enable NO 2>&1 ) ;;
?" [ ] "*) err=$( f_sysrc_set accounting_enable YES 2>&1 ) ;;
esac
[ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" ;;
?" ["?"] $msg_lpd")
case "$mtag" in
?" [X] "*) err=$( f_sysrc_set lpd_enable NO 2>&1 ) ;;
?" [ ] "*) err=$( f_sysrc_set lpd_enable YES 2>&1 ) ;;
esac
[ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" ;;
?" ["?"] $msg_sco")
case "$mtag" in
?" [X] "*) err=$( f_sysrc_set ibcs2_enable NO 2>&1 ) ;;
?" [ ] "*) err=$( f_sysrc_set ibcs2_enable YES 2>&1 ) ;;
esac
[ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" ;;
?" ["?"] $msg_svr4")
case "$mtag" in
?" [X] "*) err=$( f_sysrc_set svr4_enable NO 2>&1 ) ;;
?" [ ] "*) err=$( f_sysrc_set svr4_enable YES 2>&1 ) ;;
esac
[ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" ;;
&& err=$( f_sysrc_set rpcbind_enable YES 2>&1 )
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 )
;;
?" ["?"] $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 )
;;
?" ["?"] $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 )
;;
esac
[ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n"
done
exit $SUCCESS