From b138f462d94eba24e0fa3270724b06cd3f03a9e1 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Thu, 19 Feb 2026 18:33:19 -0500 Subject: [PATCH] Moved spinners for database upgrades from install.sh to database-update.sh --- database-update.sh | 34 +++++++++++++++++++++++++++++++--- install.sh | 8 ++------ 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/database-update.sh b/database-update.sh index 269a666..45e45c2 100755 --- a/database-update.sh +++ b/database-update.sh @@ -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 diff --git a/install.sh b/install.sh index afc16d3..dbd897b 100755 --- a/install.sh +++ b/install.sh @@ -231,14 +231,10 @@ then echo "Performing database updates. This may take a while..." # apply database updates from sql file - (mysql --defaults-extra-file=$mysql_opt_file --force < database-update.sql >/dev/null 2>&1) & - task_pid=$! - spinner $task_pid + mysql --defaults-extra-file=$mysql_opt_file --force < database-update.sql >/dev/null 2>&1 # apply database updates via script - (bash ./database-update.sh $mysql_opt_file) & - task_pid=$! - spinner $task_pid + bash ./database-update.sh $mysql_opt_file echo "... finished with database updates." rm -f $mysql_opt_file