add while loop and general improvements

This commit is contained in:
Heavybullets8 2022-12-15 19:57:32 -07:00
parent bcadb12e11
commit 948b3fd5ad

View File

@ -31,14 +31,14 @@ export -f backup
deleteBackup(){
while true
do
clear -x && echo "pulling all restore points.."
list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl -s ") " | column -t)
if [[ -z "$list_backups" ]]; then
echo "No restore points available"
exit
fi
#Select a restore point
while true
do
clear -x
@ -63,6 +63,8 @@ do
fi
break # Break out of the loop if all of the If statement checks above are untrue
done
#Confirm deletion
while true
do
clear -x
@ -87,6 +89,8 @@ do
;;
esac
done
#Check if there are more backups to delete
while true
do
read -rt 120 -p "Delete more backups? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; }
@ -106,20 +110,19 @@ do
esac
done
done
}
export -f deleteBackup
restore(){
while true
do
clear -x && echo "pulling restore points.."
list_backups=$(cli -c 'app kubernetes list_backups' | grep -E "HeavyScript_|TrueTool_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl -s ") " | column -t)
if [[ -z "$list_backups" ]]; then
echo "No HeavyScript restore points available"
exit
fi
#Select a restore point
while true
do
clear -x
@ -157,7 +160,8 @@ do
# Compare the dates
if (("$restore_point_date" < "$when_updated" )); then
while (("$restore_point_date" < "$when_updated" ))
do
clear -x
echo "The restore point you have chosen is from an older version of Truenas Scale"
echo "This is not recommended, as it may cause issues with the system"
@ -166,6 +170,7 @@ do
[Yy] | [Yy][Ee][Ss])
echo "Proceeding.."
sleep 3
break
;;
[Nn] | [Nn][Oo])
echo "Exiting"
@ -178,9 +183,10 @@ do
;;
esac
fi
fi
done
#Confirm restore
while true
do
clear -x
@ -230,6 +236,6 @@ do
;;
esac
done
done
}
export -f restore