From 4d09020ba3b629dbd775219085f233bca4f01c0f Mon Sep 17 00:00:00 2001
From: Yoan VALLET <ext.sopra.yvallet@grandlyon.com>
Date: Tue, 9 Mar 2021 17:02:31 +0100
Subject: [PATCH] add scripts and commands for easy cozy

---
 docs/easycozy/commands.md                     | 86 +++++++++++++++++++
 docs/easycozy/index.md                        |  2 -
 docs/easycozy/scripts.md                      | 32 +++++++
 .../project_architecture/environments.md      |  4 +-
 mkdocs.yml                                    |  3 +-
 5 files changed, 122 insertions(+), 5 deletions(-)
 create mode 100644 docs/easycozy/commands.md
 delete mode 100644 docs/easycozy/index.md
 create mode 100644 docs/easycozy/scripts.md

diff --git a/docs/easycozy/commands.md b/docs/easycozy/commands.md
new file mode 100644
index 0000000..3e4bc3c
--- /dev/null
+++ b/docs/easycozy/commands.md
@@ -0,0 +1,86 @@
+Here are common commands use on dev environment.
+
+# App
+
+## Install a specific version of an app
+
+```bash
+$ cd /easy-cozy
+$ docker-compose exec cozy ./cozy apps update home --domain "[name].cozy.self-data.alpha.grandlyon.com" git://github.com/doubleface/cozy-collect.git#build-debug
+```
+
+# Konnector
+
+## Install a specific version of a konnector
+
+```bash
+$ cd /easy-cozy
+# cozy-stack konnectors uninstall ${konn} --domain ${url}
+$ docker-compose exec cozy ./cozy konnectors uninstall grdfgrandlyon --domain "[name].cozy.self-data.alpha.grandlyon.com"
+grdfgrandlyon has been uninstalled
+# cozy-stack konnectors install ${konn} --domain ${url}
+$ docker-compose exec cozy ./cozy konnectors install grdfgrandlyon --domain "[name].cozy.self-data.alpha.grandlyon.com" git://forge.grandlyon.com/web-et-numerique/llle_project/grdf-adict-konnector.git#build
+grdfgrandlyon (0.1.5-a3f6f05d9fde7c705b811658b3ce3667a9d7d0b5) has been installed on [name].cozy.self-data.alpha.grandlyon.com
+```
+
+## Update the version of a konnector
+
+```bash
+$ cd /easy-cozy
+# cozy-stack konnectors update ${konn} --domain ${url}
+$ docker-compose exec cozy ./cozy konnectors update grdfgrandlyon --domain "[name].cozy.self-data.alpha.grandlyon.com"
+grdfgrandlyon has been upgraded to 0.1.5-d4bbe7350ecf13d13734f559c538e3c0ee8dc7ae
+```
+## Run a konnector from the stack
+
+```bash
+$ cd /root/easy-cozy
+# cozy-stack konnectors run ${konn} --domain ${url}
+$ docker-compose exec cozy ./cozy konnectors run grdfgrandlyon --domain "[name].cozy.self-data.alpha.grandlyon.com"
+```
+
+# Instance
+
+## Set log level to debug for an instance
+
+```bash
+$ cd /root/easy-cozy
+# cozy-stack instances debug ${url} true
+$ docker-compose exec cozy ./cozy instances debug --domain "[name].cozy.self-data.alpha.grandlyon.com" true
+```
+
+
+# Stack
+
+## Check stack version
+
+```bash
+$ cd /easy-cozy
+$ docker-compose exec cozy ./cozy version
+```
+
+## Update stack version
+
+Update version in the Dockerfile on gitlab.
+
+**On serveur :**
+
+1. git pull or change localy the version in cozy-stack/Dockerfile
+2. create the docker image using:
+
+    ```bash
+    cd /easy-cozy/build
+    ./build-docker-image.sh
+    ```
+
+3. Start the container based on the built image
+
+    ```bash
+    cd ..
+    docker-compose up -d cozy
+    ```
+
+!!! info "Error encounter"
+    Docker container was not launched, when consulting logs we can see the folowing error
+    > ./cozy: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by ./cozy)
+    We have replaced debian:stable-slim with unbuntu:20.10 as installer for our docker build:  [https://forge.grandlyon.com/pocs/cozy/easy-cozy/-/commit/48a30a03f209169e0f1ebb0d106bb4361e7cd167](https://forge.grandlyon.com/pocs/cozy/easy-cozy/-/commit/48a30a03f209169e0f1ebb0d106bb4361e7cd167)
diff --git a/docs/easycozy/index.md b/docs/easycozy/index.md
deleted file mode 100644
index 2f4f692..0000000
--- a/docs/easycozy/index.md
+++ /dev/null
@@ -1,2 +0,0 @@
-!!! info ""
-    :construction: Section under Construction :construction:
\ No newline at end of file
diff --git a/docs/easycozy/scripts.md b/docs/easycozy/scripts.md
new file mode 100644
index 0000000..b8388bf
--- /dev/null
+++ b/docs/easycozy/scripts.md
@@ -0,0 +1,32 @@
+# Easy Cozy scripts
+
+Easy cozy project comes with 2 main scripts: 
+- create-instance.sh: used to create an instance for a user
+- remove-instance.sh: used to remove an instance for a specific user
+
+In addition of these scripts we have added custom scripts for some specific needs. All these scripts are available in the "admin_scripts" folder
+
+# Scripts for instances
+
+| Scripts           | Args              | Description                                              |
+|-------------------|-------------------|----------------------------------------------------------|
+| reset_instance.sh | instance_url      | Remove and recreate again the instance for a given user  |
+
+# Scripts for applications
+
+| Scripts                  | Args              | Description                                                                   |
+|--------------------------|-------------------|-------------------------------------------------------------------------------|
+| update_all_ecolyo_dev.sh | none              | update Ecolyo with last version from build-dev branch on all instances        |
+| update_ecolyo_master.sh  | instance_url      | update Ecolyo with last version from build branch on a specific instance      |
+| update_ecolyo_dev.sh     | instance_url      | update Ecolyo with last version from build-dev branch on a specific instance  |
+| update_ecolyo_test.sh    | instance_url      | update Ecolyo with last version from build-test branch on a specific instance |
+| update_pilote_master.sh  | instance_url      | update Pilote with last version from build-dev branch on a specific instance  |
+| update_pilote_dev.sh     | instance_url      | update PIlote with last version from build-test branch on a specific instance |
+
+# Scripts for konnectors
+
+| Scripts                         | Args              | Description                                                                            |
+|---------------------------------|-------------------|----------------------------------------------------------------------------------------|
+| update_enedis_konnector_prod.sh | instance_url      | update Enedis konnector with last version from build branch on a specific instance     |
+| update_enedis_konnector_dev.sh  | instance_url      | update Enedis konnector with last version from build-dev branch on a specific instance |
+
diff --git a/docs/ecolyo/project_architecture/environments.md b/docs/ecolyo/project_architecture/environments.md
index fe8910f..d59d44f 100644
--- a/docs/ecolyo/project_architecture/environments.md
+++ b/docs/ecolyo/project_architecture/environments.md
@@ -22,7 +22,7 @@ This projet will build and run 3 images:
 To run the project please refer to the documentation on the GitLab project.
 
 Once the project is up and running, we are able to create, update and delete instance.
-Let's see more details in the dedicated section.
+Let's see more details in the [dedicated section](../../easycozy/scripts.md).
 
 ### Proxy
 
@@ -42,7 +42,7 @@ docker-compose up -d
 
 By default the version present on the "build-dev" branch is used to install Ecolyo app and konnectors on a new instance.
 
-Some scripts has been created in order to install, update, downgrade, remove app and konnectors. Please refer to the dedicated section for more information.
+Some scripts has been created in order to install, update, downgrade, remove app and konnectors. Please refer to the [dedicated section](../../easycozy/scripts.md) for more information.
 
 ## Prod environment
 
diff --git a/mkdocs.yml b/mkdocs.yml
index b3c34c9..4ccc314 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -25,7 +25,8 @@ extra_css:
 nav:
   - Home: index.md
   - Easy Cozy:
-    - Index: easycozy/index.md
+    - Scripts: easycozy/scripts.md
+    - Commands: easycozy/commands.md
   - Pilote:
       - Pilote - TS - Back:
           - Index: pilote/Pilote - TS - Back/index.md
-- 
GitLab