Skip to content

Instantly share code, notes, and snippets.

@tzmartin
Created January 22, 2016 20:13
Show Gist options
  • Save tzmartin/5d4707f0869360287e05 to your computer and use it in GitHub Desktop.
Save tzmartin/5d4707f0869360287e05 to your computer and use it in GitHub Desktop.
x letsencrypt y
```
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions"
case "$1" in
letsencrypt:sign)
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$2"
APP="$2"; DOMAIN="$3";
mkdir -p "$DOKKU_ROOT/$APP/tls"
docker run -it --rm -p 443:443 -p 80:80 --name letsencrypt \
-v "/etc/letsencrypt:/etc/letsencrypt" \
-v "/var/lib/letsencrypt:/var/lib/letsencrypt" \
quay.io/letsencrypt/letsencrypt:latest -d $DOMAIN auth
cp "/etc/letsencrypt/live/$DOMAIN/privkey.pem" "$DOKKU_ROOT/$APP/tls/server.key"
cp "/etc/letsencrypt/live/$DOMAIN/fullchain.pem" "$DOKKU_ROOT/$APP/tls/server.crt"
nginx_build_config $APP
;;
help | letsencrypt:help)
cat && cat<<EOF
letsencrypt:sign <app> <domain>, generate certificate for <domain> and configure nginx with it"
EOF
;;
*)
exit $DOKKU_NOT_IMPLEMENTED_EXIT
;;
esac
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment