Better implementation of selecting all apps
This commit is contained in:
parent
ad39b2c78d
commit
5edcf011f4
|
@ -56,12 +56,13 @@ do
|
|||
done
|
||||
|
||||
function show_apps {
|
||||
select_all_apps=$1
|
||||
applist=""
|
||||
n=1
|
||||
app_index=0
|
||||
for a in "${APPS_AVAILABLE[@]}"
|
||||
do
|
||||
if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then
|
||||
if [[ ${APPS_INSTALLED[$app_index]} == "0" && "$select_all_apps" != "add-all" ]]; then
|
||||
applist="$applist $n $a off"
|
||||
else
|
||||
applist="$applist $n $a on"
|
||||
|
@ -130,33 +131,14 @@ function remove_apps_selected {
|
|||
}
|
||||
|
||||
function install_apps_selected {
|
||||
select_all_apps=$1
|
||||
# which apps need to be installed?
|
||||
installs=""
|
||||
app_index=0
|
||||
n=0
|
||||
|
||||
if [ ! $select_all_apps ]; then
|
||||
for a in "${APPS_INSTALLED[@]}"
|
||||
do
|
||||
if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then
|
||||
if [[ ${APPS_CHOSEN[$app_index]} == "1" ]]; then
|
||||
if [ ${n} -gt 0 ]; then
|
||||
installs="$installs ${APPS_AVAILABLE[$app_index]}"
|
||||
else
|
||||
installs="${APPS_AVAILABLE[$app_index]}"
|
||||
fi
|
||||
n=$[n+1]
|
||||
fi
|
||||
fi
|
||||
app_index=$[app_index+1]
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ $select_all_apps == "add-all" ]]; then
|
||||
for a in "${APPS_INSTALLED[@]}"
|
||||
do
|
||||
if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then
|
||||
for a in "${APPS_INSTALLED[@]}"
|
||||
do
|
||||
if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then
|
||||
if [[ ${APPS_CHOSEN[$app_index]} == "1" ]]; then
|
||||
if [ ${n} -gt 0 ]; then
|
||||
installs="$installs ${APPS_AVAILABLE[$app_index]}"
|
||||
else
|
||||
|
@ -164,10 +146,9 @@ function install_apps_selected {
|
|||
fi
|
||||
n=$[n+1]
|
||||
fi
|
||||
APPS_CHOSEN[$app_index]="1"
|
||||
app_index=$[app_index+1]
|
||||
done
|
||||
fi
|
||||
fi
|
||||
app_index=$[app_index+1]
|
||||
done
|
||||
|
||||
# if no apps to be installed then don't do anything
|
||||
if [ ${n} -eq 0 ]; then
|
||||
|
@ -206,11 +187,12 @@ if [[ ${#APPS_AVAILABLE[@]} == 0 ]]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
show_apps
|
||||
show_apps $1
|
||||
|
||||
clear
|
||||
|
||||
remove_apps_selected
|
||||
|
||||
if [[ $1 == "add-all" ]]; then
|
||||
install_apps_selected add-all
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue