Skip to content
Snippets Groups Projects
Commit d527e86c authored by Bob Mottram's avatar Bob Mottram
Browse files

Restore using radiolist

parent 0b18eb1e
No related branches found
No related tags found
No related merge requests found
......@@ -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
clear
sel=$?
case $sel in
1) return;;
255) return;;
esac
app_name=$(cat $data)
# 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
# exit
if [[ $app_name == "$ExitStr" ]]; then
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 all
if [[ $app_name == "$AllStr" ]]; then
clear
$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 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment