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 ...@@ -56,14 +56,28 @@ if [[ -f ${BASH_SOURCE}-functions-network ]]; then source ${BASH_SOURCE}-functi
fi 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 # collect info
main "$@" main "$@"
# #
# Main menu # Main menu
# #
...@@ -104,8 +118,9 @@ do ...@@ -104,8 +118,9 @@ do
[[ "$TITLELENGTH" -lt 60 ]] && TITLELENGTH="60" [[ "$TITLELENGTH" -lt 60 ]] && TITLELENGTH="60"
if [[ -z $main ]]; then
exec 3>&1 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 " \ --cancel-label "Exit" --menu "\n$MENUTITLE \n$FREQENCIES\nSupport: \Z1https://forum.armbian.com\Z0\n " \
$LISTLENGTH ${TITLELENGTH} $BOXLENGTH "${LIST[@]}" 2>&1 1>&3) $LISTLENGTH ${TITLELENGTH} $BOXLENGTH "${LIST[@]}" 2>&1 1>&3)
exit_status=$? exit_status=$?
...@@ -114,9 +129,9 @@ do ...@@ -114,9 +129,9 @@ do
[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && exit [[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && exit
dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox \ dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox \
"\nLoading ${selection,,} submodule ... " 5 $((26+${#selection})) "\nLoading ${main,,} submodule ... " 5 $((26+${#main}))
fi
case $selection in case $main in
"System" ) "System" )
submenu_settings submenu_settings
...@@ -135,6 +150,7 @@ do ...@@ -135,6 +150,7 @@ do
;; ;;
"Help" ) "Help" )
unset main
t="This tool provides a straightforward way of configuring." 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"\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" t=$t" options may have difficulties if you alter system settings manually.\n"
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
function jobs () function jobs ()
{ {
unset selection
# Shows box with loading ... # Shows box with loading ...
# #
dialog --backtitle "$BACKTITLE" --title " Please wait " --infobox "\nLoading ${selection,,} submodule ... " 5 $((26+${#selection})) dialog --backtitle "$BACKTITLE" --title " Please wait " --infobox "\nLoading ${selection,,} submodule ... " 5 $((26+${#selection}))
...@@ -1480,4 +1481,7 @@ function jobs () ...@@ -1480,4 +1481,7 @@ function jobs ()
esac esac
[[ -n $scripted ]] && exit
} }
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
# #
function submenu_settings () function submenu_settings ()
{ {
unset main
while true; do while true; do
LIST=() LIST=()
...@@ -136,7 +137,7 @@ while true; do ...@@ -136,7 +137,7 @@ while true; do
echo > $temp_rc echo > $temp_rc
fi fi
if [[ -z $selection ]]; then
exec 3>&1 exec 3>&1
selection=$(DIALOGRC=$temp_rc dialog --colors --backtitle "$BACKTITLE" --title " $sys_title " --clear \ selection=$(DIALOGRC=$temp_rc dialog --colors --backtitle "$BACKTITLE" --title " $sys_title " --clear \
--cancel-label "Back" --menu "$disclaimer" $LISTLENGTH 0 $BOXLENGTH \ --cancel-label "Back" --menu "$disclaimer" $LISTLENGTH 0 $BOXLENGTH \
...@@ -144,6 +145,7 @@ while true; do ...@@ -144,6 +145,7 @@ while true; do
exit_status=$? exit_status=$?
exec 3>&- exec 3>&-
[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break [[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break
fi
# run main function # run main function
jobs "$selection" jobs "$selection"
...@@ -161,7 +163,7 @@ function submenu_networking () ...@@ -161,7 +163,7 @@ function submenu_networking ()
# select default interface if there is more than one connected # select default interface if there is more than one connected
#select_interface "default" #select_interface "default"
unset main
while true; do while true; do
LIST=() LIST=()
...@@ -283,6 +285,7 @@ while true; do ...@@ -283,6 +285,7 @@ while true; do
fi 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 " 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 exec 3>&1
selection=$(dialog --backtitle "$BACKTITLE" --colors --title " Wired, Wireless, Bluetooth, Hotspot " --clear \ selection=$(dialog --backtitle "$BACKTITLE" --colors --title " Wired, Wireless, Bluetooth, Hotspot " --clear \
--cancel-label "Back" --menu "${disclaimer}" $LISTLENGTH 70 $BOXLENGTH \ --cancel-label "Back" --menu "${disclaimer}" $LISTLENGTH 70 $BOXLENGTH \
...@@ -290,7 +293,7 @@ while true; do ...@@ -290,7 +293,7 @@ while true; do
exit_status=$? exit_status=$?
exec 3>&- exec 3>&-
[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break [[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break
fi
# run main function # run main function
jobs "$selection" jobs "$selection"
...@@ -305,6 +308,7 @@ done ...@@ -305,6 +308,7 @@ done
# #
function submenu_personal () function submenu_personal ()
{ {
unset main
while true; do while true; do
LIST=() LIST=()
...@@ -343,6 +347,7 @@ done ...@@ -343,6 +347,7 @@ done
# #
function submenu_software () function submenu_software ()
{ {
unset main
while true; do while true; do
# detect desktop # detect desktop
...@@ -406,6 +411,7 @@ while true; do ...@@ -406,6 +411,7 @@ while true; do
LISTLENGTH="$((6+${#LIST[@]}/2))" LISTLENGTH="$((6+${#LIST[@]}/2))"
BOXLENGTH=${#LIST[@]} BOXLENGTH=${#LIST[@]}
if [[ -z $selection ]]; then
exec 3>&1 exec 3>&1
selection=$(dialog --backtitle "$BACKTITLE" --title "System and 3rd party software" --clear \ selection=$(dialog --backtitle "$BACKTITLE" --title "System and 3rd party software" --clear \
--cancel-label "Back" --menu "$disclaimer" $LISTLENGTH 70 $BOXLENGTH \ --cancel-label "Back" --menu "$disclaimer" $LISTLENGTH 70 $BOXLENGTH \
...@@ -413,6 +419,7 @@ while true; do ...@@ -413,6 +419,7 @@ while true; do
exit_status=$? exit_status=$?
exec 3>&- exec 3>&-
[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break [[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break
fi
# run main function # run main function
jobs "$selection" 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