some explanations in create_env

This commit is contained in:
asus
2024-01-31 22:18:34 +01:00
parent f53faf934b
commit 9a259a93ca

View File

@@ -31,6 +31,32 @@ WP_USER_EMAIL=moehu36@42.fr
EXECUTION_TIME=300
# if you want to get the home directory you can use $(HOME)
# however, this will not give the same result if you use sudo, ex :
# ./create_env : /home/asususus
# sudo ./create_env : /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 :
# - echo "$SUDO_USER" :
# - in normal mode it outputs : ""
# - in sudo mode it outputs 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
HOME_PATH=$(eval echo "~$SUDO_USER")
HOST_VOLUME_WP=${HOME_PATH}/data/lejourduprof/wp_volume