Restore using radiolist

This commit is contained in:
Bob Mottram 2016-10-24 09:47:17 +01:00
parent 0b18eb1e4f
commit d527e86c84
1 changed files with 49 additions and 65 deletions

View File

@ -937,80 +937,64 @@ function restore_data_from_storage {
choices=$(dialog --stdout --backtitle $"Freedombone" \
--title $"Restore apps" \
--checklist $'Choose:' \
--radiolist $'Choose:' \
30 40 20 $applist)
if [ $? -eq 0 ]; then
sel=$?
case $sel in
1) return;;
255) return;;
esac
app_name=$(cat $data)
# exit
if [[ $app_name == "$ExitStr" ]]; then
return
fi
# Restore all
if [[ $app_name == "$AllStr" ]]; then
clear
# Test for exit
for choice in $choices
do
app_index=$[choice-1]
app_name=${app_list[app_index]}
if [[ $app_name == "$ExitStr" ]]; then
return
fi
done
# Test for restoring all apps
for choice in $choices
do
app_index=$[choice-2]
app_name=${app_list[app_index]}
if [[ $app_name == "$AllStr" ]]; then
$restore_command
retcode="$?"
if [[ "$retcode" != "0" ]]; then
if [[ "$1" == "local" ]]; then
dialog --title $"Restore all apps from USB" \
--msgbox $"Restore failed with code $retcode" 6 60
else
dialog --title $"Restore all apps from $1" \
--msgbox $"Restore failed with code $retcode" 6 60
fi
return
fi
if [[ "$1" == "local" ]]; then
dialog --title $"Restore all apps from USB" \
--msgbox $"Restore complete" 6 40
else
dialog --title $"Restore all apps from $1" \
--msgbox $"Restore complete" 6 40
fi
return
fi
done
ctr=0
for choice in $choices
do
app_index=$[choice-2]
app_name=${app_list[app_index]}
if [ ${#app_name} -gt 0 ]; then
$restore_command "${app_name}"
retcode="$?"
if [[ "$retcode" != "0" ]]; then
dialog --title $"Restore apps from USB" \
--msgbox $"Restore of ${app_name} failed with code $retcode" 6 60
return
fi
fi
ctr=$((ctr + 1))
done
if [ $ctr -gt 0 ]; then
$restore_command
retcode="$?"
if [[ "$retcode" != "0" ]]; then
if [[ "$1" == "local" ]]; then
dialog --title $"Restore apps from USB" \
--msgbox $"Restore complete" 6 40
dialog --title $"Restore all apps from USB" \
--msgbox $"Restore failed with code $retcode" 6 60
else
dialog --title $"Restore apps from $1" \
--msgbox $"Restore complete" 6 40
dialog --title $"Restore all apps from $1" \
--msgbox $"Restore failed with code $retcode" 6 60
fi
return
fi
if [[ "$1" == "local" ]]; then
dialog --title $"Restore all apps from USB" \
--msgbox $"Restore complete" 6 40
else
dialog --title $"Restore all apps from $1" \
--msgbox $"Restore complete" 6 40
fi
return
fi
# Restore an app
$restore_command "${app_name}"
retcode="$?"
if [[ "$retcode" != "0" ]]; then
dialog --title $"Restore apps from USB" \
--msgbox $"Restore of ${app_name} failed with code $retcode" 6 60
return
fi
# finished
if [[ "$1" == "local" ]]; then
dialog --title $"Restore apps from USB" \
--msgbox $"Restore complete" 6 40
else
dialog --title $"Restore apps from $1" \
--msgbox $"Restore complete" 6 40
fi
any_key
}
function restore_data {