diff --git a/docs/development/plugin-creation.md b/docs/development/plugin-creation.md index 90a7a338c..13ee06120 100644 --- a/docs/development/plugin-creation.md +++ b/docs/development/plugin-creation.md @@ -19,7 +19,7 @@ source "$PLUGIN_PATH/common/functions" case "$1" in hello) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP); IMAGE=$(get_app_image_name $APP $IMAGE_TAG) verify_app_name "$APP" @@ -56,8 +56,7 @@ A few notes: ```shell IMAGE=$(docker images | grep "user/repo" | awk '{print $3}') if [[ -z $IMAGE ]]; then - echo "user/repo image not found... Did you run 'dokku plugins-install'?" - exit 1 + dokku_log_fail "user/repo image not found... Did you run 'dokku plugins-install'?" fi ``` diff --git a/plugins/00_dokku-standard/commands b/plugins/00_dokku-standard/commands index bd9864851..3d1838760 100755 --- a/plugins/00_dokku-standard/commands +++ b/plugins/00_dokku-standard/commands @@ -101,8 +101,7 @@ case "$1" in trace) [[ -d $DOKKU_ROOT/.dokkurc ]] || mkdir -p $DOKKU_ROOT/.dokkurc [[ "$2" == "on" ]] || [[ "$2" == "off" ]] || { - echo "Valid trace options are [on/off]" - exit 1 + dokku_log_fail "Valid trace options are [on/off]" } if [[ "$2" == "on" ]]; then @@ -121,7 +120,7 @@ case "$1" in ;; ls) - dokku_apps=$(ls -d $DOKKU_ROOT/*/ 2>/dev/null) || (echo "You haven't deployed any applications yet" && exit 1) + dokku_apps=$(ls -d $DOKKU_ROOT/*/ 2>/dev/null) || (dokku_log_fail "You haven't deployed any applications yet") dokku_col_log_info1_quiet "App Name" "Container Type" "Container Id" "Status" @@ -143,7 +142,7 @@ case "$1" in ;; logs) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" APP="$2"; verify_app_name "$2" if (is_deployed $APP); then @@ -169,7 +168,7 @@ case "$1" in ;; run) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP); IMAGE=$(get_app_image_name $APP $IMAGE_TAG) verify_app_name "$APP" @@ -185,7 +184,7 @@ case "$1" in ;; url | urls) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" APP="$2"; verify_app_name "$2" eval "$(config_export app $APP)" @@ -217,10 +216,7 @@ case "$1" in ;; version) - cat "$DOKKU_ROOT/VERSION" || { - echo "Unable to determine dokku's version" 2>&1 - exit 1 - } + cat "$DOKKU_ROOT/VERSION" || dokku_log_fail "Unable to determine dokku's version" ;; help) diff --git a/plugins/apps/commands b/plugins/apps/commands index f2e29666d..55fdfb89a 100755 --- a/plugins/apps/commands +++ b/plugins/apps/commands @@ -9,7 +9,7 @@ case "$1" in ;; apps:create) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" [[ -d "$DOKKU_ROOT/$2" ]] && dokku_log_warn "Name is already taken" && exit 1 APP="$2" @@ -18,8 +18,8 @@ case "$1" in ;; apps:destroy) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 - [[ "$2" == "tls" ]] && echo "Unable to destroy tls directory" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" + [[ "$2" == "tls" ]] && dokku_log_fail "Unable to destroy tls directory" [[ "$3" == "force" ]] && DOKKU_APPS_FORCE_DELETE=1 APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP) verify_app_name "$APP" diff --git a/plugins/backup/commands b/plugins/backup/commands index d964cde6e..1d1cf0655 100755 --- a/plugins/backup/commands +++ b/plugins/backup/commands @@ -50,14 +50,12 @@ case "$1" in tar xf $INPUT_FILE --directory=$BACKUP_TMP_DIR if [[ ! -f $BACKUP_TMP_DIR/.dokku_backup_version ]]; then - echo "Unable to determine backup version" - exit 1 + dokku_log_fail "Unable to determine backup version" fi VERSION=$(< $BACKUP_TMP_DIR/.dokku_backup_version) if [[ $VERSION -ne 1 ]]; then - echo "Unknown format version $VERSION" - exit 1 + dokku_log_fail "Unknown format version $VERSION" fi echo "Importing a version $VERSION backup..." @@ -69,8 +67,7 @@ case "$1" in if $force; then echo "-f used. Ignoring warnings." else - echo "Archive did not pass sanity checks. Use -f to import anyway" >&2 - exit 1 + dokku_log_fail "Archive did not pass sanity checks. Use -f to import anyway" fi fi diff --git a/plugins/certs/commands b/plugins/certs/commands index ad1da8b24..3bb1d14e6 100755 --- a/plugins/certs/commands +++ b/plugins/certs/commands @@ -66,7 +66,7 @@ case "$1" in ;; certs:generate) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" verify_app_name "$2" APP="$2"; DOMAIN="$3"; SSL_PATH="$DOKKU_ROOT/$APP/tls" @@ -95,7 +95,7 @@ case "$1" in ;; certs:info) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" verify_app_name "$2" APP="$2"; SSL_TYPE=$(is_ssl_enabled $APP) case "$SSL_TYPE" in @@ -137,7 +137,7 @@ case "$1" in ;; certs:remove) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" verify_app_name "$2" APP="$2"; APP_SSL_PATH="$DOKKU_ROOT/$APP/tls" @@ -157,9 +157,12 @@ case "$1" in help | certs:help) cat && 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 EOF ;; diff --git a/plugins/config/functions b/plugins/config/functions index bfdd610b2..a07d23fbc 100644 --- a/plugins/config/functions +++ b/plugins/config/functions @@ -38,7 +38,7 @@ config_parse_args() { if [[ "$DOKKU_CONFIG_TYPE" = "app" ]]; then if [[ -z $APP ]]; then - echo "Please specify an app to run the command on" >&2 && exit 1 + dokku_log_fail "Please specify an app to run the command on" else verify_app_name "$2" fi @@ -105,7 +105,7 @@ config_all() { is_config_export "$@" && config_export "$DOKKU_CONFIG_TYPE" "$APP" && exit 0 [[ "$APP" ]] && DOKKU_CONFIG_TYPE=$APP - [[ ! -s $ENV_FILE ]] && echo "no config vars for $DOKKU_CONFIG_TYPE" && exit 1 + [[ ! -s $ENV_FILE ]] && dokku_log_fail "no config vars for $DOKKU_CONFIG_TYPE" VARS=$(grep -Eo "export ([a-zA-Z_][a-zA-Z0-9_]*=.*)" $ENV_FILE | cut -d" " -f2-) diff --git a/plugins/domains/commands b/plugins/domains/commands index 399ff15d4..9f4f78a11 100755 --- a/plugins/domains/commands +++ b/plugins/domains/commands @@ -26,7 +26,7 @@ RE_IPV6="${RE_IPV6}\$" case "$1" in domains) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" verify_app_name "$2" APP="$2" @@ -40,7 +40,7 @@ case "$1" in ;; domains:setup) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" verify_app_name "$2" APP="$2"; VHOST_PATH="$DOKKU_ROOT/$APP/VHOST" @@ -73,7 +73,7 @@ case "$1" in ;; domains:add) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" verify_app_name "$2" APP="$2" @@ -103,7 +103,7 @@ case "$1" in ;; domains:clear) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" verify_app_name "$2" APP="$2" @@ -115,7 +115,7 @@ case "$1" in ;; domains:remove) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" verify_app_name "$2" APP="$2" diff --git a/plugins/ps/commands b/plugins/ps/commands index 0acf81ac5..a24b10a58 100755 --- a/plugins/ps/commands +++ b/plugins/ps/commands @@ -5,7 +5,7 @@ source "$(dirname $0)/functions" case "$1" in ps) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" APP="$2"; verify_app_name "$APP"; DOKKU_APP_RUNNING_CONTAINER_IDS=$(get_app_running_container_ids $APP) ! (is_deployed $APP) && echo "App $APP has not been deployed" && exit 0 @@ -17,7 +17,7 @@ case "$1" in ;; ps:start) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP); verify_app_name "$APP" @@ -31,7 +31,7 @@ case "$1" in ;; ps:stop) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" APP="$2"; DOKKU_APP_RUNNING_CONTAINER_IDS=$(get_app_running_container_ids $APP) verify_app_name "$APP" @@ -46,7 +46,7 @@ case "$1" in ;; ps:rebuild) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" APP="$2"; verify_app_name "$APP" pluginhook -p receive-app $APP @@ -63,7 +63,7 @@ case "$1" in ;; ps:restart) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP) verify_app_name "$APP" @@ -83,7 +83,7 @@ case "$1" in ;; ps:scale) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP) verify_app_name "$APP" diff --git a/plugins/tags/commands b/plugins/tags/commands index a77f8bc93..1d8fb3cef 100755 --- a/plugins/tags/commands +++ b/plugins/tags/commands @@ -5,7 +5,7 @@ source "$(dirname $0)/functions" case "$1" in tags) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" APP="$2"; IMAGE_REPO=$(get_app_image_repo $APP) verify_app_name "$APP" @@ -14,7 +14,7 @@ case "$1" in ;; tags:create) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" APP="$2"; IMAGE_TAG="$3"; IMAGE_REPO=$(get_app_image_repo $APP) verify_app_name "$APP" @@ -24,7 +24,7 @@ case "$1" in ;; tags:deploy) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" APP="$2"; IMAGE_TAG="$3" verify_app_name "$APP" @@ -32,7 +32,7 @@ case "$1" in ;; tags:destroy) - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" APP="$2"; IMAGE_TAG="$3"; IMAGE_REPO=$(get_app_image_repo $APP) verify_app_name "$2"