From ef9677ef8d089ca5b5ad6e221b8601cc1c5e0c4d Mon Sep 17 00:00:00 2001 From: Cielquan <43916661+Cielquan@users.noreply.github.com> Date: Tue, 10 Dec 2019 18:45:37 +0100 Subject: [PATCH 1/9] added `-F` flag (Fallback) to script --- start_doth_dns.bash | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/start_doth_dns.bash b/start_doth_dns.bash index ba741fb..6bd8033 100755 --- a/start_doth_dns.bash +++ b/start_doth_dns.bash @@ -59,7 +59,7 @@ exit_dc_err() { # Func for showing usage string usage_string() { - printf "\nUsage: %s [-f] [-a ] [-c] [-I ] [-i ] ` + printf "\nUsage: %s [-f] [-F] [-a ] [-c] [-I ] [-i ] ` `[-n ] [-t ] [-d ] [-N] [-R] [-U] [-P] [-D] [-h]\n" "$0" 1>&2; } @@ -79,11 +79,14 @@ help() { # ########################################################################################## # Catching flags -while getopts ":fa:cI:i:n:t:d:NRUPDh" flag; do +while getopts ":fFa:cI:i:n:t:d:NRUPDh" flag; do case ${flag} in f) # Set for overwriting existing configs with new ones. _FLAG_FRESH='y' ;; + F) # Set to let the script fallback to next source for configuration variables. Order: `flag -> .env file -> environment -> self gather` + _FLAG_FALLBACK='y' + ;; a) # Set ARCHITECTURE variable with 'ARM' or 'x86' (case insensitive). if ! [[ "${OPTARG,,}" == 'arm' ]] && ! [[ "${OPTARG,,}" == 'x86' ]]; then printf "No valid argument for '-a'.\n" From 1af7dd0e04881d5e57e7251b93e6a48f60e4033f Mon Sep 17 00:00:00 2001 From: Cielquan <43916661+Cielquan@users.noreply.github.com> Date: Tue, 10 Dec 2019 18:47:02 +0100 Subject: [PATCH 2/9] added dividing line before traefik auth part in script --- start_doth_dns.bash | 2 ++ 1 file changed, 2 insertions(+) diff --git a/start_doth_dns.bash b/start_doth_dns.bash index 6bd8033..ae2bacc 100755 --- a/start_doth_dns.bash +++ b/start_doth_dns.bash @@ -399,6 +399,8 @@ elif [[ -n "${_ENV_DOMAIN}" ]]; then fi fi + +# ########################################################################################## # Set TRAEFIK_AUTH if ! [ -f traefik-docker/shared/.htpasswd ] || [[ "${_FLAG_TRAEFIK_NOAUTH}" == 'y' ]]; then _TRAEFIK_AUTH="NoAuth" From a16a1100db23984838e1b113ceff4f675662ce83 Mon Sep 17 00:00:00 2001 From: Cielquan <43916661+Cielquan@users.noreply.github.com> Date: Tue, 10 Dec 2019 19:52:14 +0100 Subject: [PATCH 3/9] added message categories as variables to script --- start_doth_dns.bash | 198 +++++++++++++++++++++++--------------------- 1 file changed, 102 insertions(+), 96 deletions(-) diff --git a/start_doth_dns.bash b/start_doth_dns.bash index ae2bacc..821014a 100755 --- a/start_doth_dns.bash +++ b/start_doth_dns.bash @@ -27,6 +27,12 @@ ORANGE='\e[0;33m' # For WARNING messages CYAN='\e[0;36m' # For INFO messages BLANK='\e[0m' # For resetting colors +# Message category variables +ERROR="${RED}ERROR: ${BLANK}" +SUCCESS="${GREEN}SUCCESS:${BLANK}" +WARNING="${ORANGE}WARNING:${BLANK}" +INFO="${CYAN}INFO: ${BLANK}" + # ########################################################################################## ### Functions for error exits and help @@ -146,9 +152,9 @@ done # Shutting service down if [[ ${_FLAG_DOWN_ALL} == 'y' ]]; then printf "\n####################\n" - printf "\n%bINFO: %b Shutting DoTH-DNS down.\n\n" "${CYAN}" "${BLANK}" + printf "\n%b Shutting DoTH-DNS down.\n\n" "${INFO}" docker-compose -f docker-compose.yaml -f docker-compose.traefik.yaml down || exit_dc_err - printf "\n\n%bSUCCESS:%b DoTH-DNS shut down.\n" "${GREEN}" "${BLANK}" + printf "\n\n%b DoTH-DNS shut down.\n" "${SUCCESS}" printf "\n####################\n\n" exit 0 fi @@ -157,22 +163,22 @@ fi # ########################################################################################## # Starting line printf "\n####################\n" -printf "\n%bINFO: %b Starting setup for DoTH-DNS.\n\n\n" "${CYAN}" "${BLANK}" +printf "\n%b Starting setup for DoTH-DNS.\n\n\n" "${INFO}" # ########################################################################################## # Load .env file if [[ ${_FLAG_FRESH} == 'y' ]]; then - printf "%bINFO: %b Skipped loading of '.env'.\n\n" "${CYAN}" "${BLANK}" + printf "%b Skipped loading of '.env'.\n\n" "${INFO}" else if [[ -f .env ]]; then if . .env; then - printf "%bINFO: %b .env loaded.\n\n" "${CYAN}" "${BLANK}" + printf "%b .env loaded.\n\n" "${INFO}" else - printf "%bWARNING:%b Failed to load '.env'. Falling back to self gather information.\n\n" "${ORANGE}" "${BLANK}" + printf "%b Failed to load '.env'. Falling back to self gather information.\n\n" "${WARNING}" fi else - printf "%bWARNING:%b No '.env' file found. Falling back to self gather information.\n\n" "${ORANGE}" "${BLANK}" + printf "%b No '.env' file found. Falling back to self gather information.\n\n" "${WARNING}" fi fi @@ -180,7 +186,7 @@ fi # ########################################################################################## # Grabbing EnvVars if [[ ${_FLAG_FRESH} == 'y' ]]; then - printf "%bINFO: %b Skipped loading of Environment Variables.\n\n" "${CYAN}" "${BLANK}" + printf "%b Skipped loading of Environment Variables.\n\n" "${INFO}" else if \ _ENV_ARCHITECTURE=${DOTH_ARCHITECTURE} && @@ -190,10 +196,10 @@ else _ENV_TIMEZONE=${DOTH_TIMEZONE} && _ENV_DOMAIN=${DOTH_DOMAIN} then - printf "%bINFO: %b Environment Variables loaded.\n\n" "${CYAN}" "${BLANK}" + printf "%b Environment Variables loaded.\n\n" "${INFO}" else - printf "%bWARNING:%b No Environment Variables could be loaded. Falling back to self gather information.\n\n" \ - "${ORANGE}" "${BLANK}" + printf "%b No Environment Variables could be loaded. Falling back to self gather information.\n\n" \ + "${WARNING}" fi fi @@ -404,12 +410,12 @@ fi # Set TRAEFIK_AUTH if ! [ -f traefik-docker/shared/.htpasswd ] || [[ "${_FLAG_TRAEFIK_NOAUTH}" == 'y' ]]; then _TRAEFIK_AUTH="NoAuth" - printf "%bINFO: %b Treafik dashboard authorization is set to %bINACTIVE%b.\n" \ - "${CYAN}" "${BLANK}" "${CYAN}" "${BLANK}" + printf "%b Treafik dashboard authorization is set to %bINACTIVE%b.\n" \ + "${INFO}" "${CYAN}" "${BLANK}" else _TRAEFIK_AUTH="Auth" - printf "%bINFO: %b Treafik dashboard authorization is set to %bACTIVE%b.\n" \ - "${CYAN}" "${BLANK}" "${CYAN}" "${BLANK}" + printf "%b Treafik dashboard authorization is set to %bACTIVE%b.\n" \ + "${INFO}" "${CYAN}" "${BLANK}" fi @@ -421,7 +427,7 @@ if printf "%s" "${_ARCHITECTURE}" | grep -iq arm; then elif printf "%s" "${_ARCHITECTURE}" | grep -iq x86; then _UNBOUND_VARIANT="unbound" else - printf "%bERROR: %b Invalid architecture. Only 'ARM' and 'x86' are allowed.\n" "${RED}" "${BLANK}" + printf "%b Invalid architecture. Only 'ARM' and 'x86' are allowed.\n" "${ERROR}" exit_err fi @@ -433,18 +439,18 @@ if [[ "${_FLAG_COMPILE}" == 'y' ]] || VERSION="$(git ls-remote -t --refs https://github.com/m13253/dns-over-https.git | tail -n1 | awk '{print $2}' | sed 's,refs/tags/v,,')" && CUR_DIR="$(pwd)" && - printf "%bINFO: %b Compiling image for 'goofball222/dns-over-https' for version %s.\n" \ - "${CYAN}" "${BLANK}" "${VERSION}." && + printf "%b Compiling image for 'goofball222/dns-over-https' for version %s.\n" \ + "${INFO}" "${VERSION}." && mkdir -p ~/dns-over-https_tmp && cd ~/dns-over-https_tmp && git clone https://github.com/goofball222/dns-over-https.git && cd dns-over-https && printf "%s" "${VERSION}" | tee 'stable/VERSION' > /dev/null && sudo make && cd "${CUR_DIR}" && rm -rf ~/dns-over-https_tmp then - printf "%bSUCCESS:%b Image compiled.\n" "${GREEN}" "${BLANK}" + printf "%b Image compiled.\n" "${SUCCESS}" else - printf "%bERROR: %b Compiling failed. Deleting '~/dns-over-https_tmp' directory.\n" "${RED}" "${BLANK}" + printf "%b Compiling failed. Deleting '~/dns-over-https_tmp' directory.\n" "${ERROR}" rm -rf ~/dns-over-https_tmp || - printf "%bERROR: %b Failed to delete '~/dns-over-https_tmp' directory.\n" "${RED}" "${BLANK}" + printf "%b Failed to delete '~/dns-over-https_tmp' directory.\n" "${ERROR}" exit_err fi fi @@ -452,58 +458,58 @@ fi # ########################################################################################## # Download root.hints file -printf "\n%bINFO: %b Checking for 'root.hints' file.\n" "${CYAN}" "${BLANK}" +printf "\n%b Checking for 'root.hints' file.\n" "${INFO}" if ! [ -f unbound-docker/var/root.hints ]; then if wget -nv https://www.internic.net/domain/named.root -O unbound-docker/var/root.hints; then - printf "%bSUCCESS:%b 'root.hints' file downloaded.\n" "${GREEN}" "${BLANK}" + printf "%b 'root.hints' file downloaded.\n" "${SUCCESS}" else - printf "%bERROR: %b 'root.hints' file download failed.\n" "${RED}" "${BLANK}" + printf "%b 'root.hints' file download failed.\n" "${ERROR}" exit_err fi else (( DIFF = ($(date +%s) - $(stat -c %Z unbound-docker/var/root.hints))/3600 )) if ((DIFF > 1)) || [[ "${_FLAG_FRESH}" == 'y' ]]; then if wget -nv https://www.internic.net/domain/named.root -O unbound-docker/var/root.hints; then - printf "%bSUCCESS:%b 'root.hints' file updated.\n" "${GREEN}" "${BLANK}" + printf "%b 'root.hints' file updated.\n" "${SUCCESS}" else - printf "%bWARNING:%b 'root.hints' file update failed.\n" "${ORANGE}" "${BLANK}" + printf "%b 'root.hints' file update failed.\n" "${WARNING}" fi else - printf "%bSUCCESS:%b 'root.hints' file found.\n" "${GREEN}" "${BLANK}" + printf "%b 'root.hints' file found.\n" "${SUCCESS}" fi fi # ########################################################################################## ### Check encryption file stuff -printf "\n%bINFO: %b Checking for TLS files.\n" "${CYAN}" "${BLANK}" +printf "\n%b Checking for TLS files.\n" "${INFO}" # Check for 'cert.crt' file -printf "%bINFO: %b Checking for cert.crt file.\n" "${CYAN}" "${BLANK}" +printf "%b Checking for cert.crt file.\n" "${INFO}" if [ -f certificates/cert.crt ]; then - printf "%bSUCCESS:%b Found cert.crt file.\n" "${GREEN}" "${BLANK}" + printf "%b Found cert.crt file.\n" "${SUCCESS}" else - printf "%bERROR: %b No 'cert.crt' file found. Please add a 'cert.crt' file to certificates/.` - ` Then restart this script.\n" "${RED}" "${BLANK}" + printf "%b No 'cert.crt' file found. Please add a 'cert.crt' file to certificates/.` + ` Then restart this script.\n" "${ERROR}" exit_err fi # Check for 'key.key' file -printf "%bINFO: %b Checking for key.key file.\n" "${CYAN}" "${BLANK}" +printf "%b Checking for key.key file.\n" "${INFO}" if [ -f certificates/key.key ]; then - printf "%bSUCCESS:%b Found key.key file.\n" "${GREEN}" "${BLANK}" + printf "%b Found key.key file.\n" "${SUCCESS}" else - printf "%bERROR: %b No 'key.key' file found. Please add a 'key.key' file to certificates/.` - ` Then restart this script.\n" "${RED}" "${BLANK}" + printf "%b No 'key.key' file found. Please add a 'key.key' file to certificates/.` + ` Then restart this script.\n" "${ERROR}" exit_err fi # Check for 'dhparam.pem' file -printf "%bINFO: %b Checking for dhparam.pem file.\n" "${CYAN}" "${BLANK}" +printf "%b Checking for dhparam.pem file.\n" "${INFO}" if [ -f certificates/dhparam.pem ]; then - printf "%bSUCCESS:%b Found dhparam.pem file.\n" "${GREEN}" "${BLANK}" + printf "%b Found dhparam.pem file.\n" "${SUCCESS}" else - printf "%bERROR: %b No 'dhparam.pem' file found. Please add a 'dhparam.pem' file to certificates/.` - ` Then restart this script.\n" "${RED}" "${BLANK}" + printf "%b No 'dhparam.pem' file found. Please add a 'dhparam.pem' file to certificates/.` + ` Then restart this script.\n" "${ERROR}" exit_err fi @@ -511,23 +517,23 @@ fi # ########################################################################################## # Creating/Overwriting '.env' file if [ -f .env ]; then - printf "\n%bINFO: %b Overwriting '.env' file.\n" "${CYAN}" "${BLANK}" + printf "\n%b Overwriting '.env' file.\n" "${INFO}" _NEW_ENV='Overwrote' else - printf "\n%bINFO: %b Creating '.env' file.\n" "${CYAN}" "${BLANK}" + printf "\n%b Creating '.env' file.\n" "${INFO}" _NEW_ENV='Created new' fi if printf "HOST_NAME=%s\nDOMAIN=%s\nTIMEZONE=%s\nUNBOUND_VARIANT=%s\nARCHITECTURE=%s\nINTERFACE=%s\nHOST_IP=%s` `\nTRAEFIK_AUTH=%s" "${_HOST_NAME}" "${_DOMAIN}" "${_TIMEZONE}" "${_UNBOUND_VARIANT}" "${_ARCHITECTURE}" \ "${_INTERFACE}" "${_HOST_IP}" "${_TRAEFIK_AUTH}" | tee .env > /dev/null; then - printf "%bSUCCESS:%b ${_NEW_ENV} '.env' file.\n" "${GREEN}" "${BLANK}" + printf "%b ${_NEW_ENV} '.env' file.\n" "${SUCCESS}" else if [ -f .env ]; then - printf "%bERROR: %b Error while creating '.env' file. Data could not be gathered and empty file was created. ` - `Please add necessary settings (ServerIP, DOMAIN and TZ) manually.\n" "${RED}" "${BLANK}" + printf "%b Error while creating '.env' file. Data could not be gathered and empty file was created. ` + `Please add necessary settings (ServerIP, DOMAIN and TZ) manually.\n" "${ERROR}" exit_err else - printf "%bERROR: %b Error while creating '.env' file. The file was not created.\n" "${RED}" "${BLANK}" + printf "%b Error while creating '.env' file. The file was not created.\n" "${ERROR}" exit_err fi fi @@ -535,16 +541,16 @@ fi # ########################################################################################## # Setup finish & run start line -printf "\n\n%bSUCCESS:%b Setup for DoTH-DNS finished.\n" "${GREEN}" "${BLANK}" +printf "\n\n%b Setup for DoTH-DNS finished.\n" "${SUCCESS}" printf "\n####################\n" -printf "\n%bINFO: %b Starting DoTH-DNS.\n\n\n" "${CYAN}" "${BLANK}" +printf "\n%b Starting DoTH-DNS.\n\n\n" "${INFO}" # ########################################################################################## # Different start compositions if [[ "${_FLAG_NO_PROXY}" == 'y' ]]; then if [[ "${_FLAG_UPDATE_ALL}" == 'y' ]]; then - printf "%bINFO: %b Updating DoTH-DNS without reverse proxy.\n" "${CYAN}" "${BLANK}" + printf "%b Updating DoTH-DNS without reverse proxy.\n" "${INFO}" docker-compose down || exit_dc_err if printf "%s" "${_ARCHITECTURE}" | grep -iq arm; then docker-compose pull pihole unbound || exit_dc_err @@ -553,16 +559,16 @@ if [[ "${_FLAG_NO_PROXY}" == 'y' ]]; then fi docker-compose up -d --force-recreate || exit_dc_err elif [[ "${_FLAG_RECREATE_ALL}" == 'y' ]]; then - printf "%bINFO: %b Recreating DoTH-DNS without reverse proxy.\n" "${CYAN}" "${BLANK}" + printf "%b Recreating DoTH-DNS without reverse proxy.\n" "${INFO}" docker-compose up -d --force-recreate || exit_dc_err else - printf "%bINFO: %b Creating DoTH-DNS without reverse proxy.\n" "${CYAN}" "${BLANK}" + printf "%b Creating DoTH-DNS without reverse proxy.\n" "${INFO}" docker-compose up -d || exit_dc_err fi else if [[ "${_FLAG_UPDATE_ALL}" == 'y' ]]; then - printf "%bINFO: %b Updating DoTH-DNS with %btraefik%b reverse proxy.\n" \ - "${CYAN}" "${BLANK}" "${CYAN}" "${BLANK}" + printf "%b Updating DoTH-DNS with %btraefik%b reverse proxy.\n" \ + "${INFO}" "${CYAN}" "${BLANK}" docker-compose -f docker-compose.yaml -f docker-compose.traefik.yaml down || exit_dc_err if printf "%s" "${_ARCHITECTURE}" | grep -iq arm; then docker-compose -f docker-compose.yaml -f docker-compose.traefik.yaml pull pihole unbound traefik || exit_dc_err @@ -571,12 +577,12 @@ else fi docker-compose -f docker-compose.yaml -f docker-compose.traefik.yaml up -d || exit_dc_err elif [[ "${_FLAG_RECREATE_ALL}" == 'y' ]]; then - printf "%bINFO: %b Recreating DoTH-DNS with %btraefik%b reverse proxy.\n" \ - "${CYAN}" "${BLANK}" "${CYAN}" "${BLANK}" + printf "%b Recreating DoTH-DNS with %btraefik%b reverse proxy.\n" \ + "${INFO}" "${CYAN}" "${BLANK}" docker-compose -f docker-compose.yaml -f docker-compose.traefik.yaml up -d --force-recreate || exit_dc_err else - printf "%bINFO: %b Creating DoTH-DNS with %btraefik%b reverse proxy.\n" \ - "${CYAN}" "${BLANK}" "${CYAN}" "${BLANK}" + printf "%b Creating DoTH-DNS with %btraefik%b reverse proxy.\n" \ + "${INFO}" "${CYAN}" "${BLANK}" docker-compose -f docker-compose.yaml -f docker-compose.traefik.yaml up -d || exit_dc_err fi fi @@ -585,7 +591,7 @@ fi # ########################################################################################## ### Testing unbound-docker # Check if container started and works; timeout after 1 min -printf "\n%bINFO: %b Starting up unbound container " "${CYAN}" "${BLANK}" +printf "\n%b Starting up unbound container " "${INFO}" for i in $(seq 1 20); do if [ "$(docker inspect -f "{{.State.Health.Status}}" unbound)" == "healthy" ]; then printf " %bOK%b\n" "${GREEN}" "${BLANK}" @@ -597,15 +603,15 @@ for i in $(seq 1 20); do if [ "$i" -eq 20 ]; then printf " %bFAILED%b\n" "${RED}" "${BLANK}" - printf "%bERROR: %b Timed out waiting for unbound to start, check your container logs for more info ` - `(\`docker logs unbound\`).\n" "${RED}" "${BLANK}" - printf "%bINFO: %b Container health status of 'unbound': ` - `%b$(docker inspect -f "{{.State.Health.Status}}" unbound)%b\n" "${CYAN}" "${BLANK}" "${CYAN}" "${BLANK}" + printf "%b Timed out waiting for unbound to start, check your container logs for more info ` + `(\`docker logs unbound\`).\n" "${ERROR}" + printf "%b Container health status of 'unbound': ` + `%b$(docker inspect -f "{{.State.Health.Status}}" unbound)%b\n" "${INFO}" "${CYAN}" "${BLANK}" exit_err fi done; -printf "%bINFO: %b Container health status of 'unbound': ` - `%b$(docker inspect -f "{{.State.Health.Status}}" unbound)%b\n" "${CYAN}" "${BLANK}" "${CYAN}" "${BLANK}" +printf "%b Container health status of 'unbound': ` + `%b$(docker inspect -f "{{.State.Health.Status}}" unbound)%b\n" "${INFO}" "${CYAN}" "${BLANK}" # Test DNSSEC - The first command should give a status report of SERVFAIL and no IP address. # The second should give NOERROR plus an IP address. @@ -615,28 +621,28 @@ if [ "$(echo "$TEST" | sed '/SERVER:/d' | grep -cE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9 TEST=$(docker exec unbound drill sigok.verteiltesysteme.net @127.0.0.1 -p 53) if [ "$(echo "$TEST" | sed '/SERVER:/d' | grep -cE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')" = 1 ] && [ "$(echo "$TEST" | grep -c 'rcode: NOERROR')" = 1 ]; then - printf "%bSUCCESS:%b DNSSEC works.\n" "${GREEN}" "${BLANK}" + printf "%b DNSSEC works.\n" "${SUCCESS}" else - printf "%bWARNING:%b DNSSEC fail with second check (positiv check).\n" "${ORANGE}" "${BLANK}" + printf "%b DNSSEC fail with second check (positiv check).\n" "${WARNING}" fi else - printf "%bWARNING:%b DNSSEC fail with first check (negativ check).\n" "${ORANGE}" "${BLANK}" + printf "%b DNSSEC fail with first check (negativ check).\n" "${WARNING}" fi # ########################################################################################## ### Testing pihole-docker # Check if container started and works; timeout after 1 min -printf "\n%bINFO: %b Starting up pihole container " "${CYAN}" "${BLANK}" +printf "\n%b Starting up pihole container " "${INFO}" for i in $(seq 1 20); do if [ "$(docker inspect -f "{{.State.Health.Status}}" pihole)" == "healthy" ]; then printf " %bOK%b\n" "${GREEN}" "${BLANK}" if [ "$(docker logs pihole 2> /dev/null | grep -c 'Setting password:')" -gt 0 ]; then - printf "%bINFO: %b $(docker logs pihole 2> /dev/null | - grep 'Setting password:') for your pi-hole: https://pi.hole/admin/.\n" "${CYAN}" "${BLANK}" + printf "%b $(docker logs pihole 2> /dev/null | + grep 'Setting password:') for your pi-hole: https://pi.hole/admin/.\n" "${INFO}" RAN_PW='y' else - printf "%bINFO: %b Set given WEBPASSWORD for your pi-hole: https://pi.hole/admin/.\n" "${CYAN}" "${BLANK}" + printf "%b Set given WEBPASSWORD for your pi-hole: https://pi.hole/admin/.\n" "${INFO}" RAN_PW='n' fi break @@ -647,22 +653,22 @@ for i in $(seq 1 20); do if [ "$i" -eq 20 ]; then printf " %bFAILED%b\n" "${RED}" "${BLANK}" - printf "%bERROR: %b Timed out waiting for Pi-hole to start, check your container logs for more info ` - `(\`docker logs pihole\`).\n" "${RED}" "${BLANK}" - printf "%bINFO: %b Container health status of 'pihole': ` - `%b$(docker inspect -f "{{.State.Health.Status}}" pihole)%b\n" "${CYAN}" "${BLANK}" "${CYAN}" "${BLANK}" + printf "%b Timed out waiting for Pi-hole to start, check your container logs for more info ` + `(\`docker logs pihole\`).\n" "${ERROR}" + printf "%b Container health status of 'pihole': ` + `%b$(docker inspect -f "{{.State.Health.Status}}" pihole)%b\n" "${INFO}" "${CYAN}" "${BLANK}" exit_err fi done; -printf "%bINFO: %b Container health status of 'pihole': ` - `%b$(docker inspect -f "{{.State.Health.Status}}" pihole)%b\n" "${CYAN}" "${BLANK}" "${CYAN}" "${BLANK}" +printf "%b Container health status of 'pihole': ` + `%b$(docker inspect -f "{{.State.Health.Status}}" pihole)%b\n" "${INFO}" "${CYAN}" "${BLANK}" # Check if blocklist setup is finished and when then restore custom conf; timeout after 10 min -printf "%bINFO: %b Waiting for blocklist setup to finish " "${CYAN}" "${BLANK}" +printf "%b Waiting for blocklist setup to finish " "${INFO}" for i in $(seq 1 60); do if [ "$(docker logs pihole 2> /dev/null | grep -c "\[services.d\] done.")" -gt 0 ]; then printf " %bOK%b\n" "${GREEN}" "${BLANK}" - printf "%bSUCCESS:%b Blocklist setup finished.\n" "${GREEN}" "${BLANK}" + printf "%b Blocklist setup finished.\n" "${SUCCESS}" break else sleep 10 @@ -671,8 +677,8 @@ for i in $(seq 1 60); do if [ "$i" -eq 60 ]; then printf " %bFAILED%b\n" "${RED}" "${BLANK}" - printf "%bERROR: %b Timed out waiting for blocklists to set up, check your container logs for more info ` - `(\`docker logs pihole\`).\n" "${RED}" "${BLANK}" + printf "%b Timed out waiting for blocklists to set up, check your container logs for more info ` + `(\`docker logs pihole\`).\n" "${ERROR}" exit_err fi done; @@ -681,7 +687,7 @@ done; # ########################################################################################## ### Testing doh_server-docker # Check if container started and is running; timeout after 1 min -printf "\n%bINFO: %b Starting up doh_server container " "${CYAN}" "${BLANK}" +printf "\n%b Starting up doh_server container " "${INFO}" for i in $(seq 1 20); do if [ "$(docker inspect -f "{{.State.Status}}" doh_server)" == "running" ]; then if [ "$(docker inspect -f "{{.State.Status}}" doh_server)" == "running" ]; then @@ -696,22 +702,22 @@ for i in $(seq 1 20); do if [ "$i" -eq 20 ]; then printf " %bFAILED%b\n" "${RED}" "${BLANK}" - printf "%bERROR: %b Timed out waiting for doh_server to start, check your container logs for more info ` - `(\`docker logs doh_server\`).\n" "${RED}" "${BLANK}" - printf "%bINFO: %b Container health status of 'doh_server': ` - `%b$(docker inspect -f "{{.State.Status}}" doh_server)%b\n" "${CYAN}" "${BLANK}" "${CYAN}" "${BLANK}" + printf "%b Timed out waiting for doh_server to start, check your container logs for more info ` + `(\`docker logs doh_server\`).\n" "${ERROR}" + printf "%b Container health status of 'doh_server': ` + `%b$(docker inspect -f "{{.State.Status}}" doh_server)%b\n" "${INFO}" "${CYAN}" "${BLANK}" exit_err fi done; -printf "%bINFO: %b Container health status of 'doh_server': ` - `%b$(docker inspect -f "{{.State.Status}}" doh_server)%b\n" "${CYAN}" "${BLANK}" "${CYAN}" "${BLANK}" +printf "%b Container health status of 'doh_server': ` + `%b$(docker inspect -f "{{.State.Status}}" doh_server)%b\n" "${INFO}" "${CYAN}" "${BLANK}" # ########################################################################################## ### Testing traefik-docker if ! [[ "${_FLAG_NO_PROXY}" == 'y' ]]; then # Check if container started and is running; timeout after 1 min - printf "\n%bINFO: %b Starting up traefik container " "${CYAN}" "${BLANK}" + printf "\n%b Starting up traefik container " "${INFO}" for i in $(seq 1 20); do if [ "$(docker inspect -f "{{.State.Status}}" traefik)" == "running" ]; then if [ "$(docker inspect -f "{{.State.Status}}" traefik)" == "running" ]; then @@ -726,20 +732,20 @@ if ! [[ "${_FLAG_NO_PROXY}" == 'y' ]]; then if [ "$i" -eq 20 ]; then printf " %bFAILED%b\n" "${RED}" "${BLANK}" - printf "%bERROR: %b Timed out waiting for traefik to start, check your container logs for more info ` - `(\`docker logs traefik\`).\n" "${RED}" "${BLANK}" - printf "%bINFO: %b Container health status of 'traefik': ` - `%b$(docker inspect -f "{{.State.Status}}" traefik)%b\n" "${CYAN}" "${BLANK}" "${CYAN}" "${BLANK}" + printf "%b Timed out waiting for traefik to start, check your container logs for more info ` + `(\`docker logs traefik\`).\n" "${ERROR}" + printf "%b Container health status of 'traefik': ` + `%b$(docker inspect -f "{{.State.Status}}" traefik)%b\n" "${INFO}" "${CYAN}" "${BLANK}" exit_err fi done; - printf "%bINFO: %b Container health status of 'traefik': ` - `%b$(docker inspect -f "{{.State.Status}}" traefik)%b\n" "${CYAN}" "${BLANK}" "${CYAN}" "${BLANK}" + printf "%b Container health status of 'traefik': ` + `%b$(docker inspect -f "{{.State.Status}}" traefik)%b\n" "${INFO}" "${CYAN}" "${BLANK}" fi # ########################################################################################## # Finishing line -printf "\n\n%bSUCCESS:%b DoTH-DNS is up and running.\n" "${GREEN}" "${BLANK}" +printf "\n\n%b DoTH-DNS is up and running.\n" "${SUCCESS}" printf "\n####################\n\n" From f10c5d0cab717a9f400978bc21ea95f891527233 Mon Sep 17 00:00:00 2001 From: Cielquan <43916661+Cielquan@users.noreply.github.com> Date: Tue, 10 Dec 2019 21:20:36 +0100 Subject: [PATCH 4/9] added newline in front of traefik auth messages in script --- start_doth_dns.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/start_doth_dns.bash b/start_doth_dns.bash index 821014a..3d5cef6 100755 --- a/start_doth_dns.bash +++ b/start_doth_dns.bash @@ -410,11 +410,11 @@ fi # Set TRAEFIK_AUTH if ! [ -f traefik-docker/shared/.htpasswd ] || [[ "${_FLAG_TRAEFIK_NOAUTH}" == 'y' ]]; then _TRAEFIK_AUTH="NoAuth" - printf "%b Treafik dashboard authorization is set to %bINACTIVE%b.\n" \ + printf "\n%b Treafik dashboard authorization is set to %bINACTIVE%b.\n" \ "${INFO}" "${CYAN}" "${BLANK}" else _TRAEFIK_AUTH="Auth" - printf "%b Treafik dashboard authorization is set to %bACTIVE%b.\n" \ + printf "\n%b Treafik dashboard authorization is set to %bACTIVE%b.\n" \ "${INFO}" "${CYAN}" "${BLANK}" fi From 30a33776a36d2fc44465710c8335958248b1ad37 Mon Sep 17 00:00:00 2001 From: Cielquan <43916661+Cielquan@users.noreply.github.com> Date: Tue, 10 Dec 2019 21:27:41 +0100 Subject: [PATCH 5/9] overhauled gathering config vars to loop & include fallback mechanism --- start_doth_dns.bash | 274 ++++++++++++++------------------------------ 1 file changed, 83 insertions(+), 191 deletions(-) diff --git a/start_doth_dns.bash b/start_doth_dns.bash index 3d5cef6..837542b 100755 --- a/start_doth_dns.bash +++ b/start_doth_dns.bash @@ -206,204 +206,96 @@ fi # ########################################################################################## ### Check and set ENV Vars -# Set ARCHITECTURE -if [[ -n "${_FLAG_ARCHITECTURE}" ]]; then - if _ARCHITECTURE="${_FLAG_ARCHITECTURE}"; then - printf "%bINFO: %b ARCHITECTURE set by CLI argument to '%s'.\n" "${CYAN}" "${BLANK}" "${_ARCHITECTURE}" - else - printf "%bERROR: %b Failed to set ARCHITECTURE by CLI argument.\n" "${RED}" "${BLANK}" - exit_err - fi -elif [[ -n "${ARCHITECTURE}" ]]; then - if _ARCHITECTURE="${ARCHITECTURE}"; then - printf "%bINFO: %b ARCHITECTURE set by .env file to '%s'.\n" "${CYAN}" "${BLANK}" "${_ARCHITECTURE}" - else - printf "%bERROR: %b Failed to set ARCHITECTURE by .env file.\n" "${RED}" "${BLANK}" - exit_err - fi -elif [[ -n "${_ENV_ARCHITECTURE}" ]]; then - if _ARCHITECTURE="${_ENV_ARCHITECTURE}"; then - printf "%bINFO: %b ARCHITECTURE set by Environment Variable to '%s'.\n" "${CYAN}" "${BLANK}" "${_ARCHITECTURE}" - else - printf "%bERROR: %b Failed to set ARCHITECTURE by Environment Variable.\n" "${RED}" "${BLANK}" - exit_err - fi - if [[ -n "${_ARCHITECTURE}" ]]; then - if _ARCHITECTURE=$(lscpu | grep Architecture: | awk '{print $2}'); then - printf "%bINFO: %b ARCHITECTURE was determined and set to '%s'.\n" "${CYAN}" "${BLANK}" "${_ARCHITECTURE}" - else - printf "%bERROR: %b ARCHITECTURE was not set and could not be determined. ` - `Please set ARCHITECTURE in '.env' file or via '-a' flag.\n" "${RED}" "${BLANK}" - exit_err - fi - fi -fi - -# Set INTERFACE -if [[ -n "${_FLAG_INTERFACE}" ]]; then - if _INTERFACE="${_FLAG_INTERFACE}"; then - printf "%bINFO: %b INTERFACE set by CLI argument to '%s'.\n" "${CYAN}" "${BLANK}" "${_INTERFACE}" - else - printf "%bERROR: %b Failed to set INTERFACE by CLI argument.\n" "${RED}" "${BLANK}" - exit_err - fi -elif [[ -n "${INTERFACE}" ]]; then - if _INTERFACE="${INTERFACE}"; then - printf "%bINFO: %b INTERFACE set by .env file to '%s'.\n" "${CYAN}" "${BLANK}" "${_INTERFACE}" - else - printf "%bERROR: %b Failed to set INTERFACE by .env file.\n" "${RED}" "${BLANK}" - exit_err - fi -elif [[ -n "${_ENV_INTERFACE}" ]]; then - if _INTERFACE="${_ENV_INTERFACE}"; then - printf "%bINFO: %b INTERFACE set by Environment Variable to '%s'.\n" "${CYAN}" "${BLANK}" "${_INTERFACE}" - else - printf "%bERROR: %b Failed to set INTERFACE by Environment Variable.\n" "${RED}" "${BLANK}" - exit_err - fi - if [[ -n "${_INTERFACE}" ]]; then - if _INTERFACE=$(route | grep '^default' | grep -o '[^ ]*$'); then - printf "%bINFO: %b INTERFACE was determined and set to '%s'.\n" "${CYAN}" "${BLANK}" "${_INTERFACE}" - else - printf "%bERROR: %b INTERFACE was not set and could not be determined. ` - `Please set INTERFACE in '.env' file or via '-a' flag.\n" "${RED}" "${BLANK}" - exit_err - fi - fi -fi - -# Set HOST_IP for given INTERFACE -if [[ -n "${_FLAG_HOST_IP}" ]]; then - if _HOST_IP="${_FLAG_HOST_IP}"; then - printf "%bINFO: %b HOST_IP set by CLI argument to '%s'.\n" "${CYAN}" "${BLANK}" "${_HOST_IP}" - else - printf "%bERROR: %b Failed to set HOST_IP by CLI argument.\n" "${RED}" "${BLANK}" - exit_err - fi -elif [[ -n "${HOST_IP}" ]]; then - if _HOST_IP="${HOST_IP}"; then - printf "%bINFO: %b HOST_IP set by .env file to '%s'.\n" "${CYAN}" "${BLANK}" "${_HOST_IP}" - else - printf "%bERROR: %b Failed to set HOST_IP by .env file.\n" "${RED}" "${BLANK}" - exit_err - fi -elif [[ -n "${_ENV_HOST_IP}" ]]; then - if _HOST_IP="${_ENV_HOST_IP}"; then - printf "%bINFO: %b HOST_IP set by Environment Variable to '%s'.\n" "${CYAN}" "${BLANK}" "${_HOST_IP}" - else - printf "%bERROR: %b Failed to set HOST_IP by Environment Variable.\n" "${RED}" "${BLANK}" - exit_err - fi - if [[ -n "${_HOST_IP}" ]]; then - if _HOST_IP=$(ifconfig "${_INTERFACE}" | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'); then - printf "%bINFO: %b HOST_IP was determined and set to '%s'.\n" "${CYAN}" "${BLANK}" "${_HOST_IP}" - else - printf "%bERROR: %b HOST_IP was not set and could not be determined. ` - `Please set HOST_IP in '.env' file or via '-a' flag.\n" "${RED}" "${BLANK}" - exit_err - fi - fi -fi - - -# Set HOSTNAME -if [[ -n "${_FLAG_HOST_NAME}" ]]; then - if _HOST_NAME="${_FLAG_HOST_NAME}"; then - printf "%bINFO: %b HOST_NAME set by CLI argument to '%s'.\n" "${CYAN}" "${BLANK}" "${_HOST_NAME}" - else - printf "%bERROR: %b Failed to set HOST_NAME by CLI argument.\n" "${RED}" "${BLANK}" - exit_err - fi -elif [[ -n "${HOST_NAME}" ]]; then - if _HOST_NAME="${HOST_NAME}"; then - printf "%bINFO: %b HOST_NAME set by .env file to '%s'.\n" "${CYAN}" "${BLANK}" "${_HOST_NAME}" - else - printf "%bERROR: %b Failed to set HOST_NAME by .env file.\n" "${RED}" "${BLANK}" - exit_err - fi -elif [[ -n "${_ENV_HOST_NAME}" ]]; then - if _HOST_NAME="${_ENV_HOST_NAME}"; then - printf "%bINFO: %b HOST_NAME set by Environment Variable to '%s'.\n" "${CYAN}" "${BLANK}" "${_HOST_NAME}" - else - printf "%bERROR: %b Failed to set HOST_NAME by Environment Variable.\n" "${RED}" "${BLANK}" - exit_err - fi - if [[ -n "${_HOST_NAME}" ]]; then - if _HOST_NAME=$(hostname); then - printf "%bINFO: %b HOST_NAME was determined and set to '%s'.\n" "${CYAN}" "${BLANK}" "${_HOST_NAME}" - else - printf "%bERROR: %b HOST_NAME was not set and could not be determined. ` - `Please set HOST_NAME in '.env' file or via '-a' flag.\n" "${RED}" "${BLANK}" - exit_err +# Put config vars and sources into arrays +_CONF_VARS=(ARCHITECTURE INTERFACE HOST_IP HOST_NAME TIMEZONE DOMAIN) +_CONF_SOURCES=(FLAG ENV DOT_ENV) + +# Loop trough config vars +for _CONF_VAR in "${_CONF_VARS[@]}"; do + + # Set loop variable + _CONF_VAR_UC="_$_CONF_VAR" + _FALLBACK_START="" + + # Loop trough sources + for _CONF_SOURCE in "${_CONF_SOURCES[@]}"; do + + # Set variables according to source + case ${_CONF_SOURCE} in + FLAG) + _CONF_SOURCE_VAR="_FLAG_$_CONF_VAR" + _CONF_SOURCE_MESSAGE="'CLI argument'" + ;; + ENV) + _CONF_SOURCE_VAR="_ENV_$_CONF_VAR" + _CONF_SOURCE_MESSAGE="'Environment Variable'" + ;; + DOT_ENV) + _CONF_SOURCE_VAR="$_CONF_VAR" + _CONF_SOURCE_MESSAGE="'.env file'" + ;; + esac + + # Gather config from source + if [[ -z "${!_CONF_VAR_UC}" ]]; then + if [[ -n "${!_CONF_SOURCE_VAR}" ]]; then + if eval "${_CONF_VAR_UC}"='${!_CONF_SOURCE_VAR}'; then + printf "%b %s set to '%s' by %s.\n" "${INFO}" "${_CONF_VAR}" "${!_CONF_VAR_UC}" \ + "${_CONF_SOURCE_MESSAGE}" + else + if [[ "${_FLAG_FALLBACK}" == 'y' ]]; then + _FALLBACK_START="y" + printf "%b Failed to set %s by %s. Falling back to next source.\n" "${WARNING}" \ + "${_CONF_VAR}" "${_CONF_SOURCE_MESSAGE}" + else + printf "%b Failed to set %s by %s. Fallback to other sources is deactivated.\n" "${ERROR}" \ + "${_CONF_VAR}" "${_CONF_SOURCE_MESSAGE}" + exit_err + fi + fi + elif [[ "${_FALLBACK_START}" == 'y' ]]; then + printf "%b Failed to set %s by %s because not set. Falling back to next source.\n" \ + "${WARNING}" "${_CONF_VAR}" "${_CONF_SOURCE_MESSAGE}" + fi fi - fi -fi -# Set TIMEZONE -if [[ -n "${_FLAG_TIMEZONE}" ]]; then - if _TIMEZONE="${_FLAG_TIMEZONE}"; then - printf "%bINFO: %b TIMEZONE set by CLI argument to '%s'.\n" "${CYAN}" "${BLANK}" "${_TIMEZONE}" - else - printf "%bERROR: %b Failed to set TIMEZONE by CLI argument.\n" "${RED}" "${BLANK}" - exit_err - fi -elif [[ -n "${TIMEZONE}" ]]; then - if _TIMEZONE="${TIMEZONE}"; then - printf "%bINFO: %b TIMEZONE set by .env file to '%s'.\n" "${CYAN}" "${BLANK}" "${_TIMEZONE}" - else - printf "%bERROR: %b Failed to set TIMEZONE by .env file.\n" "${RED}" "${BLANK}" - exit_err - fi -elif [[ -n "${_ENV_TIMEZONE}" ]]; then - if _TIMEZONE="${_ENV_TIMEZONE}"; then - printf "%bINFO: %b TIMEZONE set by Environment Variable to '%s'.\n" "${CYAN}" "${BLANK}" "${_TIMEZONE}" - else - printf "%bERROR: %b Failed to set TIMEZONE by Environment Variable.\n" "${RED}" "${BLANK}" - exit_err - fi - if [[ -n "${_TIMEZONE}" ]]; then - if _TIMEZONE=$(timedatectl | grep 'Time zone' | awk '{print $3}'); then - printf "%bINFO: %b TIMEZONE was determined and set to '%s'.\n" "${CYAN}" "${BLANK}" "${_TIMEZONE}" + done + + # Self gather config via command + if [[ -z "${!_CONF_VAR_UC}" ]]; then + case "${_CONF_VAR}" in + ARCHITECTURE) + _ARCHITECTURE=$(lscpu | grep Architecture: | awk '{print $2}') + ;; + INTERFACE) + _INTERFACE=$(route | grep '^default' | grep -o '[^ ]*$') + ;; + HOST_IP) + _HOST_IP=$(ifconfig "${_INTERFACE}" | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p') + ;; + HOST_NAME) + _HOST_NAME=$(hostname) + ;; + TIMEZONE) + _TIMEZONE=$(timedatectl | grep 'Time zone' | awk '{print $3}') + ;; + DOMAIN) + _DOMAIN="${_HOST_NAME}".dns + ;; + esac + + if [[ -n "${!_CONF_VAR_UC}" ]]; then + printf "%b %s set to '%s' by determining from system.\n" "${INFO}" "${_CONF_VAR}" \ + "${!_CONF_VAR_UC}" else - printf "%bERROR: %b TIMEZONE was not set and could not be determined. ` - `Please set TIMEZONE in '.env' file or via '-a' flag.\n" "${RED}" "${BLANK}" + printf "%b %s was not set and could not be determined. ` + `Please set %s via '-a' flag, in the shell environment or in '.env' file.\n" "${ERROR}" \ + "${_CONF_VAR}" "${_CONF_VAR}" exit_err fi fi -fi -# Set DOMAIN or create with HOSTNAME -if [[ -n "${_FLAG_DOMAIN}" ]]; then - if _DOMAIN="${_FLAG_DOMAIN}"; then - printf "%bINFO: %b DOMAIN set by CLI argument to '%s'.\n" "${CYAN}" "${BLANK}" "${_DOMAIN}" - else - printf "%bERROR: %b Failed to set DOMAIN by CLI argument.\n" "${RED}" "${BLANK}" - exit_err - fi -elif [[ -n "${DOMAIN}" ]]; then - if _DOMAIN="${DOMAIN}"; then - printf "%bINFO: %b DOMAIN set by .env file to '%s'.\n" "${CYAN}" "${BLANK}" "${_DOMAIN}" - else - printf "%bERROR: %b Failed to set DOMAIN by .env file.\n" "${RED}" "${BLANK}" - exit_err - fi -elif [[ -n "${_ENV_DOMAIN}" ]]; then - if _DOMAIN="${_ENV_DOMAIN}"; then - printf "%bINFO: %b DOMAIN set by Environment Variable to '%s'.\n" "${CYAN}" "${BLANK}" "${_DOMAIN}" - else - printf "%bERROR: %b Failed to set DOMAIN by Environment Variable.\n" "${RED}" "${BLANK}" - exit_err - fi - if [[ -n "${_DOMAIN}" ]]; then - if _DOMAIN="${_HOST_NAME}.dns"; then - printf "%bINFO: %b DOMAIN was determined and set to '%s'.\n" "${CYAN}" "${BLANK}" "${_DOMAIN}" - else - printf "%bERROR: %b DOMAIN was not set and could not be created. ` - `Please set DOMAIN in '.env' file or via '-a' flag.\n" "${RED}" "${BLANK}" - exit_err - fi - fi -fi +done # ########################################################################################## From e1d8b57cccaa3f5432bcc26908f59e4c013d0f6e Mon Sep 17 00:00:00 2001 From: Cielquan <43916661+Cielquan@users.noreply.github.com> Date: Tue, 10 Dec 2019 21:28:30 +0100 Subject: [PATCH 6/9] added `shellcheck disable=SC2034` comment to vars now being called indirectly in script --- start_doth_dns.bash | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/start_doth_dns.bash b/start_doth_dns.bash index 837542b..fc283ad 100755 --- a/start_doth_dns.bash +++ b/start_doth_dns.bash @@ -98,24 +98,30 @@ while getopts ":fFa:cI:i:n:t:d:NRUPDh" flag; do printf "No valid argument for '-a'.\n" exit_arg_err fi + # shellcheck disable=SC2034 # Variable(s) is/are referenced indirectly _FLAG_ARCHITECTURE=${OPTARG,,} ;; c) # Set for force compiling the 'goofball222/dns-over-https' docker image. _FLAG_COMPILE='y' ;; I) # Set INTERFACE variable with . E.g. eth0 + # shellcheck disable=SC2034 # Variable(s) is/are referenced indirectly _FLAG_INTERFACE=${OPTARG} ;; i) # Set HOST_IP variable with . E.g. 192.168.0.2 + # shellcheck disable=SC2034 # Variable(s) is/are referenced indirectly _FLAG_HOST_IP=${OPTARG} ;; n) # Set HOST_NAME variable with . E.g. raspberry + # shellcheck disable=SC2034 # Variable(s) is/are referenced indirectly _FLAG_HOST_NAME=${OPTARG} ;; t) # Set TIMEZONE variable with . Format e.g. Europe/London + # shellcheck disable=SC2034 # Variable(s) is/are referenced indirectly _FLAG_TIMEZONE=${OPTARG} ;; d) # Set DOMAIN variable with . E.g. example.com + # shellcheck disable=SC2034 # Variable(s) is/are referenced indirectly _FLAG_DOMAIN=${OPTARG} ;; N) # Deactivate traefik dashboard authorization @@ -188,6 +194,7 @@ fi if [[ ${_FLAG_FRESH} == 'y' ]]; then printf "%b Skipped loading of Environment Variables.\n\n" "${INFO}" else + # shellcheck disable=SC2034 # Variable(s) is/are referenced indirectly if \ _ENV_ARCHITECTURE=${DOTH_ARCHITECTURE} && _ENV_INTERFACE=${DOTH_INTERFACE} && From e6ca2fad51543928113ee805200532444efb8b62 Mon Sep 17 00:00:00 2001 From: Christian Riedel <43916661+Cielquan@users.noreply.github.com> Date: Wed, 11 Dec 2019 08:02:02 +0100 Subject: [PATCH 7/9] fixed order in comment for `-F` flag --- start_doth_dns.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start_doth_dns.bash b/start_doth_dns.bash index fc283ad..603826e 100755 --- a/start_doth_dns.bash +++ b/start_doth_dns.bash @@ -90,7 +90,7 @@ while getopts ":fFa:cI:i:n:t:d:NRUPDh" flag; do f) # Set for overwriting existing configs with new ones. _FLAG_FRESH='y' ;; - F) # Set to let the script fallback to next source for configuration variables. Order: `flag -> .env file -> environment -> self gather` + F) # Set to let the script fallback to next source for configuration variables. Order: `flag -> environment -> .env file -> self gather` _FLAG_FALLBACK='y' ;; a) # Set ARCHITECTURE variable with 'ARM' or 'x86' (case insensitive). From 359eed77a263d1d0efd82444f1d33aaaf5ad05cd Mon Sep 17 00:00:00 2001 From: Christian Riedel <43916661+Cielquan@users.noreply.github.com> Date: Wed, 11 Dec 2019 08:02:31 +0100 Subject: [PATCH 8/9] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 40500df..4125685 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,8 @@ Here is an overview of the available flags for setup when calling the script. Ru * `-f`): If set then old configuration settings saved in `.env` file will not be loaded and a new `root.hints` file will be downloaded. +* `-F`): Set to let the script fallback to next source for configuration variables. Order: `flag -> environment -> .env file -> self gather` + * `-a`): Set Architecture of the processor ('arm' or 'x86') used by the server. Needed for determining the right docker images. If not set script will determine it. * `-c`): Set to force `goofball222/dns-over-https` docker image to be compiled. If not set then the `ARCHITECTURE` determines if the image will be compiled From dfac3f9f4b9134f2ffc674a4129b00548f843c40 Mon Sep 17 00:00:00 2001 From: Christian Riedel <43916661+Cielquan@users.noreply.github.com> Date: Wed, 11 Dec 2019 08:03:08 +0100 Subject: [PATCH 9/9] Update CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 650d530..1118743 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # DoTH DNS Change Log +**Release 5.3.0** - 11.12.2019 +- Reworked config gathering in script and added fallback mechanism ([commit](https://github.com/Cielquan/DoTH-DNS/commit/30a33776a36d2fc44465710c8335958248b1ad37)) +- Added `-F` flag for fallback option ([commit](https://github.com/Cielquan/DoTH-DNS/commit/ef9677ef8d089ca5b5ad6e221b8601cc1c5e0c4d)) +- Minor code improvements in script +- Updated README ([commit](https://github.com/Cielquan/DoTH-DNS/commit/359eed77a263d1d0efd82444f1d33aaaf5ad05cd)) + **Release 5.2.1** - 30.11.2019 - Added missing hint for `whiptail` in README ([commit](https://github.com/Cielquan/DoTH-DNS/commit/f389e3ab123a64066b67acaf2a33c6a80bf1c139))