Moved spinners for database upgrades from install.sh to database-update.sh

This commit is contained in:
2026-02-19 18:33:19 -05:00
parent dd86d2e519
commit b138f462d9
2 changed files with 33 additions and 9 deletions

View File

@@ -6,6 +6,19 @@
# SPDX-License-Identifier: GPL-2.0
function spinner() {
local pid="$1"
local delay="0.1"
local spinstr='|/-\\'
local i=0
while ps -p "$pid" > /dev/null; do
i=$(( (i+1) % 4 ))
printf "\r[%c]" "${spinstr:$i:1}"
sleep "$delay"
done
printf "\r \r" # Clear the spinner line
}
if [[ $1 == "" ]]
then
@@ -45,7 +58,9 @@ echo "Started database updates for OpenLog version 5.3.0..."
# Import old flag data from old scheme to new flagmap table
if [[ $(mysql $margs -e "select count(*) from flagmap") == 0 ]]
then
echo "Importing flag data from old scheme to new flagmap table..."
echo "Importing flag data from old scheme to new flagmap table."
echo "This may take some time..."
(
for flagnumber in $(mysql $margs -e "select flagid from flags")
do
flag_x=$(mysql $margs -s -e "show tables like 'flag_$flagnumber'")
@@ -69,13 +84,18 @@ then
mysql $margs -e "drop table flag_$flagnumber"
fi
done
) &
task_pid=$!
spinner $task_pid
echo "...done."
fi
# Import reference chain data into new reflinks table
if [[ $(mysql $margs -e "select count(*) from reflinks") == 0 ]]
then
echo "Importing lognote reference chain data into new reflinks table..."
echo "Importing lognote reference chain data into new reflinks table."
echo "This may take some time..."
(
for note in $(mysql $margs -e "select lognoteid from lognotes where refs!=''")
do
refstring=$(mysql $margs -e "select refs from lognotes where lognoteid=$note")
@@ -88,8 +108,13 @@ then
done
IFS=$oldifs
done
) &
task_pid=$!
spinner $task_pid
echo "...done."
echo "Importing template reference chain data into new reflinks table..."
echo "Importing template reference chain data into new reflinks table."
echo "This may take some time..."
(
for template in $(mysql $margs -e "select templateid from notetemplates where refs!=''")
do
refstring=$(mysql $margs -e "select refs from notetemplates where templateid=$template")
@@ -102,6 +127,9 @@ then
done
IFS=$oldifs
done
) &
task_pid=$!
spinner $task_pid
echo "...done."
mysql $margs -e "alter table lognotes drop column refs" >/dev/null 2>&1
mysql $margs -e "alter table notetemplates drop column refs" >/dev/null 2>&1