Browse Source

Add quiet switch and refactor code

Kristan Kenney 6 years ago
parent
commit
a7e8a3d7d7
1 changed files with 43 additions and 15 deletions
  1. 43 15
      bin/v-update-sys-theme

+ 43 - 15
bin/v-update-sys-theme

@@ -1,25 +1,53 @@
 #!/bin/bash
 
+quiet=$1
+
 source $HESTIA/func/main.sh
 source $HESTIA/conf/hestia.conf
 
-echo "Updating system base theme..."
-if [ -e "$HESTIA/web/css/styles.min.css" ]; then
-    rm -f "$HESTIA/web/css/styles.min.css"
+welcome_message() {
+    echo "********************************************************"
+    echo "*  Hestia Control Panel - User Interface Theme Updater *"
+    echo "********************************************************"
+    echo "     This script will update the themes currently       "
+    echo " available on your system, which may include bug fixes  "
+    echo " and improvements from our development team which are   "
+    echo "    intended to provide a user better experience        "
+    echo "********************************************************"
+    echo "       Proceed with theme update installation?          "
+    echo "                       [Y/n]                            "
+    echo ""
+}
+
+if [ "$quiet" ]; then 
+    answer="y"
+else
+    welcome_message
+    read -p "" answer
 fi
-wget -qO $HESTIA/web/css/styles.min.css $HESTIA_GIT_REPO/$RELEASE_BRANCH/web/css/styles.min.css
 
-echo "Updating included themes..."
-for themefile in `ls $HESTIA/install/deb/themes`; do
+if [ "$answer" = "y" ] || [ "$answer" = "Y" ] || [ "$answer" = "yes" ]; then
+    echo ""
+    echo "Updating system base theme..."
+    if [ -e "$HESTIA/web/css/styles.min.css" ]; then
+        rm -f "$HESTIA/web/css/styles.min.css"
+    fi
+    wget -O $HESTIA/web/css/styles.min.css $HESTIA_GIT_REPO/$RELEASE_BRANCH/web/css/styles.min.css --show-progress --progress=bar:force --limit-rate=3m 
 
-if [ -e $themefile ]; then
-    rm -f $themefile
-fi
+    echo "Updating included themes..."
+    for themefile in `ls $HESTIA/install/deb/themes`; do
 
-wget -qO $HESTIA_INSTALL_DIR/themes/$themefile $HESTIA_GIT_REPO/$RELEASE_BRANCH/install/deb/themes/$themefile
-done
+    if [ -e $themefile ]; then
+        rm -f $themefile
+    fi
+    echo "Downloading $themefile..."
+    wget -O $HESTIA_INSTALL_DIR/themes/$themefile $HESTIA_GIT_REPO/$RELEASE_BRANCH/install/deb/themes/$themefile --show-progress --progress=bar:force --limit-rate=3m
+    done
 
-if [ "$THEME" != "default" ]; then
-    echo "Applying updated system interface theme..."
-    $BIN/v-change-sys-theme $THEME
-fi
+    if [ "$THEME" != "default" ]; then
+        echo "Applying updated system interface theme..."
+        $BIN/v-change-sys-theme $THEME
+    fi
+else
+    echo "Update process aborted."
+fi