Browse Source

Minor fixes to v-update-sys-hestia-git

Reworked install confirmation switch and clarified warning message.
Ensure temporary build files are removed if installation is aborted.
Kristan Kenney 6 years ago
parent
commit
57cbe55bd3
1 changed files with 35 additions and 18 deletions
  1. 35 18
      bin/v-update-sys-hestia-git

+ 35 - 18
bin/v-update-sys-hestia-git

@@ -90,19 +90,13 @@ if [ ! -z "$1" ]; then
         exit 1
         exit 1
     else
     else
         /usr/local/hestia/bin/v-change-sys-config-value 'RELEASE_BRANCH' "$branch"
         /usr/local/hestia/bin/v-change-sys-config-value 'RELEASE_BRANCH' "$branch"
-        echo "Changed update release branch to $branch from GitHub repository."
+        echo "Changed release branch to $branch."
     fi
     fi
 else
 else
     source /usr/local/hestia/conf/hestia.conf
     source /usr/local/hestia/conf/hestia.conf
     branch=$RELEASE_BRANCH
     branch=$RELEASE_BRANCH
 fi
 fi
 
 
-if [ ! -z "$2" ]; then
-    install=$2
-else
-    install="y"
-fi
-
 if [ -z "$branch" ]; then
 if [ -z "$branch" ]; then
     echo "No branch detected, please provide one using: v-update-sys-hestia-git branch"
     echo "No branch detected, please provide one using: v-update-sys-hestia-git branch"
     exit
     exit
@@ -373,19 +367,42 @@ fi
 #
 #
 #################################################################################
 #################################################################################
 
 
-if [ "$install" = 'yes' ] || [ "$install" = 'y' ]; then
-    echo "!!! Development builds should not be installed on systems with live production data without understanding the potential risks involved. !!!"
-    read -p 'Do you want to proceed the package installation? [y/n] ' answer
+# Define package installation functions
+warning_message() {
+    echo ""
+    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+    echo "WARNING - Development builds should not be installed on"
+    echo "systems with live production data without understanding"
+    echo "the potential risks that are involved!"
+    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+    echo ""
+}
+
+install_build() {
+    echo "Installing packages..."
+    for i in $DEB_DIR/*.deb; do
+        # Install all available packages
+        dpkg -i $i
+    done
+    # Remove temporary files
+    rm -rf $BUILD_DIR
+}
+
+# Define installation routine
+
+if [ "$install" = "yes" ]; then 
+    install_build
+else
+    warning_message
+    read -p "Do you wish to proceed with the installation? [y/n] " answer
     if [ "$answer" = 'y' ] || [ "$answer" = 'Y'  ]; then
     if [ "$answer" = 'y' ] || [ "$answer" = 'Y'  ]; then
-        echo "Installing packages..."
-        for i in $DEB_DIR/*.deb; do
-            # Install all available packages
-            dpkg -i $i
-        done
+        install_build
         unset $answer
         unset $answer
-        # Remove temporary files
-        rm -rf $BUILD_DIR
     else
     else
-        check_result 1 "Package installation cancelled..."
+        echo "Installation of development build aborted."
+        echo "Removing temporary files..."
+        rm -rf $BUILD_DIR
+        unset $answer
+        echo ""
     fi
     fi
 fi
 fi