forked from wmluke/dokku-domains-plugin
-
Notifications
You must be signed in to change notification settings - Fork 3
/
commands
executable file
·63 lines (52 loc) · 1.4 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
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# Check if name is specified
if [[ $1 == domains ]] || [[ $1 == domains:* ]]; then
if [[ -z $2 ]]; then
echo "You must specify an app name"
exit 1
else
APP="$2"
DOMAINS_FILE="$DOKKU_ROOT/$APP/DOMAINS"
# Check if app exists with the same name
if [ ! -d "$DOKKU_ROOT/$APP" ]; then
echo "App $APP does not exist"
exit 1
fi
[ -f $DOMAINS_FILE ] || {
echo "-----> Creating $DOMAINS_FILE"
touch $DOMAINS_FILE
}
fi
fi
case "$1" in
url)
APP="$2";
if [[ -d "$DOKKU_ROOT/$APP" ]]; then
if [[ -f "$DOKKU_ROOT/$APP/nginx.conf" ]]; then
echo "=====> Current server_name configuration for app vhost:"
echo -n " "; cat $DOKKU_ROOT/$APP/nginx.conf | grep "server_name"
fi
fi
;;
domains)
cat $DOMAINS_FILE
;;
domains:set)
if [[ -z "${*:3}" ]]; then
echo "Usage: dokku domains:set APP DOMAIN1 [DOMAIN2 ...]"
echo "Must specify a DOMAIN."
exit 1
fi
domains="${*:3}"
echo "$domains" > $DOMAINS_FILE
pluginhook nginx-pre-reload $APP
sudo /etc/init.d/nginx reload
;;
help)
cat && cat<<EOF
domains <app> display the domains for an app
domains:set <app> DOMAIN1 [DOMAIN2 ...] set one or more domains
EOF
;;
esac