diff --git a/Makefile b/Makefile index f0955ace57478c70a3f4ba341482ac4ffbc9f473..a34f7fd2a0e8d4874cfcd2b3893c5718779da935 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ clean: ## Update nginx configuration. _reload: - nginx -s reload + @nginx -s reload ## Update nginx configuraion without stopping container. reload: @@ -61,9 +61,8 @@ shell: # params: #- target - proxy destanation adress. Also you can specify container name in memes_network; -#- addr - new address mapping in format ${subdomain}.${domain}. -#- zone - new address zone. Default: 'com'. -## Generate new subdomain configuration in nginx sites-available. with subdomain pointing to target. | parameters: target, subdomain, zone +#- addr - new address mapping in format ${subdomain}.${domain}.${zone} e.g. sub.domain.com. +## Generate new subdomain configuration in nginx sites-available. with subdomain pointing to target. | parameters: target, subdomain add: ifndef addr @echo "${RED}Error${RESET}: please specify ${YELLOW}addr${RESET} variable." @@ -73,43 +72,34 @@ ifndef target @echo "${RED}Error${RESET}: please specify ${YELLOW}target${RESET} variable" exit 1 endif -ifndef zone - $(eval zone="com") -endif - set -e ;\ + @set -e ;\ SUBDOMAIN_VAR=$$(echo "${addr}" | cut -d '.' -f1) ;\ DOMAIN_VAR=$$(echo "${addr}" | cut -d '.' -f2);\ + ZONE_VAR=$$(echo "${addr}" | cut -d '.' -f3);\ + ZONE_VAR="$${ZONE_VAR:-com}";\ + echo "Creating $${SUBDOMAIN_VAR}.$${DOMAIN_VAR} file"; \ cp ./nginx/subdomain_template.conf "./nginx/sites-enabled/$${SUBDOMAIN_VAR}.$${DOMAIN_VAR}.conf";\ sed -i "s/\$${sub_domain}/$${SUBDOMAIN_VAR}/g;"\ "s/\$${main_domain}/$${DOMAIN_VAR}/g;"\ - "s/\$${domain_zone}/${zone}/g;"\ + "s/\$${domain_zone}/$${ZONE_VAR}/g;"\ "s/\$${target_cont}/${target}/" "./nginx/sites-enabled/$${SUBDOMAIN_VAR}.$${DOMAIN_VAR}.conf"; \ docker exec -it ${cont_name} nginx -s reload; if [ $$? -ne 0 ]; then\ echo -e '${RED}Wrong config.${RESET}\n'\ - 'Please make sure that ${YELLOW}target${RESET} and ${YELLOW}subdomain${RESET} parameters was provided and correct.' ;\ + 'Please make sure that ${YELLOW}target${RESET} and ${YELLOW}addr${RESET} parameters was provided and correct.' ;\ rm ./nginx/sites-enabled/$${SUBDOMAIN_VAR}.$${DOMAIN_VAR}.conf ;\ docker exec -it ${cont_name} nginx -s reload;\ fi -tesa: -ifndef addr - $(eval addr="hui.sosi") -endif - set -e ;\ - TMP=$$(echo "${addr}" | cut -d '.' -f1) ;\ - TMP2=$$(echo "${addr}" | cut -d '.' -f2);\ - echo "$${TMP}____$${TMP2}"; - _create_trash: mkdir -p ./trash _move_to_trash: -ifndef subdomain - @echo "${RED}Error${RESET}: please specify ${YELLOW}subdomain${RESET} variable"; +ifndef addr + @echo "${RED}Error${RESET}: please specify ${YELLOW}addr${RESET} variable"; else - mv ./nginx/sites-enabled/$(subdomain).$(domain_name).conf ./trash/ + mv ./nginx/sites-enabled/$(addr).conf ./trash/ endif -## Remove subdomain configuration.| parameters: subdomain +## Remove subdomain configuration.| parameters: addr rm: _create_trash _move_to_trash reload