-
Notifications
You must be signed in to change notification settings - Fork 0
/
vars
executable file
·46 lines (40 loc) · 1.32 KB
/
vars
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
#!/bin/bash
source "$(dirname $0)/../dokku_common"
DB_ROOT="$DOKKU_ROOT/.neo4j"
DB_IMAGE_NAME="tpires/neo4j"
DB_CONTAINER_LINK="neo4j"
DB_CONTAINER_VOLUME="${NEO4J_CONTAINER_VOLUME:-/var/lib/neo4j/data}"
DB_PORT="${NEO4J_PORT:-7474}"
function neo4j_for_app() {
verify_app_name "$1"
DB_VOLUME="$DB_ROOT/$APP"
if [ -s "$DB_VOLUME" ] ; then
DB_APP="$(cat "$DB_VOLUME")"
else
DB_APP="$APP"
fi
DB_CONTAINER_NAME="plugin_neo4j_${DB_APP}"
DB_DATA_CONTAINER_NAME="plugin_neo4j_data_${DB_APP}"
#DB_PASSWORD_FILE="$DB_VOLUME/pass_$APP"
DB_HOST="$DB_CONTAINER_LINK"
DB_REST_URL="http://$DB_CONTAINER_LINK:$DB_PORT/db/data"
set +eo pipefail
DB_CONTAINER_ID=$(docker ps | grep "$DB_CONTAINER_NAME" | awk '{print $1}')
set -eo pipefail
}
function start_database_container() {
docker run --name="$DB_DATA_CONTAINER_NAME" \
-v "$DB_CONTAINER_VOLUME" \
busybox:latest true 1> /dev/null 2> /dev/null || true
docker run --detach \
-e NEO4J_AUTH=none \
--name="$DB_CONTAINER_NAME" \
--volumes-from="$DB_DATA_CONTAINER_NAME" \
"$DB_IMAGE_NAME" > /dev/null
}
function ensure_database_container_is_running() {
if [[ -z "$DB_CONTAINER_ID" ]] ; then
remove_container "$DB_CONTAINER_NAME"
start_database_container 2> /dev/null || true
fi
}