Skip to content

Commit e94672b

Browse files
committed
Replace . "progress bar" with a spinner.
1 parent a7c94b5 commit e94672b

File tree

2 files changed

+58
-14
lines changed

2 files changed

+58
-14
lines changed

install/hst-install-debian.sh

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ LOG="/root/hst_install_backups/hst_install-$(date +%d%m%Y%H%M).log"
1515
memory=$(grep 'MemTotal' /proc/meminfo |tr ' ' '\n' |grep [0-9])
1616
hst_backups="/root/hst_install_backups/$(date +%d%m%Y%H%M)"
1717
arch=$(uname -i)
18+
spinner="/-\|"
1819
os='debian'
1920
release=$(cat /etc/debian_version|grep -o [0-9]|head -n1)
2021
codename="$(cat /etc/os-release |grep VERSION= |cut -f 2 -d \(|cut -f 1 -d \))"
@@ -496,7 +497,20 @@ fi
496497

497498
# Updating system
498499
echo "Upgrade System using apt-get..."
499-
apt-get -y upgrade >> $LOG
500+
apt-get -y upgrade >> $LOG &
501+
BACK_PID=$!
502+
503+
# Check if package installation is done, print a spinner
504+
spin_i=1
505+
while kill -0 $BACK_PID 2> /dev/null ; do
506+
printf "\b${spinner:spin_i++%${#spinner}:1}"
507+
sleep 0.5
508+
done
509+
510+
# Do a blank echo to get the \n back
511+
echo
512+
513+
# Check Installation result
500514
check_result $? 'apt-get upgrade failed'
501515

502516
# Define apt conf location
@@ -700,14 +714,15 @@ echo -e '#!/bin/sh\nexit 101' > /usr/sbin/policy-rc.d
700714
chmod a+x /usr/sbin/policy-rc.d
701715

702716
# Installing apt packages
703-
echo -ne "\n\nWe will now install HestiaCP and all required packages. The process will take around 10-15 minutes."
717+
echo -ne "\n\nWe will now install HestiaCP and all required packages. The process will take around 10-15 minutes. "
704718
apt-get -y install $software >> $LOG &
705719
BACK_PID=$!
706720

707-
# Check if package installation is done
721+
# Check if package installation is done, print a spinner
722+
spin_i=1
708723
while kill -0 $BACK_PID 2> /dev/null ; do
709-
echo -n "."
710-
sleep 2
724+
printf "\b${spinner:spin_i++%${#spinner}:1}"
725+
sleep 0.5
711726
done
712727

713728
# Do a blank echo to get the \n back
@@ -1289,7 +1304,14 @@ if [ "$clamd" = 'yes' ]; then
12891304
systemctl daemon-reload
12901305
fi
12911306
echo "Updating ClamAV..."
1292-
/usr/bin/freshclam >> $LOG
1307+
/usr/bin/freshclam >> $LOG &
1308+
BACK_PID=$!
1309+
spin_i=1
1310+
while kill -0 $BACK_PID 2> /dev/null ; do
1311+
printf "\b${spinner:spin_i++%${#spinner}:1}"
1312+
sleep 0.5
1313+
done
1314+
echo
12931315
service clamav-daemon start
12941316
check_result $? "clamav-daemon start failed"
12951317
fi

install/hst-install-ubuntu.sh

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ LOG="/root/hst_install_backups/hst_install-$(date +%d%m%Y%H%M).log"
1515
memory=$(grep 'MemTotal' /proc/meminfo |tr ' ' '\n' |grep [0-9])
1616
hst_backups="/root/hst_install_backups/$(date +%d%m%Y%H%M)"
1717
arch=$(uname -i)
18+
spinner="/-\|"
1819
os='ubuntu'
1920
release="$(lsb_release -s -r)"
2021
codename="$(lsb_release -s -c)"
@@ -466,8 +467,21 @@ fi
466467
#----------------------------------------------------------#
467468

468469
# Updating system
469-
echo "Upgrade System using apt-get..."
470-
apt-get -y upgrade >> $LOG
470+
echo -e "Upgrade System using apt-get... "
471+
apt-get -y upgrade >> $LOG &
472+
BACK_PID=$!
473+
474+
# Check if package installation is done, print a spinner
475+
spin_i=1
476+
while kill -0 $BACK_PID 2> /dev/null ; do
477+
printf "\b${spinner:spin_i++%${#spinner}:1}"
478+
sleep 0.5
479+
done
480+
481+
# Do a blank echo to get the \n back
482+
echo
483+
484+
# Check Installation result
471485
check_result $? 'apt-get upgrade failed'
472486

473487
# Define apt conf location
@@ -666,14 +680,15 @@ echo -e '#!/bin/sh\nexit 101' > /usr/sbin/policy-rc.d
666680
chmod a+x /usr/sbin/policy-rc.d
667681

668682
# Installing apt packages
669-
echo -ne "\n\nWe will now install HestiaCP and all required packages. The process will take around 10-15 minutes."
683+
echo -ne "\n\nWe will now install HestiaCP and all required packages. The process will take around 10-15 minutes. "
670684
apt-get -y install $software >> $LOG &
671685
BACK_PID=$!
672686

673-
# Check if package installation is done
687+
# Check if package installation is done, print a spinner
688+
spin_i=1
674689
while kill -0 $BACK_PID 2> /dev/null ; do
675-
echo -n "."
676-
sleep 2
690+
printf "\b${spinner:spin_i++%${#spinner}:1}"
691+
sleep 0.5
677692
done
678693

679694
# Do a blank echo to get the \n back
@@ -1241,8 +1256,15 @@ if [ "$clamd" = 'yes' ]; then
12411256
gpasswd -a clamav Debian-exim > /dev/null 2>&1
12421257
cp -f $hestiacp/clamav/clamd.conf /etc/clamav/
12431258
update-rc.d clamav-daemon defaults
1244-
echo "Updating ClamAV..."
1245-
/usr/bin/freshclam >> $LOG
1259+
echo -ne "Updating ClamAV... "
1260+
/usr/bin/freshclam >> $LOG &
1261+
BACK_PID=$!
1262+
spin_i=1
1263+
while kill -0 $BACK_PID 2> /dev/null ; do
1264+
printf "\b${spinner:spin_i++%${#spinner}:1}"
1265+
sleep 0.5
1266+
done
1267+
echo
12461268
service clamav-daemon start
12471269
check_result $? "clamav-daemon start failed"
12481270
fi

0 commit comments

Comments
 (0)