#74 add color in install.sh and update README.md

Нэгтгэсэн
Alexandra 1-ийг blezz-tech/unstable-оос ShariX_Open/unstable 1 өдөр өмнө болгон нэгтгэв
3 өөрчлөгдсөн 40 нэмэгдсэн , 14 устгасан
  1. 3 3
      README.md
  2. 22 0
      bin/functions.sh
  3. 15 11
      bin/install.sh

+ 3 - 3
README.md

@@ -5,9 +5,9 @@ The base Django project of a service web application to which other modules are
 ## Installation / Upgrade
 
 1. Download or clone repository.
-2. Make a copy of configuration file (cp bin/install.cfg.example bin/install.cfg) and modify it for your service (check
-   paths).
-3. For the initial/update project configuration, run *bin/install.sh*.
+2. Go to the root of the repository.
+3. run `./bin/install.sh`
+4. Follow the instructions in console.
 
 ### Test Users
 

+ 22 - 0
bin/functions.sh

@@ -0,0 +1,22 @@
+
+# Colors
+
+RED="\e[31m"
+GREEN="\e[32m"
+YELLOW="\e[33m"
+RESET="\e[0m"
+
+
+# Functions
+
+echo_error() {
+    echo -e "${RED}$1${RESET}"
+}
+
+echo_warning() {
+    echo -e "${YELLOW}$1${RESET}"
+}
+
+echo_success() {
+    echo -e "${GREEN}$1${RESET}"
+}

+ 15 - 11
bin/install.sh

@@ -1,5 +1,7 @@
 #!/bin/bash
 
+source bin/functions.sh
+
 if [ -f bin/install.cfg ]; then
     echo "File install.cfg already exists"
 else
@@ -7,24 +9,26 @@ else
     max_attempts=3
 
     while [ $attempts -lt $max_attempts ]; do
-        read -p "File install.cfg does not exist. Do you want to create it? (y/n) [default: y]: " answer
+        echo_error "File install.cfg does not exist."
+
+        read -p "Do you want to create it? (y/n) [default: y]: " answer
 
         if [[ "$answer" == "y" || "$answer" == "Y" ]]; then
             cp bin/install.cfg.example bin/install.cfg
-            echo "File install.cfg was successfully created"
-            echo "Restart install.sh script after editing install.cfg"
+            echo_success "File install.cfg was successfully created"
+            echo_warning "Restart install.sh script after editing install.cfg"
             exit 0
         elif [[ "$answer" == "n" || "$answer" == "N" ]]; then
-            echo "Error: You need to create the file manually and then continue."
+            echo_error "Error: You need to create the file manually and then continue."
             echo "cp /bin/install.cfg.example to /bin/install.cfg with your settings."
             exit 1
         else
             attempts=$((attempts + 1))
-            echo "Invalid input. Please enter 'y' or 'n'. Attempt $attempts of $max_attempts."
+            echo_error "Invalid input. Please enter 'y' or 'n'. Attempt $attempts of $max_attempts."
         fi
     done
 
-    echo "Exceeded maximum attempts. Exiting."
+    echo_error "Exceeded maximum attempts. Exiting."
     exit 1
 fi
 
@@ -38,14 +42,14 @@ update_repository() {
 
     if [ -d "$repo_dir" ]; then
         # If the directory exists, then do a git pull
-        echo "Updating $repo_dir..."
+        echo_warning "Updating $repo_dir..."
         cd "$repo_dir" || exit
         git checkout $repo_branch
         git pull
         cd - || exit
     else
         # If the directory does not exist, then do a git clone
-        echo "Cloning $repo_url into $repo_dir..."
+        echo_warning "Cloning $repo_url into $repo_dir..."
         git clone -b "$repo_branch" "$repo_url" "$repo_dir"
     fi
 }
@@ -84,9 +88,9 @@ if [ -f conf/sharix_open.service ]; then
     echo "File sharix_open.service already exists"
 else
     cp conf/sharix_open.service.example conf/sharix_open.service
-    echo "File sharix_open.service was successfully created"
-    echo "Write the settings for systemd service."
-    echo "Restart install.sh script after editing."
+    echo_success "File sharix_open.service was successfully created"
+    echo "Write the settings for systemd service, if you want."
+    echo_warning "To continue, restart the install.sh"
     exit
 fi