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 # 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 == "" ]] if [[ $1 == "" ]]
then 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 # Import old flag data from old scheme to new flagmap table
if [[ $(mysql $margs -e "select count(*) from flagmap") == 0 ]] if [[ $(mysql $margs -e "select count(*) from flagmap") == 0 ]]
then 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") for flagnumber in $(mysql $margs -e "select flagid from flags")
do do
flag_x=$(mysql $margs -s -e "show tables like 'flag_$flagnumber'") flag_x=$(mysql $margs -s -e "show tables like 'flag_$flagnumber'")
@@ -69,13 +84,18 @@ then
mysql $margs -e "drop table flag_$flagnumber" mysql $margs -e "drop table flag_$flagnumber"
fi fi
done done
) &
task_pid=$!
spinner $task_pid
echo "...done." echo "...done."
fi fi
# Import reference chain data into new reflinks table # Import reference chain data into new reflinks table
if [[ $(mysql $margs -e "select count(*) from reflinks") == 0 ]] if [[ $(mysql $margs -e "select count(*) from reflinks") == 0 ]]
then 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!=''") for note in $(mysql $margs -e "select lognoteid from lognotes where refs!=''")
do do
refstring=$(mysql $margs -e "select refs from lognotes where lognoteid=$note") refstring=$(mysql $margs -e "select refs from lognotes where lognoteid=$note")
@@ -88,8 +108,13 @@ then
done done
IFS=$oldifs IFS=$oldifs
done done
) &
task_pid=$!
spinner $task_pid
echo "...done." 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!=''") for template in $(mysql $margs -e "select templateid from notetemplates where refs!=''")
do do
refstring=$(mysql $margs -e "select refs from notetemplates where templateid=$template") refstring=$(mysql $margs -e "select refs from notetemplates where templateid=$template")
@@ -102,6 +127,9 @@ then
done done
IFS=$oldifs IFS=$oldifs
done done
) &
task_pid=$!
spinner $task_pid
echo "...done." echo "...done."
mysql $margs -e "alter table lognotes drop column refs" >/dev/null 2>&1 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 mysql $margs -e "alter table notetemplates drop column refs" >/dev/null 2>&1

View File

@@ -231,14 +231,10 @@ then
echo "Performing database updates. This may take a while..." echo "Performing database updates. This may take a while..."
# apply database updates from sql file # apply database updates from sql file
(mysql --defaults-extra-file=$mysql_opt_file --force < database-update.sql >/dev/null 2>&1) & mysql --defaults-extra-file=$mysql_opt_file --force < database-update.sql >/dev/null 2>&1
task_pid=$!
spinner $task_pid
# apply database updates via script # apply database updates via script
(bash ./database-update.sh $mysql_opt_file) & bash ./database-update.sh $mysql_opt_file
task_pid=$!
spinner $task_pid
echo "... finished with database updates." echo "... finished with database updates."
rm -f $mysql_opt_file rm -f $mysql_opt_file