From 66623b233e4a251789a500f6ee384776d735c574 Mon Sep 17 00:00:00 2001
From: Ludivine Premont <ludivine.premont@veremes.com>
Date: Thu, 3 Dec 2020 09:19:06 +0100
Subject: [PATCH] initialisation bin

---
 bin/clone_deps.sh      | 36 +++++++++++++++++++
 bin/mount_project.sh   | 64 +++++++++++++++++++++++++++++++++
 bin/unmount_project.sh | 81 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 181 insertions(+)
 create mode 100755 bin/clone_deps.sh
 create mode 100755 bin/mount_project.sh
 create mode 100755 bin/unmount_project.sh

diff --git a/bin/clone_deps.sh b/bin/clone_deps.sh
new file mode 100755
index 00000000..1d784ed4
--- /dev/null
+++ b/bin/clone_deps.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+#
+# 	Script à lancer pour l'installation d'une application Vitis
+#
+#   Paramètres obligatoires :
+#       --app_path : chemin vers le répertoire d'installation d'application
+#
+#
+
+for i in "$@"
+do
+case $i in
+  # param app_path
+  --app_path=*)
+  app_path="${i#*=}"
+  shift
+  ;;
+esac
+done
+
+if [ -z ${app_path+x} ]
+then
+  echo "--app_path required"
+  exit 1
+fi
+
+cd $app_path
+echo "---- Clone Repos ----"
+
+if [ -d src ]; then
+  mkdir -p src
+fi
+
+git clone git@gitlab.veremes.net:Development/vitis-2020/sources/vitis.git src/vitis
+git clone git@gitlab.veremes.net:Development/vitis-2020/sources/module-vmap.git src/module_vmap
\ No newline at end of file
diff --git a/bin/mount_project.sh b/bin/mount_project.sh
new file mode 100755
index 00000000..3ae59e89
--- /dev/null
+++ b/bin/mount_project.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+#
+#
+# 	Script à lancer pour l'installation d'une application Vitis
+#
+#   Paramètres obligatoires :
+#       --app_path : chemin vers le répertoire d'installation d'application
+#
+#
+
+for i in "$@"
+do
+case $i in
+  # param app_path
+  --app_path=*)
+  app_path="${i#*=}"
+  shift
+  ;;
+esac
+done
+
+if [ -z ${app_path+x} ]
+then
+  echo "--app_path required"
+  exit 1
+fi
+
+cd $app_path
+echo "---- Generate Client ----"
+mkdir -p client
+empty=`ls -a client | sed -e "/\.$/d" | wc -l`
+
+if [ $empty -eq 0 ]
+then
+  echo "---- Mount module's assets folder ----"
+  sudo mount --bind src/vitis/client client
+  mkdir -p client/src/modules/vmap
+  sudo mount --bind src/module_vmap/module client/src/modules/vmap
+  mkdir -p client/src/conf
+  sudo mount --bind conf client/src/conf
+
+  # Motage des modules Angular
+  if [ -f conf/modules-components.ts ]; then
+    cp -f conf/modules-components.ts src/vitis/client/src/app/modules/modules-components.ts
+  else
+    cp -f src/vitis/client/src/app/modules/modules-components.sample.ts src/vitis/client/src/app/modules/modules-components.ts
+  fi
+  if [ -d src/module_vmap/module/components ]; then
+    mkdir src/vitis/client/src/app/modules/vmap
+    sudo mount --bind src/module_vmap/module/components client/src/app/modules/vmap
+  fi
+fi
+
+echo "---- Generate VAS ----"
+mkdir -p vas
+empty=`ls -a vas | sed -e "/\.$/d" | wc -l`
+
+if [ $empty -eq 0 ]
+then
+  echo "---- Mount module's WebServices folder ----"
+  sudo mount --bind src/vitis/vas vas
+  mkdir -p vas/src/Module/Vmap
+  sudo mount --bind src/module_vmap/web_services vas/src/Module/Vmap
+fi
diff --git a/bin/unmount_project.sh b/bin/unmount_project.sh
new file mode 100755
index 00000000..5799a3cb
--- /dev/null
+++ b/bin/unmount_project.sh
@@ -0,0 +1,81 @@
+#!/bin/bash
+#
+#
+# 	Script à lancer pour l'installation d'une application Vitis
+#
+#   Paramètres obligatoires :
+#       --app_path : chemin vers le répertoire d'installation d'application
+#
+#
+
+for i in "$@"
+do
+case $i in
+  # param app_path
+  --app_path=*)
+  app_path="${i#*=}"
+  shift
+  ;;
+esac
+done
+
+if [ -z ${app_path+x} ]
+then
+  echo "--app_path required"
+  exit 1
+fi
+
+cd $app_path
+
+# Démonte un dossier
+unmount_folder() {
+  if [ -d "$1" ]; then
+    if mount | grep "$app_path/$1" > /dev/null; then
+      echo "Unmount $1"
+      sudo umount "$app_path/$1"
+    fi
+  fi
+}
+
+# Démote les points de montages contenus dans un dossier
+unmount_containing_folders() {
+  if [ -d "$1" ]; then
+    for f in "$1"/*; do
+      if [ -d "$f" ]; then
+        unmount_folder "$f"
+      fi
+    done
+  fi
+}
+
+echo "--------------------------------"
+echo "---- Unmount client folders ----"
+echo "--------------------------------"
+
+# Démote src/vitis/client/src/modules/*
+unmount_containing_folders "src/vitis/client/src/modules"
+
+# Démote src/vitis/client/src/app/modules/*
+unmount_containing_folders "src/vitis/client/src/app/modules"
+
+# Démonte src/vitis/client/src/conf
+unmount_folder "src/vitis/client/src/conf"
+
+# Démonte client
+unmount_folder "client"
+
+# Supprime modules-components.ts
+sudo rm src/vitis/client/src/app/modules/modules-components.ts
+
+echo "-----------------------------"
+echo "---- Unmount vas folders ----"
+echo "-----------------------------"
+
+# Démote src/vitis/vas/engine/*
+unmount_containing_folders "src/vitis/vas/engine"
+
+# Démote src/vitis/vas/src/Module/*
+unmount_containing_folders "src/vitis/vas/src/Module"
+
+# Démonte vas
+unmount_folder "vas"
\ No newline at end of file
-- 
GitLab