-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstart_search_engine.sh
More file actions
executable file
·47 lines (38 loc) · 1.23 KB
/
Copy pathstart_search_engine.sh
File metadata and controls
executable file
·47 lines (38 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
# Bring up the local SearXNG instance used by the ThreeToks web vertical.
# See infra/searxng/README.md for details.
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SEARXNG_DIR="$ROOT_DIR/infra/searxng"
ENV_FILE="$SEARXNG_DIR/.env"
if ! command -v docker >/dev/null 2>&1; then
echo "error: docker is not installed or not on PATH" >&2
exit 1
fi
if ! docker info >/dev/null 2>&1; then
echo "error: Docker daemon is not running" >&2
exit 1
fi
# Reuse a previously generated secret so restarts don't rotate sessions/cache.
if [ -f "$ENV_FILE" ]; then
# shellcheck disable=SC1090
source "$ENV_FILE"
fi
if [ -z "${SEARXNG_SECRET:-}" ]; then
SEARXNG_SECRET="$(openssl rand -hex 32)"
echo "SEARXNG_SECRET=$SEARXNG_SECRET" > "$ENV_FILE"
echo "generated new SEARXNG_SECRET, saved to $ENV_FILE"
fi
export SEARXNG_SECRET
(cd "$SEARXNG_DIR" && docker compose up -d)
echo "waiting for searxng to come up..."
for _ in $(seq 1 15); do
if curl -s -X POST http://localhost:8080/search \
-d 'q=hello&categories=general&format=' >/dev/null 2>&1; then
echo "searxng up"
exit 0
fi
sleep 1
done
echo "error: searxng did not respond in time" >&2
exit 1