From a43d22a81cf21dab2e4a1f856723e2c4800f8a5b Mon Sep 17 00:00:00 2001 From: asus Date: Thu, 14 Sep 2023 13:46:13 +0200 Subject: [PATCH] last modif in env var its now working --- Makefile | 50 +++++++++++++++++++++++++++++--------------------- README.md | 22 +++++++++++++++++----- srcs/.env | 10 +++++----- 3 files changed, 51 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index 92586f4..6db8d85 100644 --- a/Makefile +++ b/Makefile @@ -32,13 +32,26 @@ COMPOSE = ./srcs/docker-compose.yml # sudo make : /root # but you can use this command `eval echo "~$SUDO_USER"` to get # the home directory of the user using sudo, it works in non-sudo also : -# - $SUDO_USER : -# - in normal mode its value is "" -# - in sudo mode its value is the user (same as $USER in normal mode) -# - ~$SUDO_USER : -# - in linux "~USER" print the home directory of a user +# - echo "$SUDO_USER" : +# - in normal mode it output : "" +# - in sudo mode it output the user : "username" +# - same as $USER in normal mode +# - echo "~$SUDO_USER" : +# - in linux "~USER" is the home directory of a user +# - but echo "something" will treat ~ as a string litteral +# - so the output in mormal mode will be : "~" +# - and in sudo mode it will be : "~username" +# - eval echo "~$SUDO_USER" : +# - eval will evaluate the expression and perform expansion one more time +# - so it will evaluate the output of `echo "~$SUDO_USER"` +# - in normal mode : +# - it will evaluate : "~" +# - and ouptput : "/home/username" +# - in sudo mode : +# - it will evaluate : "~username" +# - and output : "/home/username" +# - because "~username" expand in the home (~) directory of given user # https://stackoverflow.com/questions/77088135/makefile-subst-doesnt-use-make-variable-as-expected -#USER_HOME := $(shell echo ~$$SUDO_USER) USER_HOME := $(shell eval echo "~$$SUDO_USER") # extract env variables in .env file # then expend the home path @@ -48,8 +61,6 @@ EXPENDED_ENV_VAR := $(shell grep "^#EXPEND_" ./srcs/.env) EXPENDED_ENV_VAR := $(subst $$HOME_PATH,$(USER_HOME),$(EXPENDED_ENV_VAR)) EXPENDED_ENV_VAR := $(subst $$PWD_PATH,$(shell pwd),$(EXPENDED_ENV_VAR)) EXPENDED_ENV_VAR := $(EXPENDED_ENV_VAR:#EXPEND_%=%) -TESTVAR := $(subst $$HOME_PATH,$(USER_HOME),"$$HOME_PATH/project/dir") -TESTVAR := $(USER_HOME)/project/dir # this creates a list of the path from the list of the variables : # VAR_1=/path/to_1 VAR_2=/path/to_2 @@ -78,28 +89,25 @@ VOLUMES = $(shell docker volume ls -q) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # -#all: require build up -all: testt - -testt: - @echo $(B_YELLOW)"user home:"$(RESET) - @echo $(USER_HOME) - @echo $(B_YELLOW)"expended env var:"$(RESET) - @echo $(EXPENDED_ENV_VAR) - @echo $(B_YELLOW)"test var:"$(RESET) - @echo $(TESTVAR) +all: require build up require: # remove all the lines starting with "HOST_VOLUME_" in .env + @echo $(B_PURPLE)"removes all lines starting with 'HOST_VOLUMES' in .env"$(RESET) @sed -i "/^HOST_VOLUME_/d" ./srcs/.env # add new expended lines starting with "HOST_VOLUME_" after the line "# EXPENDED LINES :" in .env + @echo $(B_PURPLE)"add new expended lines starting with 'HOST_VOLUME_' in .env"$(RESET) @$(foreach val,$(EXPENDED_ENV_VAR),sed -i "/^# EXPENDED LINES/a\$(val)" ./srcs/.env;) # create the volumes directories - mkdir -p $(VOLUMES_D) + @echo $(B_PURPLE)"create the volumes directories"$(RESET) + @mkdir -p $(VOLUMES_D) # create the ssl folder to avoid pbm at nginx docker creation - mkdir -p ./srcs/requirements/nginx/conf/ssl + @echo $(B_PURPLE)"create the ssl folder"$(RESET) + @mkdir -p ./srcs/requirements/nginx/conf/ssl # verify if the wordpress url is added to the local path - - if ! grep "127.0.0.1 $(WP_URL)" /etc/hosts 2> /dev/null; then \ + @echo $(B_PURPLE)"verify if the wordpress url is added to the local path"$(RESET) + @- if ! grep "127.0.0.1 $(WP_URL)" /etc/hosts 2> /dev/null; then \ + @echo $(B_PURPLE)"nop ! adding it"$(RESET) \ bash -c 'echo -e "\n# adding for lejourduprof (you can delete it)\n127.0.0.1 $(WP_URL)" >> /etc/hosts'; \ fi diff --git a/README.md b/README.md index 5295d05..48b1ad8 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ - end: 18h - len: 1h30 - total: 3h - - tarif: 90€ + - money: 90€ - 09/09/23 - begin: 16h30 @@ -47,7 +47,7 @@ - end: 17h30 - len: 1h - total: 1h - - tarif: 30€ + - money: 30€ - 10/09/23 - begin: 10h @@ -55,7 +55,7 @@ - end: 12h - len: 2h - total: 2h - - tarif: 60€ + - money: 60€ - 11/09/23 - begin: 10h @@ -63,7 +63,7 @@ - end: 13h30 - len: 3h30 - total: 3h30 - - tarif: 105€ + - money: 105€ - 12/09/23 - begin: 9h30 @@ -71,7 +71,19 @@ - end: 12h15 - len: 2h45 - total: 2h45 - - tarif: 82€50 + - money: 82€50 + +- 14/09/23 + - begin: 11h30 + - mes: "" + - end: 12h + - len: 0h30 + - begin: 13h + - mes: "" + - end: h + - len: h + - total: h + - money: € #### total : 90 + 30 = 120€ diff --git a/srcs/.env b/srcs/.env index 8b08534..4c2a553 100644 --- a/srcs/.env +++ b/srcs/.env @@ -31,10 +31,10 @@ MAX_UPLOAD_SIZE=512 EXECUTION_TIME=300 # env file does not have expension capacity, so we simulate it with makefile : -# 1. the lines starting with EXPEND_ will be retrieved by the makefil +# 1. the lines starting with "#EXPEND_" will be retrieved by the makefile # 2. then it will expend the $HOME_PATH and $PWD_PATH -# 3. then it will remove the leading "EXPEND_" word -# 4. then it will erase all the line starting with "HOST_VOLUME_" +# 3. then it will remove the leading "#EXPEND_" word +# 4. then it will erase all the line starting with "HOST_VOLUME_" if they exist # 5. and finally it will add the expended lines after the line "EXPENDED LINES :" # LINES TO EXPEND : #EXPEND_HOST_VOLUME_WP=$HOME_PATH/data/lejourduprof/wp_volume @@ -44,6 +44,6 @@ EXECUTION_TIME=300 # EXPENDED LINES : HOST_VOLUME_CERTS=/home/asususus/Nextcloud/informatique/lejourduprof/srcs/requirements/nginx/conf/ssl HOST_VOLUME_PLUGINS=/home/asususus/Nextcloud/informatique/lejourduprof/srcs/plugins -HOST_VOLUME_DB=~/data/lejourduprof/db_volume -HOST_VOLUME_WP=~/data/lejourduprof/wp_volume +HOST_VOLUME_DB=/home/asususus/data/lejourduprof/db_volume +HOST_VOLUME_WP=/home/asususus/data/lejourduprof/wp_volume