LibreY

- privacy respecting meta search engine
git clone git://git.acid.vegas/LibreY.git
Log | Files | Refs | Archive | README | LICENSE

env-substitution.sh (1560B)

      1 #!/bin/sh
      2 
      3 # Load all environment variables from 'attributes.sh' using the command 'source /path/attributes.sh'
      4 source "docker/attributes.sh"
      5 
      6 # The lines below will replace the environment variables in the templates with the corresponding variables listed above if the config file is not yet provided. To accomplish this, the GNU 'envsubst' package will be used
      7 # Although not recommended (if you do not know what you are doing), you still have the option to add new substitution file templates using any required environment variables
      8 
      9 [[ ! -s ${CONFIG_PHP_TEMPLATE} ]] && cat 'docker/config.php' | envsubst > ${CONFIG_PHP_TEMPLATE};
     10 [[ ! -s ${CONFIG_OPEN_SEARCH_TEMPLATE} ]] && cat 'docker/opensearch.xml' | envsubst > ${CONFIG_OPEN_SEARCH_TEMPLATE};
     11 
     12 export OPEN_SEARCH_HOST_FOR_NGINX="$(echo "${OPEN_SEARCH_HOST}" | cut -d "/" -f 3 | cut -d ":" -f 1)"
     13 if [[ ! -s ${CONFIG_NGINX_TEMPLATE} ]]; then
     14 
     15     cat 'docker/nginx.conf' | envsubst '${OPEN_SEARCH_HOST_FOR_NGINX}' > ${CONFIG_NGINX_TEMPLATE};
     16     mv "docker/fastcgi.conf" /etc/nginx/fastcgi.conf
     17 
     18     chown nginx:nginx "/etc/nginx/fastcgi.conf"
     19     chown nginx:nginx "/etc/nginx/http.d/librey.conf"
     20 
     21 fi
     22 
     23 # If it is empty or proxy is not enabled, we are using sed to delete
     24 # any line that contains the string 'CURLOPT_PROXY' or 'CURLOPT_PROXYTYPE'
     25 # from the file 'config.php' defined on top of 'attributes.sh'
     26 if [[ -z "${CURLOPT_PROXY}" || "${CURLOPT_PROXY_ENABLED}" = false ]]; then
     27     sed -i "/CURLOPT_PROXY/d" ${CONFIG_PHP_TEMPLATE};
     28     sed -i "/CURLOPT_PROXYTYPE/d" ${CONFIG_PHP_TEMPLATE};
     29 fi