This plugin conforms to the heroku api for setting and removing domains. Note that it does not yet update the URL file for a given application.
This commit is contained in:
Jose Diaz-Gonzalez
2014-11-24 02:02:46 -05:00
parent f23809e75f
commit 66171551d8
2 changed files with 89 additions and 0 deletions

82
plugins/domains/commands Executable file
View File

@@ -0,0 +1,82 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
vhost_create () {
VHOST_PATH="$DOKKU_ROOT/$2/VHOST"
[ -f $VHOST_PATH ] || {
echo "-----> Creating new $VHOST_PATH..."
touch $VHOST_PATH
}
}
case "$1" in
domains)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
[[ ! -d "$DOKKU_ROOT/$2" ]] && echo "App $2 does not exist" && exit 1
APP="$2"
vhost_create
echo "=== $APP Domain Names"
cat "$DOKKU_ROOT/$APP/VHOST"
;;
domains:add)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
[[ ! -d "$DOKKU_ROOT/$2" ]] && echo "App $2 does not exist" && exit 1
APP="$2"
if [[ -z $3 ]]; then
echo "Usage: dokku $1 $APP DOMAIN"
echo "Must specify DOMAIN."
exit 1
fi
vhost_create
echo "$3" >> "$DOKKU_ROOT/$APP/VHOST"
pluginhook post-domains-update $APP
echo "-----> Added $3 to $APP"
;;
domains:clear)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
[[ ! -d "$DOKKU_ROOT/$2" ]] && echo "App $2 does not exist" && exit 1
APP="$2"
vhost_create
echo '' > "$DOKKU_ROOT/$APP/VHOST"
pluginhook post-domains-update $APP
echo "-----> Cleared domains in $APP"
;;
domains:remove)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
[[ ! -d "$DOKKU_ROOT/$2" ]] && echo "App $2 does not exist" && exit 1
APP="$2"
if [[ -z $3 ]]; then
echo "Usage: dokku $1 $2 DOMAIN"
echo "Must specify DOMAIN."
exit 1
fi
vhost_create
sed -i "/^$3$/d" "$DOKKU_ROOT/$APP/VHOST"
pluginhook post-domains-update $APP
echo "-----> Removed $3 from $APP"
;;
help | domains:help)
cat && cat<<EOF
domains <app> List custom domains for app
domains:help <app> This help message
domains:add <app> DOMAIN Add a custom domain to app
domains:clear <app> Clear all custom domains for app
domains:remove <app> DOMAIN Remove a custom domain from app
EOF
;;
*)
exit $DOKKU_NOT_IMPLEMENTED_EXIT
;;
esac

7
plugins/domains/install Executable file
View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
for app in $(ls -d $DOKKU_ROOT/*/CONTAINER); do
APP=$(basename $(dirname $app));
touch "$DOKKU_ROOT/$APP/VHOST"
done