lxc-searx.env 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # -*- coding: utf-8; mode: sh indent-tabs-mode: nil -*-
  2. # SPDX-License-Identifier: AGPL-3.0-or-later
  3. # shellcheck shell=bash
  4. # This file is a setup of a LXC suite. It is sourced from different context, do
  5. # not manipulate the environment directly, implement functions and manipulate
  6. # environment only is subshells!
  7. # ----------------------------------------------------------------------------
  8. # config
  9. # ----------------------------------------------------------------------------
  10. # shellcheck disable=SC2034
  11. LXC_SUITE_NAME="searx"
  12. lxc_set_suite_env() {
  13. # name of https://images.linuxcontainers.org
  14. export LINUXCONTAINERS_ORG_NAME="${LINUXCONTAINERS_ORG_NAME:-images}"
  15. export LXC_HOST_PREFIX="${LXC_SUITE_NAME:-searx}"
  16. export LXC_SUITE=(
  17. # to disable containers, comment out lines ..
  18. # end of standard support see https://wiki.ubuntu.com/Releases
  19. "$LINUXCONTAINERS_ORG_NAME:ubuntu/16.04" "ubu1604" # April 2021
  20. "$LINUXCONTAINERS_ORG_NAME:ubuntu/18.04" "ubu1804" # April 2023
  21. "$LINUXCONTAINERS_ORG_NAME:ubuntu/19.10" "ubu1910" # July 2020
  22. "$LINUXCONTAINERS_ORG_NAME:ubuntu/20.04" "ubu2004" # future (EOL 2030)
  23. # EOL see https://fedoraproject.org/wiki/Releases
  24. "$LINUXCONTAINERS_ORG_NAME:fedora/31" "fedora31"
  25. # rolling releases see https://www.archlinux.org/releng/releases/
  26. "$LINUXCONTAINERS_ORG_NAME:archlinux" "archlinux"
  27. )
  28. PUBLIC_URL="${PUBLIC_URL:-http://$(uname -n)/searx}"
  29. if in_container; then
  30. # container hostnames do not have a DNS entry: use primary IP!
  31. PUBLIC_URL="http://$(primary_ip)/searx"
  32. # make GUEST's services public to the HOST
  33. FILTRON_API="0.0.0.0:4005"
  34. FILTRON_LISTEN="0.0.0.0:4004"
  35. MORTY_LISTEN="0.0.0.0:3000"
  36. # export LXC specific environment
  37. export PUBLIC_URL FILTRON_API FILTRON_LISTEN MORTY_LISTEN
  38. fi
  39. }
  40. lxc_suite_install_info() {
  41. (
  42. lxc_set_suite_env
  43. cat <<EOF
  44. LXC suite: ${LXC_SUITE_NAME} --> ${PUBLIC_URL}
  45. suite includes searx, morty & filtron
  46. suite images:
  47. $(echo " ${LOCAL_IMAGES[*]}" | $FMT)
  48. suite containers:
  49. $(echo " ${CONTAINERS[*]}" | $FMT)
  50. EOF
  51. )
  52. }
  53. lxc_suite_install() {
  54. (
  55. lxc_set_suite_env
  56. FORCE_TIMEOUT=0
  57. export FORCE_TIMEOUT
  58. "${LXC_REPO_ROOT}/utils/searx.sh" install all
  59. "${LXC_REPO_ROOT}/utils/morty.sh" install all
  60. "${LXC_REPO_ROOT}/utils/filtron.sh" install all
  61. rst_title "suite installation finished ($(hostname))" part
  62. lxc_suite_info
  63. echo
  64. )
  65. }
  66. lxc_suite_info() {
  67. (
  68. lxc_set_suite_env
  69. for ip in $(global_IPs) ; do
  70. if [[ $ip =~ .*:.* ]]; then
  71. info_msg "(${ip%|*}) IPv6: http://[${ip#*|}]"
  72. else
  73. # IPv4:
  74. # shellcheck disable=SC2034,SC2031
  75. info_msg "(${ip%|*}) filtron: http://${ip#*|}:4004/ $PUBLIC_URL"
  76. info_msg "(${ip%|*}) morty: http://${ip#*|}:3000/ $PUBLIC_URL_MORTY"
  77. info_msg "(${ip%|*}) docs-live: http://${ip#*|}:8080/"
  78. fi
  79. done
  80. )
  81. }