last modif in env var its now working
This commit is contained in:
50
Makefile
50
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user