Browse Source

Replace . "progress bar" with a spinner.

Raphael Schneeberger 7 years ago
parent
commit
e94672b50f
2 changed files with 58 additions and 14 deletions
  1. 28 6
      install/hst-install-debian.sh
  2. 30 8
      install/hst-install-ubuntu.sh

+ 28 - 6
install/hst-install-debian.sh

@@ -15,6 +15,7 @@ LOG="/root/hst_install_backups/hst_install-$(date +%d%m%Y%H%M).log"
 memory=$(grep 'MemTotal' /proc/meminfo |tr ' ' '\n' |grep [0-9])
 hst_backups="/root/hst_install_backups/$(date +%d%m%Y%H%M)"
 arch=$(uname -i)
+spinner="/-\|"
 os='debian'
 release=$(cat /etc/debian_version|grep -o [0-9]|head -n1)
 codename="$(cat /etc/os-release |grep VERSION= |cut -f 2 -d \(|cut -f 1 -d \))"
@@ -496,7 +497,20 @@ fi
 
 # Updating system
 echo "Upgrade System using apt-get..."
-apt-get -y upgrade >> $LOG
+apt-get -y upgrade >> $LOG &
+BACK_PID=$!
+
+# Check if package installation is done, print a spinner
+spin_i=1
+while kill -0 $BACK_PID 2> /dev/null ; do
+    printf "\b${spinner:spin_i++%${#spinner}:1}"
+    sleep 0.5
+done
+
+# Do a blank echo to get the \n back
+echo
+
+# Check Installation result
 check_result $? 'apt-get upgrade failed'
 
 # Define apt conf location
@@ -700,14 +714,15 @@ echo -e '#!/bin/sh\nexit 101' > /usr/sbin/policy-rc.d
 chmod a+x /usr/sbin/policy-rc.d
 
 # Installing apt packages
-echo -ne "\n\nWe will now install HestiaCP and all required packages. The process will take around 10-15 minutes."
+echo -ne "\n\nWe will now install HestiaCP and all required packages. The process will take around 10-15 minutes. "
 apt-get -y install $software >> $LOG &
 BACK_PID=$!
 
-# Check if package installation is done
+# Check if package installation is done, print a spinner
+spin_i=1
 while kill -0 $BACK_PID 2> /dev/null ; do
-    echo -n "."
-    sleep 2
+    printf "\b${spinner:spin_i++%${#spinner}:1}"
+    sleep 0.5
 done
 
 # Do a blank echo to get the \n back
@@ -1289,7 +1304,14 @@ if [ "$clamd" = 'yes' ]; then
         systemctl daemon-reload
     fi
     echo "Updating ClamAV..."
-    /usr/bin/freshclam >> $LOG
+    /usr/bin/freshclam >> $LOG &
+    BACK_PID=$!
+    spin_i=1
+    while kill -0 $BACK_PID 2> /dev/null ; do
+        printf "\b${spinner:spin_i++%${#spinner}:1}"
+        sleep 0.5
+    done
+    echo
     service clamav-daemon start
     check_result $? "clamav-daemon start failed"
 fi

+ 30 - 8
install/hst-install-ubuntu.sh

@@ -15,6 +15,7 @@ LOG="/root/hst_install_backups/hst_install-$(date +%d%m%Y%H%M).log"
 memory=$(grep 'MemTotal' /proc/meminfo |tr ' ' '\n' |grep [0-9])
 hst_backups="/root/hst_install_backups/$(date +%d%m%Y%H%M)"
 arch=$(uname -i)
+spinner="/-\|"
 os='ubuntu'
 release="$(lsb_release -s -r)"
 codename="$(lsb_release -s -c)"
@@ -466,8 +467,21 @@ fi
 #----------------------------------------------------------#
 
 # Updating system
-echo "Upgrade System using apt-get..."
-apt-get -y upgrade >> $LOG
+echo -e "Upgrade System using apt-get... "
+apt-get -y upgrade >> $LOG &
+BACK_PID=$!
+
+# Check if package installation is done, print a spinner
+spin_i=1
+while kill -0 $BACK_PID 2> /dev/null ; do
+    printf "\b${spinner:spin_i++%${#spinner}:1}"
+    sleep 0.5
+done
+
+# Do a blank echo to get the \n back
+echo
+
+# Check Installation result
 check_result $? 'apt-get upgrade failed'
 
 # Define apt conf location
@@ -666,14 +680,15 @@ echo -e '#!/bin/sh\nexit 101' > /usr/sbin/policy-rc.d
 chmod a+x /usr/sbin/policy-rc.d
 
 # Installing apt packages
-echo -ne "\n\nWe will now install HestiaCP and all required packages. The process will take around 10-15 minutes."
+echo -ne "\n\nWe will now install HestiaCP and all required packages. The process will take around 10-15 minutes. "
 apt-get -y install $software >> $LOG &
 BACK_PID=$!
 
-# Check if package installation is done
+# Check if package installation is done, print a spinner
+spin_i=1
 while kill -0 $BACK_PID 2> /dev/null ; do
-    echo -n "."
-    sleep 2
+    printf "\b${spinner:spin_i++%${#spinner}:1}"
+    sleep 0.5
 done
 
 # Do a blank echo to get the \n back
@@ -1241,8 +1256,15 @@ if [ "$clamd" = 'yes' ]; then
     gpasswd -a clamav Debian-exim > /dev/null 2>&1
     cp -f $hestiacp/clamav/clamd.conf /etc/clamav/
     update-rc.d clamav-daemon defaults
-    echo "Updating ClamAV..."
-    /usr/bin/freshclam >> $LOG
+    echo -ne "Updating ClamAV... "
+    /usr/bin/freshclam >> $LOG &
+    BACK_PID=$!
+    spin_i=1
+    while kill -0 $BACK_PID 2> /dev/null ; do
+        printf "\b${spinner:spin_i++%${#spinner}:1}"
+        sleep 0.5
+    done
+    echo
     service clamav-daemon start
     check_result $? "clamav-daemon start failed"
 fi