Skip to content

Commit

Permalink
Basic support for accepting parameters. Just a few are working ...
Browse files Browse the repository at this point in the history
RFC is needed into the direction that each command is unique, now a few are toggling and we don't know from which state.
  • Loading branch information
igorpecovnik committed Mar 6, 2020
1 parent 86a778f commit 23c7146
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
30 changes: 23 additions & 7 deletions debian-config
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down Expand Up @@ -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=$?
Expand All @@ -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
Expand All @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions debian-config-jobs
Original file line number Diff line number Diff line change
Expand Up @@ -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}))
Expand Down Expand Up @@ -1480,4 +1481,7 @@ function jobs ()


esac


[[ -n $scripted ]] && exit
}
13 changes: 10 additions & 3 deletions debian-config-submenu
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#
function submenu_settings ()
{
unset main
while true; do

LIST=()
Expand Down Expand Up @@ -136,14 +137,15 @@ 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 \
"${LIST[@]}" 2>&1 1>&3)
exit_status=$?
exec 3>&-
[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break
fi

# run main function
jobs "$selection"
Expand All @@ -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=()
Expand Down Expand Up @@ -283,14 +285,15 @@ 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 \
"${LIST[@]}" 2>&1 1>&3)
exit_status=$?
exec 3>&-
[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break

fi
# run main function
jobs "$selection"

Expand All @@ -305,6 +308,7 @@ done
#
function submenu_personal ()
{
unset main
while true; do

LIST=()
Expand Down Expand Up @@ -343,6 +347,7 @@ done
#
function submenu_software ()
{
unset main
while true; do

# detect desktop
Expand Down Expand Up @@ -406,13 +411,15 @@ 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 \
"${LIST[@]}" 2>&1 1>&3)
exit_status=$?
exec 3>&-
[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break
fi

# run main function
jobs "$selection"
Expand Down

0 comments on commit 23c7146

Please sign in to comment.