-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker_entrypoint.sh
executable file
·48 lines (42 loc) · 1.79 KB
/
docker_entrypoint.sh
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
48
#!/bin/sh
set -ea
_term() {
echo "Caught TERM signal!"
kill -TERM "$redis_process" 2>/dev/null
kill -TERM "$searxng_process" 2>/dev/null
}
export TOR_ONLY=$(yq e '.tor-url' /root/start9/config.yaml)
export SEARXNG_HOSTNAME=$(yq e '.public-host' /root/start9/config.yaml)
export LAN_ADDRESS=$(yq e '.lan-address' /root/start9/config.yaml)
export TOR_ADDRESS=$(yq e '.tor-address' /root/start9/config.yaml)
export LETSENCRYPT_EMAIL=$(yq e '.email-address' /root/start9/config.yaml)
export ENABLE_METRICS=$(yq e '.enable-metrics' /root/start9/config.yaml)
export ULTRA_SECRET_KEY=$(openssl rand -hex 32)
export INSTANCE_NAME=$(yq e '.instance-name' /root/start9/config.yaml)
if [ "$SEARXNG_HOSTNAME" = "null" ]; then
SEARXNG_HOSTNAME=$LAN_ADDRESS
fi
export SEARXNG_HOSTNAME=${SEARXNG_HOSTNAME:-https://$LAN_ADDRESS}
export SEARXNG_BASE_URL=https://${SEARXNG_HOSTNAME:-$LAN_ADDRESS}/
if $TOR_ONLY; then
export SEARXNG_HOSTNAME=http://$TOR_ADDRESS
export SEARXNG_BASE_URL=http://$TOR_ADDRESS/
fi
export SEARXNG_TLS=${LETSENCRYPT_EMAIL:-internal}
echo "SEARXNG_HOSTNAME=$SEARXNG_HOSTNAME" > /etc/.env
echo "LETSENCRYPT_EMAIL=$LETSENCRYPT_EMAIL" >> /etc/.env
sed -i "s|ultrasecretkey|$ULTRA_SECRET_KEY|g" /etc/searxng/settings.yml
sed -i "s|instance_name: .*|instance_name: $INSTANCE_NAME|g" /etc/searxng/settings.yml
yq e ".general.enable_metrics = $ENABLE_METRICS" -i /etc/searxng/settings.yml
touch /etc/searxng/limiter.toml
touch /root/start9/stats.yaml
echo 'version: 2' > /root/start9/stats.yaml
echo 'data:' >> /root/start9/stats.yaml
printf "\n\n [i] Starting Redis ...\n\n"
redis-server --save "" --appendonly "no" &
redis_process=$!
printf "\n\n [i] Starting SearXNG ...\n\n"
sh /usr/local/searxng/dockerfiles/docker-entrypoint.sh &
searxng_process=$!
trap _term TERM
wait $redis_process $searxng_process