Browse Source

If there are no apps installed, the stop script won't fail anymore.

dextreem 2 năm trước cách đây
mục cha
commit
ddbc0df7e6
1 tập tin đã thay đổi với 14 bổ sung10 xóa
  1. 14 10
      scripts/stop.sh

+ 14 - 10
scripts/stop.sh

@@ -23,17 +23,21 @@ cd "$ROOT_FOLDER"
 export DOCKER_CLIENT_TIMEOUT=240
 export COMPOSE_HTTP_TIMEOUT=240
 
-# Get all app names from the apps folder
+# Stop all installed apps if there are any
 apps_folder="${ROOT_FOLDER}/apps"
-apps_names=($(ls -d ${apps_folder}/*/ | xargs -n 1 basename | sed 's/\///g'))
-
-for app_name in "${apps_names[@]}"; do
-  # if folder ${ROOT_FOLDER}/app-data/app_name exists, then stop app
-  if [[ -d "${ROOT_FOLDER}/app-data/${app_name}" ]]; then
-    echo "Stopping ${app_name}"
-    "${ROOT_FOLDER}/scripts/app.sh" stop $app_name
-  fi
-done
+if [ "$(find ${apps_folder} -maxdepth 1 -type d | wc -l)" -gt 1 ]; then
+  apps_names=($(ls -d ${apps_folder}/*/ | xargs -n 1 basename | sed 's/\///g'))
+
+  for app_name in "${apps_names[@]}"; do
+    # if folder ${ROOT_FOLDER}/app-data/app_name exists, then stop app
+    if [[ -d "${ROOT_FOLDER}/app-data/${app_name}" ]]; then
+      echo "Stopping ${app_name}"
+      "${ROOT_FOLDER}/scripts/app.sh" stop $app_name
+    fi
+  done
+else
+  echo "No app installed that can be stopped."
+fi
 
 echo "Stopping Docker services..."
 echo