added a env file generator with expansions
This commit is contained in:
6
Makefile
6
Makefile
@@ -156,7 +156,11 @@ re: fclean all
|
||||
# !! remove everything everything
|
||||
erase_v:
|
||||
- rm -rf $(VOLUMES_D)
|
||||
new: erase_v re
|
||||
$(MAKE) fclean
|
||||
new: erase_v $(NAME)
|
||||
|
||||
try:
|
||||
./test.sh
|
||||
|
||||
.PHONY : all $(VOLUMES_D) require build up list clean fclean re erase_v new
|
||||
|
||||
|
||||
58
srcs/.env
58
srcs/.env
@@ -1,48 +1,22 @@
|
||||
|
||||
# NGINX SETUP
|
||||
|
||||
NG_VOLUME_CERTS=/etc/ssl
|
||||
MAX_UPLOAD_SIZE=512
|
||||
|
||||
# MARIADB SETUP
|
||||
|
||||
DB_HOST=mariadb
|
||||
DB_NAME=db_wp_inception
|
||||
DB_PSWD='too bad you have read this now i have to erase your memory'
|
||||
DB_USER=user_wp_inception
|
||||
DB_PSWD="too bad you have read this now i have to erase your memory"
|
||||
|
||||
# WORDPRESS SETUP
|
||||
|
||||
WP_URL=local_lejourduprof.com
|
||||
EXECUTION_TIME=300
|
||||
HOME_PATH=/home/asususus
|
||||
HOST_VOLUME_DB=/home/asususus/data/lejourduprof/db_volume
|
||||
HOST_VOLUME_PLUGINS=/srcs/plugins
|
||||
HOST_VOLUME_WP=/home/asususus/data/lejourduprof/wp_volume
|
||||
MAX_UPLOAD_SIZE=512
|
||||
NG_VOLUME_CERTS=/etc/ssl
|
||||
WP_ADMIN_EMAIL=hulamy@42.fr
|
||||
WP_ADMIN=hulamy
|
||||
WP_ADMIN_PSWD='you shall not password !'
|
||||
WP_PORT=3003
|
||||
WP_TITLE=title
|
||||
WP_URL=local_lejourduprof.com
|
||||
WP_USER_EMAIL=moehu36@42.fr
|
||||
WP_USER=moehu36
|
||||
WP_USER_PSWD='it'\''s a secret for nobody'
|
||||
WP_VOLUME_DIR=/var/www/html
|
||||
WP_VOLUME_PLUGINS=/home/www-data
|
||||
WP_TITLE=title
|
||||
|
||||
WP_ADMIN=hulamy
|
||||
WP_ADMIN_PSWD="you shall not password !"
|
||||
WP_ADMIN_EMAIL=hulamy@42.fr
|
||||
|
||||
WP_USER=moehu36
|
||||
WP_USER_PSWD="it's a secret for nobody"
|
||||
WP_USER_EMAIL=moehu36@42.fr
|
||||
|
||||
# MAP
|
||||
|
||||
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 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_" 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
|
||||
#EXPEND_HOST_VOLUME_DB=$HOME_PATH/data/lejourduprof/db_volume
|
||||
#EXPEND_HOST_VOLUME_PLUGINS=$PWD_PATH/srcs/plugins
|
||||
# EXPENDED LINES :
|
||||
HOST_VOLUME_PLUGINS=/home/asususus/nextcloud_backup/backup_planethoster_server/nextclouddata/hugogogo/files/informatique/wordpress_docker/srcs/plugins
|
||||
HOST_VOLUME_DB=/home/asususus/data/lejourduprof/db_volume
|
||||
HOST_VOLUME_WP=/home/asususus/data/lejourduprof/wp_volume
|
||||
|
||||
|
||||
47
srcs/create_env.sh
Normal file
47
srcs/create_env.sh
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/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}" > ${CURRENT_PATH}/.env
|
||||
|
||||
rm -f ${TMP_BEFORE} ${TMP_AFTER} ${TMP_FILE}
|
||||
|
||||
39
srcs/model.env
Normal file
39
srcs/model.env
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
# NGINX SETUP
|
||||
|
||||
NG_VOLUME_CERTS=/etc/ssl
|
||||
MAX_UPLOAD_SIZE=512
|
||||
|
||||
# MARIADB SETUP
|
||||
|
||||
DB_HOST=mariadb
|
||||
DB_NAME=db_wp_inception
|
||||
DB_USER=user_wp_inception
|
||||
DB_PSWD="too bad you have read this now i have to erase your memory"
|
||||
|
||||
# WORDPRESS SETUP
|
||||
|
||||
WP_URL=local_lejourduprof.com
|
||||
WP_PORT=3003
|
||||
WP_VOLUME_DIR=/var/www/html
|
||||
WP_VOLUME_PLUGINS=/home/www-data
|
||||
WP_TITLE=title
|
||||
|
||||
WP_ADMIN=hulamy
|
||||
WP_ADMIN_PSWD="you shall not password !"
|
||||
WP_ADMIN_EMAIL=hulamy@42.fr
|
||||
|
||||
WP_USER=moehu36
|
||||
WP_USER_PSWD="it's a secret for nobody"
|
||||
WP_USER_EMAIL=moehu36@42.fr
|
||||
|
||||
# MAP
|
||||
|
||||
EXECUTION_TIME=300
|
||||
|
||||
HOME_PATH=$(eval echo "~$SUDO_USER")
|
||||
|
||||
HOST_VOLUME_WP=${HOME_PATH}/data/lejourduprof/wp_volume
|
||||
HOST_VOLUME_DB=${HOME_PATH}/data/lejourduprof/db_volume
|
||||
HOST_VOLUME_PLUGINS=${PWD_PATH}/srcs/plugins
|
||||
|
||||
Reference in New Issue
Block a user