From c42216bce8b06d01c5a20a9c22f727ec820233cb Mon Sep 17 00:00:00 2001 From: rockySagar Date: Thu, 25 Aug 2022 11:16:07 +0530 Subject: [PATCH 1/2] license --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..9ac31bcd2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 ShikshaLokam + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file From 693e3589c10441a6836f8e72b859daad29220620 Mon Sep 17 00:00:00 2001 From: rakesh kumar Date: Thu, 13 Oct 2022 11:26:05 +0530 Subject: [PATCH 2/2] deployment scripts added --- deployment/ansible.yml | 66 +++++++++++++++++++++++++++++++++++++++++ src/scripts/json2env.sh | 4 +++ 2 files changed, 70 insertions(+) create mode 100644 deployment/ansible.yml create mode 100644 src/scripts/json2env.sh diff --git a/deployment/ansible.yml b/deployment/ansible.yml new file mode 100644 index 000000000..2da9a710f --- /dev/null +++ b/deployment/ansible.yml @@ -0,0 +1,66 @@ +--- +- hosts: elevateDev + vars: + #contents: "{{ lookup('file', '/opt/rsync/text.txt') }}" + project_path: /opt/backend/deployment + tasks: + - name: Slurp hosts file + slurp: + src: /opt/backend/test/.token + register: slurpfile + #- debug: msg="{{ slurpfile['content'] | b64decode }}" + #- debug: msg="the value of foo.txt is {{ contents }}" + - name: Run vault credentials + shell: "curl --location --request GET '{{ vaultAddress }}v1/elevate/data/users' --header 'X-Vault-Token: {{ slurpfile['content'] | b64decode }}' | jq '.data' > '{{ project_path +}}/data2.json'" + register: vaultCurl + - name: Set some variable + set_fact: + release_path: "{{ project_path }}/releases/{{ lookup('pipe','date +%Y%m%d%H%M%S') }}" + current_path: "{{ project_path }}/users" + - name: Retrieve current release folder + command: readlink -f users + register: current_release_path + ignore_errors: yes + args: + chdir: "{{ project_path }}" + - name: Create new folder + file: + dest={{ release_path }} + mode=0755 + recurse=yes + state=directory + - name: Clone the repository + git: + repo: https://github.com/ELEVATE-Project/user.git + dest: "{{ release_path }}" + clone: yes + update: yes + version: dev + - name: Update npm + shell: cd {{release_path}}/src && npm i + + - name: Update symlink + file: + src={{ release_path }} + dest={{ current_path }} + state=link + - name: Delete old pm2 process + command: pm2 delete elevate-mentoring + ignore_errors: yes + + - name: set permission + shell: chmod 744 {{ current_path }}/src/scripts/json2env.sh + + - name: generate .env + shell: cat {{ project_path }}/data2.json | {{ current_path }}/src/scripts/json2env.sh > {{ current_path }}/src/.env + register: envConfig + - debug: msg=" cred {{ envConfig }} " + + - name: Start pm2 + command: "chdir={{current_path}}/src pm2 start app.js -i 2 --name elevate-notification" + register: pm2Info + + - name: debug info + debug: + msg: "Pm2 log {{pm2Info}}" \ No newline at end of file diff --git a/src/scripts/json2env.sh b/src/scripts/json2env.sh new file mode 100644 index 000000000..df5a8a66c --- /dev/null +++ b/src/scripts/json2env.sh @@ -0,0 +1,4 @@ +#!/bin/sh +tr -d '\n' | + grep -o '"[A-Za-z_][A-Za-z_0-9]\+"\s*:\s*\("[^"]\+"\|[0-9\.]\+\|true\|false\|null\)' | + sed 's/"\(.*\)"\s*:\s*"\?\([^"]\+\)"\?/\1="\2"/' \ No newline at end of file