From d001fcc89609b7d69f5358d5330cf5cb464e2796 Mon Sep 17 00:00:00 2001 From: Omar Shehata Date: Mon, 28 Nov 2016 02:53:46 +0000 Subject: [PATCH 01/10] Added certs default help function --- plugins/certs/commands | 23 +++-------------------- plugins/certs/functions | 24 ++++++++++++++++++++++++ plugins/certs/subcommands/default | 13 +++++++++++++ 3 files changed, 40 insertions(+), 20 deletions(-) create mode 100644 plugins/certs/subcommands/default diff --git a/plugins/certs/commands b/plugins/certs/commands index c34b902c8..e04a558a3 100755 --- a/plugins/certs/commands +++ b/plugins/certs/commands @@ -1,31 +1,14 @@ #!/usr/bin/env bash [[ " help certs:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_AVAILABLE_PATH/certs/functions" case "$1" in help | certs:help) - help_content_func () { - declare desc="return certs plugin help content" - cat< CRT KEY, Add an ssl endpoint to an app. Can also import from a tarball on stdin - certs:chain CRT [CRT ...], [NOT IMPLEMENTED] Print the ordered and complete chain for the given certificate - certs:generate DOMAIN, Generate a key and certificate signing request (and self-signed certificate) - certs:info , Show certificate information for an ssl endpoint - certs:key CRT KEY [KEY ...], [NOT IMPLEMENTED] Print the correct key for the given certificate - certs:remove , Remove an SSL Endpoint from an app - certs:rollback , [NOT IMPLEMENTED] Rollback an SSL Endpoint for an app - certs:update CRT KEY, Update an SSL Endpoint on an app. Can also import from a tarball on stdin -help_content - } + if [[ $1 = "certs:help" ]] ; then - echo -e 'Usage: dokku certs:COMMAND' - echo '' - echo 'Manage Dokku apps SSL (TLS) certs.' - echo '' - echo 'Additional commands:' - help_content_func | sort | column -c2 -t -s, + help_formatted else help_content_func fi diff --git a/plugins/certs/functions b/plugins/certs/functions index a130c993e..77d10de83 100755 --- a/plugins/certs/functions +++ b/plugins/certs/functions @@ -2,6 +2,30 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +help_formatted (){ + echo -e 'Usage: dokku certs:COMMAND' + echo '' + echo 'Manage Dokku apps SSL (TLS) certs.' + echo '' + echo 'Additional commands:' + help_content_func | sort | column -c2 -t -s, +} + +help_content_func () { + declare desc="return certs plugin help content" + cat< CRT KEY, Add an ssl endpoint to an app. Can also import from a tarball on stdin + certs:chain CRT [CRT ...], [NOT IMPLEMENTED] Print the ordered and complete chain for the given certificate + certs:generate DOMAIN, Generate a key and certificate signing request (and self-signed certificate) + certs:info , Show certificate information for an ssl endpoint + certs:key CRT KEY [KEY ...], [NOT IMPLEMENTED] Print the correct key for the given certificate + certs:remove , Remove an SSL Endpoint from an app + certs:rollback , [NOT IMPLEMENTED] Rollback an SSL Endpoint for an app + certs:update CRT KEY, Update an SSL Endpoint on an app. Can also import from a tarball on stdin +help_content + } + is_ssl_enabled() { declare desc="returns 0 if ssl is enabled for given app" local APP=$1; verify_app_name "$APP" diff --git a/plugins/certs/subcommands/default b/plugins/certs/subcommands/default new file mode 100644 index 000000000..f9869973a --- /dev/null +++ b/plugins/certs/subcommands/default @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_AVAILABLE_PATH/certs/functions" + +certs_main_cmd() { + declare desc="return certs plugin help content" + local cmd="certs" + help_formatted +} + +certs_main_cmd "$@" + From 74db5b9d3bd57501227a8bbf71c5c09573af7127 Mon Sep 17 00:00:00 2001 From: Omar Shehata Date: Mon, 28 Nov 2016 02:59:32 +0000 Subject: [PATCH 02/10] Added ssh-keys default help function --- plugins/ssh-keys/commands | 18 +++--------------- plugins/ssh-keys/functions | 19 +++++++++++++++++++ plugins/ssh-keys/subcommands/default | 12 ++++++++++++ 3 files changed, 34 insertions(+), 15 deletions(-) create mode 100644 plugins/ssh-keys/subcommands/default diff --git a/plugins/ssh-keys/commands b/plugins/ssh-keys/commands index bfd36a0ce..a205bd054 100755 --- a/plugins/ssh-keys/commands +++ b/plugins/ssh-keys/commands @@ -1,26 +1,14 @@ #!/usr/bin/env bash [[ " help ssh-keys:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_AVAILABLE_PATH/ssh-keys/functions" case "$1" in help | ssh-keys:help) - help_content_func () { - declare desc="return ssh-keys plugin help content" - cat< [/path/to/key], Add a new public key by pipe or path - ssh-keys:remove , Remove SSH public key by name -help_content - } + if [[ $1 = "ssh-keys:help" ]] ; then - echo -e 'Usage: dokku ssh-keys[:COMMAND]' - echo '' - echo 'Manage public ssh keys that are allowed to connect to Dokku' - echo '' - echo 'Additional commands:' - help_content_func | sort | column -c2 -t -s, + help_formatted else help_content_func fi diff --git a/plugins/ssh-keys/functions b/plugins/ssh-keys/functions index 24b5e6807..262eacc44 100755 --- a/plugins/ssh-keys/functions +++ b/plugins/ssh-keys/functions @@ -2,6 +2,25 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +help_formatted (){ + echo -e 'Usage: dokku ssh-keys[:COMMAND]' + echo '' + echo 'Manage public ssh keys that are allowed to connect to Dokku' + echo '' + echo 'Additional commands:' + help_content_func | sort | column -c2 -t -s, +} + +help_content_func () { + declare desc="return ssh-keys plugin help content" + cat< [/path/to/key], Add a new public key by pipe or path + ssh-keys:remove , Remove SSH public key by name +help_content + } + verify_ssh_key_file() { declare desc="Test that public key is valid" [[ -s ${DOKKU_ROOT}/.ssh/authorized_keys ]] || dokku_log_fail "No public keys found." diff --git a/plugins/ssh-keys/subcommands/default b/plugins/ssh-keys/subcommands/default new file mode 100644 index 000000000..9b31420a5 --- /dev/null +++ b/plugins/ssh-keys/subcommands/default @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_AVAILABLE_PATH/config/functions" +source "$PLUGIN_AVAILABLE_PATH/ssh-keys/functions" + +ssh_keys_main_cmd() { + declare desc="return ssh-keys plugin help content" + local cmd="ssh-keys" + help_formatted +} + +ssh_keys_main_cmd "$@" From 810ba72879bbc0092929aa8c987c7cdeb3c3179f Mon Sep 17 00:00:00 2001 From: Omar Shehata Date: Mon, 28 Nov 2016 03:03:30 +0000 Subject: [PATCH 03/10] Added nginx default help function --- plugins/nginx-vhosts/commands | 18 +++--------------- plugins/nginx-vhosts/functions | 19 +++++++++++++++++++ plugins/nginx-vhosts/subcommands/default | 13 +++++++++++++ 3 files changed, 35 insertions(+), 15 deletions(-) create mode 100644 plugins/nginx-vhosts/subcommands/default diff --git a/plugins/nginx-vhosts/commands b/plugins/nginx-vhosts/commands index f7911fc25..2995231d7 100755 --- a/plugins/nginx-vhosts/commands +++ b/plugins/nginx-vhosts/commands @@ -1,26 +1,14 @@ #!/usr/bin/env bash [[ " help nginx:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions" case "$1" in help | nginx:help) - help_content_func () { - declare desc="return nginx plugin help content" - cat<, (Re)builds nginx config for given app - nginx:access-logs [-t], Show the nginx access logs for an application (-t follows) - nginx:error-logs [-t], Show the nginx error logs for an application (-t follows) -help_content - } + if [[ $1 = "nginx:help" ]] ; then - echo -e 'Usage: dokku nginx[:COMMAND]' - echo '' - echo 'Interact with Dokku'"'"'s Nginx proxy.' - echo '' - echo 'Additional commands:' - help_content_func | sort | column -c2 -t -s, + help_formatted else help_content_func fi diff --git a/plugins/nginx-vhosts/functions b/plugins/nginx-vhosts/functions index 2b6f6bc4b..e98e2e704 100755 --- a/plugins/nginx-vhosts/functions +++ b/plugins/nginx-vhosts/functions @@ -6,6 +6,25 @@ source "$PLUGIN_AVAILABLE_PATH/config/functions" source "$PLUGIN_AVAILABLE_PATH/domains/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" +help_formatted (){ + echo -e 'Usage: dokku nginx[:COMMAND]' + echo '' + echo 'Interact with Dokku'"'"'s Nginx proxy.' + echo '' + echo 'Additional commands:' + help_content_func | sort | column -c2 -t -s, +} + +help_content_func () { + declare desc="return nginx plugin help content" + cat<, (Re)builds nginx config for given app + nginx:access-logs [-t], Show the nginx access logs for an application (-t follows) + nginx:error-logs [-t], Show the nginx error logs for an application (-t follows) +help_content + } + validate_nginx() { declare desc="validate entire nginx config" set +e diff --git a/plugins/nginx-vhosts/subcommands/default b/plugins/nginx-vhosts/subcommands/default new file mode 100644 index 000000000..30cb86061 --- /dev/null +++ b/plugins/nginx-vhosts/subcommands/default @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_AVAILABLE_PATH/config/functions" +source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions" + +nginx_main_cmd() { + declare desc="display nginx plugin help content" + local cmd="nginx" + help_formatted +} + +nginx_main_cmd "$@" From 42947934520d1ca0f151650fbb52f5256f47cfe7 Mon Sep 17 00:00:00 2001 From: Omar Shehata Date: Mon, 28 Nov 2016 03:06:30 +0000 Subject: [PATCH 04/10] Added storage default help function --- plugins/storage/commands | 17 ++--------------- plugins/storage/functions | 19 +++++++++++++++++++ plugins/storage/subcommands/default | 12 ++++++++++++ 3 files changed, 33 insertions(+), 15 deletions(-) create mode 100644 plugins/storage/subcommands/default diff --git a/plugins/storage/commands b/plugins/storage/commands index 337f07473..03d73207f 100755 --- a/plugins/storage/commands +++ b/plugins/storage/commands @@ -1,26 +1,13 @@ #!/usr/bin/env bash [[ " storage:help help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_CORE_AVAILABLE_PATH/storage/functions" case "$1" in help | storage:help) - help_content_func () { - declare desc="return storage plugin help content" - cat<, List bind mounts for app's container(s) (host:container) - storage:mount , Create a new bind mount - storage:unmount , Remove an existing bind mount -help_content - } if [[ $1 = "shell:help" ]] ; then - echo -e 'Usage: dokku storage:COMMAND' - echo '' - echo 'Mount local volume / directories inside containers.' - echo '' - echo 'Additional commands:' - help_content_func | sort | column -c2 -t -s, + help_formatted else help_content_func fi diff --git a/plugins/storage/functions b/plugins/storage/functions index 767059f13..02752b0bc 100755 --- a/plugins/storage/functions +++ b/plugins/storage/functions @@ -2,6 +2,25 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +help_formatted (){ + echo -e 'Usage: dokku storage:COMMAND' + echo '' + echo 'Mount local volume / directories inside containers.' + echo '' + echo 'Additional commands:' + help_content_func | sort | column -c2 -t -s, +} + +help_content_func () { + declare desc="return storage plugin help content" + cat<, List bind mounts for app's container(s) (host:container) + storage:mount , Create a new bind mount + storage:unmount , Remove an existing bind mount +help_content + } + verify_paths() { declare desc="verifies storage paths" echo "$1" | grep -qe '^/.*\:/' || dokku_log_fail "Storage path must be two valid paths divided by colon." diff --git a/plugins/storage/subcommands/default b/plugins/storage/subcommands/default new file mode 100644 index 000000000..764a9f5a0 --- /dev/null +++ b/plugins/storage/subcommands/default @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/storage/functions" + +storage_main_cmd() { + declare desc="Display storage plugin help content" + local cmd="storage" + help_formatted +} + +storage_main_cmd "$@" From 0fed122a992d30e84ab4920aa564d67e8da3c0ab Mon Sep 17 00:00:00 2001 From: Omar Shehata Date: Sat, 3 Dec 2016 19:07:34 +0000 Subject: [PATCH 05/10] Revert "Added storage default help function" This reverts commit 42947934520d1ca0f151650fbb52f5256f47cfe7. --- plugins/storage/commands | 17 +++++++++++++++-- plugins/storage/functions | 19 ------------------- plugins/storage/subcommands/default | 12 ------------ 3 files changed, 15 insertions(+), 33 deletions(-) delete mode 100644 plugins/storage/subcommands/default diff --git a/plugins/storage/commands b/plugins/storage/commands index 03d73207f..337f07473 100755 --- a/plugins/storage/commands +++ b/plugins/storage/commands @@ -1,13 +1,26 @@ #!/usr/bin/env bash [[ " storage:help help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_CORE_AVAILABLE_PATH/storage/functions" case "$1" in help | storage:help) + help_content_func () { + declare desc="return storage plugin help content" + cat<, List bind mounts for app's container(s) (host:container) + storage:mount , Create a new bind mount + storage:unmount , Remove an existing bind mount +help_content + } if [[ $1 = "shell:help" ]] ; then - help_formatted + echo -e 'Usage: dokku storage:COMMAND' + echo '' + echo 'Mount local volume / directories inside containers.' + echo '' + echo 'Additional commands:' + help_content_func | sort | column -c2 -t -s, else help_content_func fi diff --git a/plugins/storage/functions b/plugins/storage/functions index 02752b0bc..767059f13 100755 --- a/plugins/storage/functions +++ b/plugins/storage/functions @@ -2,25 +2,6 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -help_formatted (){ - echo -e 'Usage: dokku storage:COMMAND' - echo '' - echo 'Mount local volume / directories inside containers.' - echo '' - echo 'Additional commands:' - help_content_func | sort | column -c2 -t -s, -} - -help_content_func () { - declare desc="return storage plugin help content" - cat<, List bind mounts for app's container(s) (host:container) - storage:mount , Create a new bind mount - storage:unmount , Remove an existing bind mount -help_content - } - verify_paths() { declare desc="verifies storage paths" echo "$1" | grep -qe '^/.*\:/' || dokku_log_fail "Storage path must be two valid paths divided by colon." diff --git a/plugins/storage/subcommands/default b/plugins/storage/subcommands/default deleted file mode 100644 index 764a9f5a0..000000000 --- a/plugins/storage/subcommands/default +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash -set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -source "$PLUGIN_CORE_AVAILABLE_PATH/storage/functions" - -storage_main_cmd() { - declare desc="Display storage plugin help content" - local cmd="storage" - help_formatted -} - -storage_main_cmd "$@" From 010c89e8104dafa0b2b9fcfae6d008af33306d64 Mon Sep 17 00:00:00 2001 From: Omar Shehata Date: Sat, 3 Dec 2016 19:08:02 +0000 Subject: [PATCH 06/10] Revert "Added ssh-keys default help function" This reverts commit 74db5b9d3bd57501227a8bbf71c5c09573af7127. --- plugins/ssh-keys/commands | 18 +++++++++++++++--- plugins/ssh-keys/functions | 19 ------------------- plugins/ssh-keys/subcommands/default | 12 ------------ 3 files changed, 15 insertions(+), 34 deletions(-) delete mode 100644 plugins/ssh-keys/subcommands/default diff --git a/plugins/ssh-keys/commands b/plugins/ssh-keys/commands index a205bd054..bfd36a0ce 100755 --- a/plugins/ssh-keys/commands +++ b/plugins/ssh-keys/commands @@ -1,14 +1,26 @@ #!/usr/bin/env bash [[ " help ssh-keys:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_AVAILABLE_PATH/ssh-keys/functions" case "$1" in help | ssh-keys:help) - + help_content_func () { + declare desc="return ssh-keys plugin help content" + cat< [/path/to/key], Add a new public key by pipe or path + ssh-keys:remove , Remove SSH public key by name +help_content + } if [[ $1 = "ssh-keys:help" ]] ; then - help_formatted + echo -e 'Usage: dokku ssh-keys[:COMMAND]' + echo '' + echo 'Manage public ssh keys that are allowed to connect to Dokku' + echo '' + echo 'Additional commands:' + help_content_func | sort | column -c2 -t -s, else help_content_func fi diff --git a/plugins/ssh-keys/functions b/plugins/ssh-keys/functions index 262eacc44..24b5e6807 100755 --- a/plugins/ssh-keys/functions +++ b/plugins/ssh-keys/functions @@ -2,25 +2,6 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -help_formatted (){ - echo -e 'Usage: dokku ssh-keys[:COMMAND]' - echo '' - echo 'Manage public ssh keys that are allowed to connect to Dokku' - echo '' - echo 'Additional commands:' - help_content_func | sort | column -c2 -t -s, -} - -help_content_func () { - declare desc="return ssh-keys plugin help content" - cat< [/path/to/key], Add a new public key by pipe or path - ssh-keys:remove , Remove SSH public key by name -help_content - } - verify_ssh_key_file() { declare desc="Test that public key is valid" [[ -s ${DOKKU_ROOT}/.ssh/authorized_keys ]] || dokku_log_fail "No public keys found." diff --git a/plugins/ssh-keys/subcommands/default b/plugins/ssh-keys/subcommands/default deleted file mode 100644 index 9b31420a5..000000000 --- a/plugins/ssh-keys/subcommands/default +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash -set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_AVAILABLE_PATH/config/functions" -source "$PLUGIN_AVAILABLE_PATH/ssh-keys/functions" - -ssh_keys_main_cmd() { - declare desc="return ssh-keys plugin help content" - local cmd="ssh-keys" - help_formatted -} - -ssh_keys_main_cmd "$@" From 0062227c579689727e0399aae09a9b538dfc0c0c Mon Sep 17 00:00:00 2001 From: Omar Shehata Date: Sat, 3 Dec 2016 19:08:25 +0000 Subject: [PATCH 07/10] Revert "Added certs default help function" This reverts commit d001fcc89609b7d69f5358d5330cf5cb464e2796. --- plugins/certs/commands | 23 ++++++++++++++++++++--- plugins/certs/functions | 24 ------------------------ plugins/certs/subcommands/default | 13 ------------- 3 files changed, 20 insertions(+), 40 deletions(-) delete mode 100644 plugins/certs/subcommands/default diff --git a/plugins/certs/commands b/plugins/certs/commands index e04a558a3..c34b902c8 100755 --- a/plugins/certs/commands +++ b/plugins/certs/commands @@ -1,14 +1,31 @@ #!/usr/bin/env bash [[ " help certs:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_AVAILABLE_PATH/certs/functions" case "$1" in help | certs:help) - + help_content_func () { + declare desc="return certs plugin help content" + cat< CRT KEY, Add an ssl endpoint to an app. Can also import from a tarball on stdin + certs:chain CRT [CRT ...], [NOT IMPLEMENTED] Print the ordered and complete chain for the given certificate + certs:generate DOMAIN, Generate a key and certificate signing request (and self-signed certificate) + certs:info , Show certificate information for an ssl endpoint + certs:key CRT KEY [KEY ...], [NOT IMPLEMENTED] Print the correct key for the given certificate + certs:remove , Remove an SSL Endpoint from an app + certs:rollback , [NOT IMPLEMENTED] Rollback an SSL Endpoint for an app + certs:update CRT KEY, Update an SSL Endpoint on an app. Can also import from a tarball on stdin +help_content + } if [[ $1 = "certs:help" ]] ; then - help_formatted + echo -e 'Usage: dokku certs:COMMAND' + echo '' + echo 'Manage Dokku apps SSL (TLS) certs.' + echo '' + echo 'Additional commands:' + help_content_func | sort | column -c2 -t -s, else help_content_func fi diff --git a/plugins/certs/functions b/plugins/certs/functions index 77d10de83..a130c993e 100755 --- a/plugins/certs/functions +++ b/plugins/certs/functions @@ -2,30 +2,6 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -help_formatted (){ - echo -e 'Usage: dokku certs:COMMAND' - echo '' - echo 'Manage Dokku apps SSL (TLS) certs.' - echo '' - echo 'Additional commands:' - help_content_func | sort | column -c2 -t -s, -} - -help_content_func () { - declare desc="return certs plugin help content" - cat< CRT KEY, Add an ssl endpoint to an app. Can also import from a tarball on stdin - certs:chain CRT [CRT ...], [NOT IMPLEMENTED] Print the ordered and complete chain for the given certificate - certs:generate DOMAIN, Generate a key and certificate signing request (and self-signed certificate) - certs:info , Show certificate information for an ssl endpoint - certs:key CRT KEY [KEY ...], [NOT IMPLEMENTED] Print the correct key for the given certificate - certs:remove , Remove an SSL Endpoint from an app - certs:rollback , [NOT IMPLEMENTED] Rollback an SSL Endpoint for an app - certs:update CRT KEY, Update an SSL Endpoint on an app. Can also import from a tarball on stdin -help_content - } - is_ssl_enabled() { declare desc="returns 0 if ssl is enabled for given app" local APP=$1; verify_app_name "$APP" diff --git a/plugins/certs/subcommands/default b/plugins/certs/subcommands/default deleted file mode 100644 index f9869973a..000000000 --- a/plugins/certs/subcommands/default +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -source "$PLUGIN_AVAILABLE_PATH/certs/functions" - -certs_main_cmd() { - declare desc="return certs plugin help content" - local cmd="certs" - help_formatted -} - -certs_main_cmd "$@" - From 1f47803324b08708212ccd553b73c75098cf83a4 Mon Sep 17 00:00:00 2001 From: Omar Shehata Date: Sat, 3 Dec 2016 19:27:49 +0000 Subject: [PATCH 08/10] Added certs plugin default to info --- plugins/certs/functions | 33 +++++++++++++++++++++++++++++++ plugins/certs/subcommands/default | 12 +++++++++++ plugins/certs/subcommands/info | 32 ------------------------------ 3 files changed, 45 insertions(+), 32 deletions(-) create mode 100644 plugins/certs/subcommands/default diff --git a/plugins/certs/functions b/plugins/certs/functions index a130c993e..55c0ea953 100755 --- a/plugins/certs/functions +++ b/plugins/certs/functions @@ -2,6 +2,39 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +certs_info_cmd() { + # This is here because it's used in both the info and the default + declare desc="prints SSL certificate info for app" + local cmd="certs:info" + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" + verify_app_name "$2" + local APP="$2"; local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls" + + if [[ -n "$APP_SSL_PATH" ]]; then + dokku_log_info1 "Fetching SSL Endpoint info for $APP..." + dokku_log_info1 "Certificate details:" + dokku_log_info2 "Common Name(s): " + + for domain in $(get_ssl_hostnames "$APP" | xargs); do + dokku_log_info2 " $domain" + done + + dokku_log_info2 "Expires At: $(openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -text | grep "Not After :" | awk -F " : " '{ print $2 }')" + dokku_log_info2 "Issuer: $(openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -text | grep "Issuer:" | xargs | sed -e "s/Issuer: //g")" + dokku_log_info2 "Starts At: $(openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -text | grep "Not Before:" | awk -F ": " '{ print $2 }')" + dokku_log_info2 "Subject: $(openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -subject | sed -e "s:subject= ::g"| sed -e "s:^/::g" | sed -e "s:/:; :g")" + local SSL_VERIFY_OUTPUT="$(openssl verify -verbose -purpose sslserver "$APP_SSL_PATH/server.crt" | awk -F ':' '{ print $2 }' | tail -1 | xargs || true)" + if [[ "$SSL_VERIFY_OUTPUT" == "OK" ]]; then + local SSL_SELF_SIGNED="verified by a certificate authority." + else + local SSL_SELF_SIGNED="self signed." + fi + dokku_log_info2 "SSL certificate is $SSL_SELF_SIGNED" + else + dokku_log_info1 "$APP does not have an SSL endpoint" + fi +} + is_ssl_enabled() { declare desc="returns 0 if ssl is enabled for given app" local APP=$1; verify_app_name "$APP" diff --git a/plugins/certs/subcommands/default b/plugins/certs/subcommands/default new file mode 100644 index 000000000..5eabd33b8 --- /dev/null +++ b/plugins/certs/subcommands/default @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_AVAILABLE_PATH/certs/functions" + +certs_main_cmd() { + declare desc="an alias for certs:info" + local cmd="certs" + certs_info_cmd "$@" +} + +certs_main_cmd "$@" diff --git a/plugins/certs/subcommands/info b/plugins/certs/subcommands/info index cfda760d8..77fd90b7c 100755 --- a/plugins/certs/subcommands/info +++ b/plugins/certs/subcommands/info @@ -3,36 +3,4 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/certs/functions" -certs_info_cmd() { - declare desc="prints SSL certificate info for app" - local cmd="certs:info" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - verify_app_name "$2" - local APP="$2"; local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls" - - if [[ -n "$APP_SSL_PATH" ]]; then - dokku_log_info1 "Fetching SSL Endpoint info for $APP..." - dokku_log_info1 "Certificate details:" - dokku_log_info2 "Common Name(s): " - - for domain in $(get_ssl_hostnames "$APP" | xargs); do - dokku_log_info2 " $domain" - done - - dokku_log_info2 "Expires At: $(openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -text | grep "Not After :" | awk -F " : " '{ print $2 }')" - dokku_log_info2 "Issuer: $(openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -text | grep "Issuer:" | xargs | sed -e "s/Issuer: //g")" - dokku_log_info2 "Starts At: $(openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -text | grep "Not Before:" | awk -F ": " '{ print $2 }')" - dokku_log_info2 "Subject: $(openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -subject | sed -e "s:subject= ::g"| sed -e "s:^/::g" | sed -e "s:/:; :g")" - local SSL_VERIFY_OUTPUT="$(openssl verify -verbose -purpose sslserver "$APP_SSL_PATH/server.crt" | awk -F ':' '{ print $2 }' | tail -1 | xargs || true)" - if [[ "$SSL_VERIFY_OUTPUT" == "OK" ]]; then - local SSL_SELF_SIGNED="verified by a certificate authority." - else - local SSL_SELF_SIGNED="self signed." - fi - dokku_log_info2 "SSL certificate is $SSL_SELF_SIGNED" - else - dokku_log_info1 "$APP does not have an SSL endpoint" - fi -} - certs_info_cmd "$@" From f2a4f61920f2a99bdb5d9765e12bad6c9963ec40 Mon Sep 17 00:00:00 2001 From: Omar Shehata Date: Sat, 3 Dec 2016 19:36:11 +0000 Subject: [PATCH 09/10] Added ssh-keys plugin default to list --- plugins/ssh-keys/functions | 7 +++++++ plugins/ssh-keys/subcommands/default | 12 ++++++++++++ plugins/ssh-keys/subcommands/list | 7 ------- 3 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 plugins/ssh-keys/subcommands/default diff --git a/plugins/ssh-keys/functions b/plugins/ssh-keys/functions index 24b5e6807..767f4ae11 100755 --- a/plugins/ssh-keys/functions +++ b/plugins/ssh-keys/functions @@ -2,6 +2,13 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +list_ssh_keys() { + declare desc="List ssh key hashes" + local cmd="ssh-keys:list" + verify_ssh_key_file + sshcommand list dokku +} + verify_ssh_key_file() { declare desc="Test that public key is valid" [[ -s ${DOKKU_ROOT}/.ssh/authorized_keys ]] || dokku_log_fail "No public keys found." diff --git a/plugins/ssh-keys/subcommands/default b/plugins/ssh-keys/subcommands/default new file mode 100644 index 000000000..abdbaa619 --- /dev/null +++ b/plugins/ssh-keys/subcommands/default @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_AVAILABLE_PATH/ssh-keys/functions" + +ssh_keys_main_cmd() { + declare desc="an alias for ssh-keys:list" + local cmd="ssh-keys" + list_ssh_keys +} + +ssh_keys_main_cmd "$@" \ No newline at end of file diff --git a/plugins/ssh-keys/subcommands/list b/plugins/ssh-keys/subcommands/list index ce485bbd6..fb78c5e2a 100755 --- a/plugins/ssh-keys/subcommands/list +++ b/plugins/ssh-keys/subcommands/list @@ -3,11 +3,4 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/ssh-keys/functions" -list_ssh_keys() { - declare desc="List ssh key hashes" - local cmd="ssh-keys:list" - verify_ssh_key_file - sshcommand list dokku -} - list_ssh_keys "$@" From 58d774a316020ee96fcadbe9479106dd109152e0 Mon Sep 17 00:00:00 2001 From: Omar Shehata Date: Sat, 3 Dec 2016 19:38:48 +0000 Subject: [PATCH 10/10] Added default for storage plugin to list --- plugins/storage/functions | 10 ++++++++++ plugins/storage/subcommands/default | 13 +++++++++++++ plugins/storage/subcommands/list | 9 --------- 3 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 plugins/storage/subcommands/default diff --git a/plugins/storage/functions b/plugins/storage/functions index 767059f13..d65daeb26 100755 --- a/plugins/storage/functions +++ b/plugins/storage/functions @@ -2,6 +2,16 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +storage_list_cmd() { + declare desc="List all bound mounts" + local cmd="storage:list" + local passed_phases="deploy" + [[ ! $2 ]] && dokku_log_fail "storage:list requires an app to list." + verify_app_name "$2" && local APP="$2" + echo "$APP volume bind-mounts:" + get_bind_mounts "$(get_phase_file_path "$passed_phases")" +} + verify_paths() { declare desc="verifies storage paths" echo "$1" | grep -qe '^/.*\:/' || dokku_log_fail "Storage path must be two valid paths divided by colon." diff --git a/plugins/storage/subcommands/default b/plugins/storage/subcommands/default new file mode 100644 index 000000000..194ef7942 --- /dev/null +++ b/plugins/storage/subcommands/default @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/storage/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/docker-options/functions" + +storage_main_cmd() { + declare desc="an alias for storage:list" + local cmd="storage" + storage_list_cmd "$@" +} + +storage_main_cmd "$@" diff --git a/plugins/storage/subcommands/list b/plugins/storage/subcommands/list index ecaab29b0..a16999a38 100755 --- a/plugins/storage/subcommands/list +++ b/plugins/storage/subcommands/list @@ -4,14 +4,5 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_CORE_AVAILABLE_PATH/storage/functions" source "$PLUGIN_CORE_AVAILABLE_PATH/docker-options/functions" -storage_list_cmd() { - declare desc="List all bound mounts" - local cmd="storage:list" - local passed_phases="deploy" - [[ ! $2 ]] && dokku_log_fail "storage:list requires an app to list." - verify_app_name "$2" && local APP="$2" - echo "$APP volume bind-mounts:" - get_bind_mounts "$(get_phase_file_path "$passed_phases")" -} storage_list_cmd "$@"