modified makefile to produce same home dir in sudo mode
This commit is contained in:
16
Makefile
16
Makefile
@@ -24,12 +24,26 @@ RESET = "\e[0m"
|
||||
|
||||
COMPOSE = ./srcs/docker-compose.yml
|
||||
|
||||
# in makefile you can use an env variable directly as a make variable :
|
||||
# -> https://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_6.html#SEC68
|
||||
# so if you want to get the home directory you can use $(HOME)
|
||||
# however, this will not give the same result if you run make in sudo, ex :
|
||||
# make : /home/asususus
|
||||
# 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
|
||||
USER_HOME := $(shell echo ~$$SUDO_USER)
|
||||
# extract env variables in .env file
|
||||
# then expend the home path
|
||||
# then expend the pwd path
|
||||
# and finally remove the leading "EXPEND_" word
|
||||
EXPENDED_ENV_VAR := $(shell grep "^#EXPEND_" ./srcs/.env)
|
||||
EXPENDED_ENV_VAR := $(subst $$HOME_PATH,$(HOME),$(EXPENDED_ENV_VAR))
|
||||
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_%=%)
|
||||
|
||||
|
||||
@@ -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=/home/asususus/data/lejourduprof/db_volume
|
||||
HOST_VOLUME_WP=/home/asususus/data/lejourduprof/wp_volume
|
||||
HOST_VOLUME_DB=/root/data/lejourduprof/db_volume
|
||||
HOST_VOLUME_WP=/root/data/lejourduprof/wp_volume
|
||||
|
||||
|
||||
Reference in New Issue
Block a user