prepare.sh 4.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/sh
  2. # YOU DON'T NEED TO EDIT THIS FILE. IF YOU WANT TO SET CUSTOM ENVIRONMENT VARIABLES,
  3. # USE THE 'DOCKERFILE IMAGE' FROM ROOT DIRECTORY AND PASS THE ENVIRONMENT PARAMETERS
  4. # This variable changes the behavior of the image builder to remove the base image
  5. export DOCKER_BUILDKIT=1
  6. # These templates will be used to create configuration files that incorporate values from environment variables
  7. # If these locations do not already exist within the Docker container, they will be created
  8. export CONFIG_PHP_TEMPLATE="$(pwd)/scripts/tmp/config.php"
  9. export CONFIG_NGINX_TEMPLATE="$(pwd)/scripts/tmp/nginx.conf"
  10. export CONFIG_OPEN_SEARCH_TEMPLATE="$(pwd)/scripts/tmp/opensearch.xml"
  11. # Configure 'opensearch.xml' with Librex configuration metadata, such as the encoding and the host that stores the site
  12. # These configurations will replace the 'opensearch.xml' inside '.dockers/templates' for the best setup for your instance
  13. export OPEN_SEARCH_TITLE="${OPEN_SEARCH_TITLE:-'LibreX'}"
  14. export OPEN_SEARCH_DESCRIPTION="${OPEN_SEARCH_DESCRIPTION:-'Framework and javascript free privacy respecting meta search engine'}"
  15. export OPEN_SEARCH_ENCODING="${OPEN_SEARCH_ENCODING:-'UTF-8'}"
  16. export OPEN_SEARCH_LONG_NAME="${OPEN_SEARCH_LONG_NAME:-'LibreX Search'}"
  17. export OPEN_SEARCH_HOST="${OPEN_SEARCH_HOST:-'http://localhost:80'}"
  18. # Replace the 'config.php' script, which contains the most common search engine configurations, with these environment setups
  19. # These environment setups can be found in 'config.php', and the default configurations can be useful for most use cases
  20. export CONFIG_GOOGLE_DOMAIN="${CONFIG_GOOGLE_DOMAIN:-'.com'}"
  21. export CONFIG_GOOGLE_LANGUAGUE="${CONFIG_GOOGLE_LANGUAGUE:-'en'}"
  22. export CONFIG_INVIDIOUS_INSTANCE="${CONFIG_INVIDIOUS_INSTANCE:-'invidious.namazso.eu'}"
  23. export CONFIG_HIDDEN_SERVICE_SEARCH=${CONFIG_HIDDEN_SERVICE_SEARCH:-false}
  24. export CONFIG_DISABLE_BITTORRENT_SEARCH=${CONFIG_DISABLE_BITTORRENT_SEARCH:-false}
  25. export CONFIG_BITTORRENT_TRACKERS="${CONFIG_BITTORRENT_TRACKERS:-'&tr=http://nyaa.tracker.wf:7777/announce&tr=udp://open.stealth.si:80/announce&tr=udp://tracker.opentrackr.org:1337/announce&tr=udp://exodus.desync.com:6969/announce&tr=udp://tracker.torrent.eu.org:451/announce'}"
  26. # Supported apps integration configuration. These empty spaces can be set up using free hosts as pointers
  27. # A particular example is using the "https://yewtu.be" or a self-hosted host to integrate the invidious app to librex
  28. export APP_INVIDIOUS="${APP_INVIDIOUS:-''}"
  29. export APP_BIBLIOGRAM="${APP_BIBLIOGRAM:-''}"
  30. export APP_RIMGO="${APP_RIMGO:-''}"
  31. export APP_SCRIBE="${APP_SCRIBE:-''}"
  32. export APP_LIBRARIAN="${APP_LIBRARIAN:-''}"
  33. export APP_GOTHUB="${APP_GOTHUB:-''}"
  34. export APP_NITTER="${APP_NITTER:-''}"
  35. export APP_LIBREREDDIT="${APP_LIBREREDDIT:-''}"
  36. export APP_PROXITOK="${APP_PROXITOK:-''}"
  37. export APP_WIKILESS="${APP_WIKILESS:-''}"
  38. export APP_QUETRE="${APP_QUETRE:-''}"
  39. export APP_LIBREMDB="${APP_LIBREMDB:-''}"
  40. export APP_BREEZEWIKI="${APP_BREEZEWIKI:-''}"
  41. export APP_ANONYMOUS_OVERFLOW="${APP_ANONYMOUS_OVERFLOW:-''}"
  42. # GNU/Curl configurations. Leave 'CURLOPT_PROXY' blank whether you don't need to use a proxy for requests
  43. # Generally, a proxy is needed when your IP address is blocked by search engines in response to multiple requests within a short time frame. In these cases, it is recommended to use rotating proxies
  44. export CURLOPT_PROXY_ENABLED=${CURLOPT_PROXY_ENABLED:-false}
  45. export CURLOPT_PROXY="${CURLOPT_PROXY:-''}"
  46. export CURLOPT_RETURNTRANSFER=${CURLOPT_RETURNTRANSFER:-true}
  47. export CURLOPT_ENCODING="${CURLOPT_ENCODING:-''}"
  48. export CURLOPT_USERAGENT="${CURLOPT_USERAGENT:-'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36'}"
  49. export CURLOPT_CUSTOMREQUEST="${CURLOPT_CUSTOMREQUEST:-'GET'}"
  50. export CURLOPT_MAXREDIRS=${CURLOPT_MAXREDIRS:-5}
  51. export CURLOPT_TIMEOUT=${CURLOPT_TIMEOUT:-18}
  52. export CURLOPT_VERBOSE=${CURLOPT_VERBOSE:-false}
  53. # These shell functions will be available for use by any function calls
  54. function AwkTrim() { awk '{$1=$1};1'; }
  55. # The lines below will replace the environment variables in the templates with the corresponding variables listed above. To accomplish this, the GNU 'envsubst' package will be used
  56. # 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
  57. [[ ! -s ${CONFIG_PHP_TEMPLATE} ]] && cat 'scripts/config.php' | envsubst | AwkTrim > ${CONFIG_PHP_TEMPLATE};
  58. [[ ! -s ${CONFIG_NGINX_TEMPLATE} ]] && cat 'scripts/nginx.conf' | envsubst | AwkTrim > ${CONFIG_NGINX_TEMPLATE};
  59. [[ ! -s ${CONFIG_OPEN_SEARCH_TEMPLATE} ]] && cat 'scripts/opensearch.xml' | envsubst | AwkTrim > ${CONFIG_OPEN_SEARCH_TEMPLATE};