-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands
executable file
·92 lines (78 loc) · 2.86 KB
/
commands
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
#!/bin/bash
source "$(dirname $0)/vars"
case "$1" in
neo4j:create)
neo4j_for_app "$2"
verify_max_args 2 "$@"
if [[ -f "$DB_VOLUME" ]] ; then
info "Neo4j database container $DB_CONTAINER_NAME already linked to $APP"
else
touch "$DB_VOLUME"
info "Neo4j database created: $DB_CONTAINER_NAME"
redeploy_app "$APP"
fi
;;
neo4j:destroy|neo4j:delete)
neo4j_for_app "$2"
verify_max_args 2 "$@"
if [ ! -s "$DB_VOLUME" ] && [ -f "$DB_VOLUME" ] ; then
stop_and_remove_container "$DB_CONTAINER_NAME" "$DB_DATA_CONTAINER_NAME"
rm -f "$DB_VOLUME"
info "Neo4j database deleted: $DB_CONTAINER_NAME"
redeploy_app "$APP"
elif [[ -f "$DB_VOLUME" ]] ; then
info "This application is linked to the database created on $DB_APP"
info "You can only delete the database by removing it from $DB_APP"
else
info "There is not a neo4j database associated with this application"
fi
;;
neo4j:link)
verify_max_args 3 "$@"
verify_app_name "$3"
verify_app_name "$2"
neo4j_for_app "$2"
if [[ -f "$DB_VOLUME" ]] ; then
info "Neo4j database container $DB_CONTAINER_NAME already linked to $APP"
else
echo "$3" > $DB_VOLUME
neo4j_for_app "$2"
info "Neo4j database linked: $DB_CONTAINER_NAME to $APP"
redeploy_app "$APP"
fi
;;
neo4j:unlink)
verify_max_args 2 "$@"
neo4j_for_app "$2"
rm -f "$DB_VOLUME"
info "Neo4j database unlinked: $DB_CONTAINER_NAME from $APP"
redeploy_app "$APP"
;;
neo4j:shell|neo4j:console)
neo4j_for_app "$2"
[[ ! -f "$DB_VOLUME" ]] && fail "$DB_CONTAINER_NAME: database is not linked to $APP"
docker exec -it "$DB_CONTAINER_NAME" "/usr/bin/neo4j-shell" "${@:2}"
;;
neo4j:info)
neo4j_for_app "$2"
verify_max_args 2 "$@"
[[ ! -f "$DB_VOLUME" ]] && fail "$DB_CONTAINER_NAME: database is not linked to $APP"
cat <<EOF
NEO4J_REST_URL=$DB_REST_URL
EOF
;;
help)
cat && cat<<EOF
neo4j:create <app> Add Neo4j config to the app environment
neo4j:destroy <app> Remove Neo4j config and container from the app environment
neo4j:link <app> <db-app> Link a Neo4j container from another app to this app.
neo4j:unlink <app> Unlinks a Neo4j container from this app.
neo4j:info <app> Shows status of Neo4j
neo4j:shell <app> Enter the neo4j-shell inside the neo4j container
EOF
# neo4j:link <app> <container> Link an app to a neo4j container
;;
*)
exit $DOKKU_NOT_IMPLEMENTED_EXIT
;;
esac