forked from dokku/dokku-elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands
executable file
·166 lines (137 loc) · 6.09 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/usr/bin/env bash
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config"
[[ " help $PLUGIN_COMMAND_PREFIX:help " == *" $1 "* ]] || [[ "$1" == "$PLUGIN_COMMAND_PREFIX:"* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_BASE_PATH/common/functions"
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/functions"
if [[ ! -d $PLUGIN_DATA_ROOT ]]; then
dokku_log_fail "$PLUGIN_SERVICE: Please run: sudo dokku plugin:install"
fi
case "$1" in
$PLUGIN_COMMAND_PREFIX:backup)
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/backup" "$@"
;;
$PLUGIN_COMMAND_PREFIX:backup-auth)
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/backup-auth" "$@"
;;
$PLUGIN_COMMAND_PREFIX:backup-deauth)
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/backup-deauth" "$@"
;;
$PLUGIN_COMMAND_PREFIX:backup-schedule)
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/backup-schedule" "$@"
;;
$PLUGIN_COMMAND_PREFIX:backup-unschedule)
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/backup-unschedule" "$@"
;;
$PLUGIN_COMMAND_PREFIX:clone)
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/clone" "$@"
;;
$PLUGIN_COMMAND_PREFIX:connect)
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/connect" "$@"
;;
$PLUGIN_COMMAND_PREFIX:create)
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/create" "$@"
;;
$PLUGIN_COMMAND_PREFIX:destroy)
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/destroy" "$@"
;;
$PLUGIN_COMMAND_PREFIX:export)
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/export" "$@"
;;
$PLUGIN_COMMAND_PREFIX:expose)
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/expose" "$@"
;;
$PLUGIN_COMMAND_PREFIX:import)
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/import" "$@"
;;
$PLUGIN_COMMAND_PREFIX:info)
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/info" "$@"
;;
$PLUGIN_COMMAND_PREFIX:link)
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/link" "$@"
;;
$PLUGIN_COMMAND_PREFIX:list)
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/list" "$@"
;;
$PLUGIN_COMMAND_PREFIX:logs)
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/logs" "$@"
;;
$PLUGIN_COMMAND_PREFIX:promote)
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/promote" "$@"
;;
$PLUGIN_COMMAND_PREFIX:restart)
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/restart" "$@"
;;
$PLUGIN_COMMAND_PREFIX:start)
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/start" "$@"
;;
$PLUGIN_COMMAND_PREFIX:stop)
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/stop" "$@"
;;
$PLUGIN_COMMAND_PREFIX:unexpose)
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/unexpose" "$@"
;;
$PLUGIN_COMMAND_PREFIX:unlink)
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/unlink" "$@"
;;
help | $PLUGIN_COMMAND_PREFIX:help)
help_content_func() {
# shellcheck disable=SC2034
declare desc="return $PLUGIN_COMMAND_PREFIX plugin help content"
cat<<help_content
$PLUGIN_COMMAND_PREFIX:backup <name> <bucket>, NOT IMPLEMENTED
$PLUGIN_COMMAND_PREFIX:backup-auth <name> <aws_access_key_id> <aws_secret_access_key>, NOT IMPLEMENTED
$PLUGIN_COMMAND_PREFIX:backup-deauth <name>, NOT IMPLEMENTED
$PLUGIN_COMMAND_PREFIX:backup-schedule <name> <schedule> <bucket>, NOT IMPLEMENTED
$PLUGIN_COMMAND_PREFIX:backup-unschedule <name>, NOT IMPLEMENTED
$PLUGIN_COMMAND_PREFIX:clone <name> <new-name>, NOT IMPLEMENTED
$PLUGIN_COMMAND_PREFIX:connect <name>, NOT IMPLEMENTED
$PLUGIN_COMMAND_PREFIX:create <name>, Create a $PLUGIN_SERVICE service
$PLUGIN_COMMAND_PREFIX:destroy <name>, Delete the $PLUGIN_SERVICE service and stop its container if there are no links left
$PLUGIN_COMMAND_PREFIX:export <name>, NOT IMPLEMENTED
$PLUGIN_COMMAND_PREFIX:expose <name> [port], Expose a $PLUGIN_SERVICE service on custom port if provided (random port otherwise)
$PLUGIN_COMMAND_PREFIX:import <name> <file>, NOT IMPLEMENTED
$PLUGIN_COMMAND_PREFIX:info <name>, Print the connection information
$PLUGIN_COMMAND_PREFIX:link <name> <app>, Link the $PLUGIN_SERVICE service to the app
$PLUGIN_COMMAND_PREFIX:list, List all $PLUGIN_SERVICE services
$PLUGIN_COMMAND_PREFIX:logs <name> [-t], Print the most recent log(s) for this service
$PLUGIN_COMMAND_PREFIX:promote <name> <app>, Promote service <name> as ${PLUGIN_DEFAULT_ALIAS}_URL in <app>
$PLUGIN_COMMAND_PREFIX:restart <name>, Graceful shutdown and restart of the $PLUGIN_SERVICE service container
$PLUGIN_COMMAND_PREFIX:start <name>, Start a previously stopped $PLUGIN_SERVICE service
$PLUGIN_COMMAND_PREFIX:stop <name>, Stop a running $PLUGIN_SERVICE service
$PLUGIN_COMMAND_PREFIX:unexpose <name>, Unexpose a previously exposed $PLUGIN_SERVICE service
$PLUGIN_COMMAND_PREFIX:unlink <name> <app>, Unlink the $PLUGIN_SERVICE service from the app
help_content
}
help_list_func() {
# shellcheck disable=SC2034
declare desc="return $PLUGIN_COMMAND_PREFIX plugin help content"
cat<<help_list
NAME, VERSION, STATUS, EXPOSED PORTS, LINKS
service-name, $PLUGIN_COMMAND_PREFIX:$PLUGIN_IMAGE_VERSION, running, -, app-name
help_list
}
if [[ $1 = "$PLUGIN_COMMAND_PREFIX:help" ]] ; then
echo -e "Usage: dokku $PLUGIN_COMMAND_PREFIX[:COMMAND]"
echo ''
echo "List your $PLUGIN_COMMAND_PREFIX services."
echo ''
echo 'Example:'
echo ''
echo "\$ dokku $PLUGIN_COMMAND_PREFIX:list"
help_list_func | column -c5 -t -s,
echo ''
echo 'Additional commands:'
help_content_func | sort | column -c2 -t -s,
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
help_content_func
else
cat<<help_desc
$PLUGIN_COMMAND_PREFIX, Plugin for managing $PLUGIN_SERVICE services
help_desc
fi
;;
*)
exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
;;
esac