This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
forked from neo4j/docker-neo4j
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-entrypoint.sh
executable file
·105 lines (88 loc) · 3.7 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash -eu
setting() {
setting="${1}"
value="${2}"
file="${3}"
if [ ! -f "conf/${file}" ]; then
if [ -f "conf/neo4j.conf" ]; then
file="neo4j.conf"
fi
fi
if [ -n "${value}" ]; then
sed -i "s|.*${setting}=.*|${setting}=${value}|" conf/"${file}"
fi
}
if [ "$1" == "neo4j" ]; then
setting "keep_logical_logs" "${NEO4J_KEEP_LOGICAL_LOGS:-100M size}" neo4j.properties
setting "dbms.pagecache.memory" "${NEO4J_CACHE_MEMORY:-512M}" neo4j.properties
setting "wrapper.java.additional=-Dneo4j.ext.udc.source" "${NEO4J_UDC_SOURCE:-docker}" neo4j-wrapper.conf
setting "wrapper.java.initmemory" "${NEO4J_HEAP_MEMORY:-512}" neo4j-wrapper.conf
setting "wrapper.java.maxmemory" "${NEO4J_HEAP_MEMORY:-512}" neo4j-wrapper.conf
setting "org.neo4j.server.thirdparty_jaxrs_classes" "${NEO4J_THIRDPARTY_JAXRS_CLASSES:-}" neo4j-server.properties
setting "allow_store_upgrade" "${NEO4J_ALLOW_STORE_UPGRADE:-}" neo4j.properties
if [ "${NEO4J_AUTH:-}" == "none" ]; then
setting "dbms.security.auth_enabled" "false" neo4j-server.properties
elif [[ "${NEO4J_AUTH:-}" == neo4j/* ]]; then
password="${NEO4J_AUTH#neo4j/}"
bin/neo4j start || \
(cat data/log/console.log && echo "Neo4j failed to start" && exit 1)
end="$((SECONDS+10))"
while true; do
http_code="$(curl --silent --write-out %{http_code} --user "neo4j:${password}" --output /dev/null http://localhost:7474/db/data/ || true)"
if [[ "${http_code}" = "200" ]]; then
break;
fi
if [[ "${http_code}" = "403" ]]; then
curl --fail --silent --show-error --user neo4j:neo4j \
--data '{"password": "'"${password}"'"}' \
--header 'Content-Type: application/json' \
http://localhost:7474/user/neo4j/password
break;
fi
if [[ "${SECONDS}" -ge "${end}" ]]; then
(cat data/log/console.log && echo "Neo4j failed to start" && exit 1)
fi
sleep 1
done
bin/neo4j stop
elif [ -n "${NEO4J_AUTH:-}" ]; then
echo "Invalid value for NEO4J_AUTH: '${NEO4J_AUTH}'"
exit 1
fi
setting "org.neo4j.server.webserver.address" "0.0.0.0" neo4j-server.properties
setting "org.neo4j.server.database.mode" "${NEO4J_DATABASE_MODE:-}" neo4j-server.properties
setting "ha.server_id" "${NEO4J_SERVER_ID:-}" neo4j.properties
setting "ha.server" "${NEO4J_HA_ADDRESS:-}:6001" neo4j.properties
setting "ha.cluster_server" "${NEO4J_HA_ADDRESS:-}:5001" neo4j.properties
setting "ha.initial_hosts" "${NEO4J_INITIAL_HOSTS:-}" neo4j.properties
[ -f "${EXTENSION_SCRIPT:-}" ] && . ${EXTENSION_SCRIPT}
if [ -d /conf ]; then
find /conf -type f -exec cp {} conf \;
fi
if [ -d /ssl ]; then
num_certs=$(ls /ssl/*.cert 2>/dev/null | wc -l)
num_keys=$(ls /ssl/*.key 2>/dev/null | wc -l)
if [ $num_certs == "1" -a $num_keys == "1" ]; then
cert=$(ls /ssl/*.cert)
key=$(ls /ssl/*.key)
setting "dbms.security.tls_certificate_file" $cert neo4j-server.properties
setting "dbms.security.tls_key_file" $key neo4j-server.properties
else
echo "You must provide exactly one *.cert and exactly one *.key in /ssl."
exit 1
fi
fi
if [ -d /plugins ]; then
find /plugins -type f -exec cp {} plugins \;
fi
exec bin/neo4j console
elif [ "$1" == "dump-config" ]; then
if [ -d /conf ]; then
cp -r conf/* /conf
else
echo "You must provide a /conf volume"
exit 1
fi
else
exec "$@"
fi