Commit 23c71467 authored by Igor Pecovnik's avatar Igor Pecovnik
Browse files

Basic support for accepting parameters. Just a few are working ...

RFC is needed into the direction that each command is unique, now a few are toggling and we don't know from which state.
parent 86a778fa
......@@ -56,14 +56,28 @@ if [[ -f ${BASH_SOURCE}-functions-network ]]; then source ${BASH_SOURCE}-functi
fi
# Script parameters handling
while [[ $1 == *=* ]]; do
parameter=${1%%=*}
value=${1##*=}
shift
echo "Command line: setting $parameter to ${value:-(empty)}"
eval "$parameter=\"$value\""
scripted=true
done
# Display help
if [[ $1 == "--help" ]]; then
echo "Armbian config options:"
echo ""
echo "Example to install headers:"
echo "${BASH_SOURCE[0]} main=Software selection=Headers"
exit
fi
# collect info
main "$@"
#
# Main menu
#
......@@ -104,8 +118,9 @@ do
[[ "$TITLELENGTH" -lt 60 ]] && TITLELENGTH="60"
if [[ -z $main ]]; then
exec 3>&1
selection=$(dialog --colors --backtitle "$BACKTITLE" --title " armbian-config " --clear \
main=$(dialog --colors --backtitle "$BACKTITLE" --title " armbian-config " --clear \
--cancel-label "Exit" --menu "\n$MENUTITLE \n$FREQENCIES\nSupport: \Z1https://forum.armbian.com\Z0\n " \
$LISTLENGTH ${TITLELENGTH} $BOXLENGTH "${LIST[@]}" 2>&1 1>&3)
exit_status=$?
......@@ -114,9 +129,9 @@ do
[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && exit
dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox \
"\nLoading ${selection,,} submodule ... " 5 $((26+${#selection}))
case $selection in
"\nLoading ${main,,} submodule ... " 5 $((26+${#main}))
fi
case $main in
"System" )
submenu_settings
......@@ -135,6 +150,7 @@ do
;;
"Help" )
unset main
t="This tool provides a straightforward way of configuring."
t=$t"\n \nAlthough it can be run at any time, some of the"
t=$t" options may have difficulties if you alter system settings manually.\n"
......
......@@ -11,6 +11,7 @@
function jobs ()
{
unset selection
# Shows box with loading ...
#
dialog --backtitle "$BACKTITLE" --title " Please wait " --infobox "\nLoading ${selection,,} submodule ... " 5 $((26+${#selection}))
......@@ -1480,4 +1481,7 @@ function jobs ()
esac
[[ -n $scripted ]] && exit
}
......@@ -19,6 +19,7 @@
#
function submenu_settings ()
{
unset main
while true; do
LIST=()
......@@ -136,7 +137,7 @@ while true; do
echo > $temp_rc
fi
if [[ -z $selection ]]; then
exec 3>&1
selection=$(DIALOGRC=$temp_rc dialog --colors --backtitle "$BACKTITLE" --title " $sys_title " --clear \
--cancel-label "Back" --menu "$disclaimer" $LISTLENGTH 0 $BOXLENGTH \
......@@ -144,6 +145,7 @@ while true; do
exit_status=$?
exec 3>&-
[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break
fi
# run main function
jobs "$selection"
......@@ -161,7 +163,7 @@ function submenu_networking ()
# select default interface if there is more than one connected
#select_interface "default"
unset main
while true; do
LIST=()
......@@ -283,6 +285,7 @@ while true; do
fi
disclaimer=$disclaimer"\n\Z1Note\Zn: This tool can be successful only when drivers are configured properly. If auto-detection fails, you are on your own.\n "
if [[ -z $selection ]]; then
exec 3>&1
selection=$(dialog --backtitle "$BACKTITLE" --colors --title " Wired, Wireless, Bluetooth, Hotspot " --clear \
--cancel-label "Back" --menu "${disclaimer}" $LISTLENGTH 70 $BOXLENGTH \
......@@ -290,7 +293,7 @@ while true; do
exit_status=$?
exec 3>&-
[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break
fi
# run main function
jobs "$selection"
......@@ -305,6 +308,7 @@ done
#
function submenu_personal ()
{
unset main
while true; do
LIST=()
......@@ -343,6 +347,7 @@ done
#
function submenu_software ()
{
unset main
while true; do
# detect desktop
......@@ -406,6 +411,7 @@ while true; do
LISTLENGTH="$((6+${#LIST[@]}/2))"
BOXLENGTH=${#LIST[@]}
if [[ -z $selection ]]; then
exec 3>&1
selection=$(dialog --backtitle "$BACKTITLE" --title "System and 3rd party software" --clear \
--cancel-label "Back" --menu "$disclaimer" $LISTLENGTH 70 $BOXLENGTH \
......@@ -413,6 +419,7 @@ while true; do
exit_status=$?
exec 3>&-
[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break
fi
# run main function
jobs "$selection"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment