From 7bfb84463c1e50afdbd89bcc233b27f69a070dcf Mon Sep 17 00:00:00 2001 From: asus Date: Thu, 1 Feb 2024 15:30:33 +0100 Subject: [PATCH] added env_generator as submodule --- .gitmodules | 3 ++ srcs/env_generator | 1 + srcs/env_generator/create_env.sh | 47 -------------------------------- 3 files changed, 4 insertions(+), 47 deletions(-) create mode 100644 .gitmodules create mode 160000 srcs/env_generator delete mode 100755 srcs/env_generator/create_env.sh diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..7a41eb9 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "srcs/env_generator"] + path = srcs/env_generator + url = git@bitbucket.org:hugogogo/script_env_generator.git diff --git a/srcs/env_generator b/srcs/env_generator new file mode 160000 index 0000000..d26a2b2 --- /dev/null +++ b/srcs/env_generator @@ -0,0 +1 @@ +Subproject commit d26a2b2902424022a2bfe65decf96c2253dff653 diff --git a/srcs/env_generator/create_env.sh b/srcs/env_generator/create_env.sh deleted file mode 100755 index 865b5cb..0000000 --- a/srcs/env_generator/create_env.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -# - this script creates a .env file in the same directory of the model.env -# - the model.env file is given in argument, otherwise it default to current path - -# change to where the script is relatively to where the execution is made -#cd $(dirname $0) - -CURRENT_PATH=$(dirname $0) -if [ $# -eq 0 ]; then - FILE_PATH="${CURRENT_PATH}/model.env" - ENV_PATH=${CURRENT_PATH} -else - FILE_PATH="$1" - ENV_PATH=$(dirname $FILE_PATH) -fi -if [ ! -f "$FILE_PATH" ]; then - echo "" - echo " no file 'model.env' found" - echo "" - echo " you need to create one in the same directory of this script," - echo " or to give the path to a valide one in argument" - echo "" - echo " like './create_env path/to/model.env'" - echo " " - echo " note that the .env file will be created where the model.env is" - echo "" - exit 1 -fi - -TMP_FILE="tmpfile_3289442091310922474928" -TMP_BEFORE="env_before.tmp" -TMP_AFTER="env_after.tmp" - -# add lines at beginning and end of a temp env file -echo "set | sort > ${TMP_BEFORE}" > ${TMP_FILE} -cat ${FILE_PATH} >> ${TMP_FILE} -echo "set | sort > ${TMP_AFTER}" >> ${TMP_FILE} - -source ${TMP_FILE} - -# diff between the two set files == the newly created env var -NEW_ENV=$(comm -13 ${TMP_BEFORE} ${TMP_AFTER} | grep -v "^_=") -echo "${NEW_ENV}" > ${ENV_PATH}/.env - -rm -f ${TMP_BEFORE} ${TMP_AFTER} ${TMP_FILE} -