cleanup shellcheck SC2086

This commit is contained in:
Michael Hobbs
2016-02-22 10:16:57 -08:00
committed by Test Robot
parent ff9bb2cbd7
commit d1b87bd7b7
75 changed files with 521 additions and 629 deletions

View File

@@ -47,16 +47,16 @@ if [[ -z "$DOKKU_APP_LISTEN_IP" ]] && [[ -f "$DOKKU_ROOT/$APP/IP" ]]; then
DOKKU_APP_LISTEN_IP=$(< "$DOKKU_ROOT/$APP/IP")
fi
if [[ -z "$DOKKU_APP_CONTAINER_ID" ]]; then
DOKKU_APP_CIDS=( $(get_app_container_ids $APP) )
DOKKU_APP_CIDS=( $(get_app_container_ids "$APP") )
DOKKU_APP_CONTAINER_ID=${DOKKU_APP_CIDS[0]}
fi
# source global and in-app envs to get DOKKU_CHECKS_WAIT and any other necessary vars
eval "$(config_export global)"
eval "$(config_export app $APP)"
eval "$(config_export app "$APP")"
if [[ "$(is_app_checks_enabled $APP)" == "false" ]];then
if [[ "$(is_app_checks_enabled "$APP")" == "false" ]];then
dokku_log_info2_quiet "Zero downtime checks for app ($APP) have been disabled. moving on..."
exit 0
fi
@@ -72,13 +72,13 @@ ATTEMPTS="${DOKKU_CHECKS_ATTEMPTS:-5}"
# docker cp exits with status 1 when run as non-root user when it tries to chown the file
# after successfully copying the file. Thus, we suppress stderr.
# ref: https://github.com/dotcloud/docker/issues/3986
TMPDIR=$(mktemp -d /tmp/CHECKS.XXXXX)
docker cp $DOKKU_APP_CONTAINER_ID:/app/CHECKS $TMPDIR 2> /dev/null || true
TMPDIR=$(mktemp -d /tmp/dokku_CHECKS.XXXXX)
docker cp $DOKKU_APP_CONTAINER_ID:/app/CHECKS "$TMPDIR" 2> /dev/null || true
FILENAME=${TMPDIR}/CHECKS
cleanup() {
rm -rf $TMPDIR
rm -rf "$TMPDIR"
dokku_log_info2_quiet "$APP container output:"
dokku_container_log_verbose_quiet $DOKKU_APP_CONTAINER_ID
dokku_log_info2_quiet "end $APP container output"
@@ -95,12 +95,12 @@ if [[ ! -s "${TMPDIR}/CHECKS" ]] || [[ "$DOKKU_APP_CONTAINER_TYPE" != "web" ]];
dokku_log_verbose "Non web container detected: Running default container check..."
fi
rm -rf $TMPDIR
rm -rf "$TMPDIR"
# simple default check to see if the container stuck around
DOKKU_DEFAULT_CHECKS_WAIT="${DOKKU_DEFAULT_CHECKS_WAIT:-10}"
dokku_log_info1 "Waiting for $DOKKU_DEFAULT_CHECKS_WAIT seconds ..."
sleep $DOKKU_DEFAULT_CHECKS_WAIT
sleep "$DOKKU_DEFAULT_CHECKS_WAIT"
! (is_container_running $DOKKU_APP_CONTAINER_ID) && dokku_log_fail "App container failed to start!!"
container_restarts=$(docker inspect -f "{{ .RestartCount }}" $DOKKU_APP_CONTAINER_ID)
@@ -133,7 +133,7 @@ do
FAILEDCHECKS=0
ATTEMPT=$(( ATTEMPT + 1 ))
dokku_log_info1 "Attempt $ATTEMPT/$ATTEMPTS Waiting for $WAIT seconds ..."
sleep $WAIT
sleep "$WAIT"
# -q do not use .curlrc (must come first)
@@ -190,6 +190,7 @@ do
[[ $DOKKU_TRACE ]] && dokku_log_verbose "$ curl $CURL_ARGS"
# Capture HTTP response or CURL error message
# shellcheck disable=SC2086
if OUTPUT=$(curl -# $CURL_ARGS 2>&1); then
# OUTPUT contains the HTTP response
if [[ ! "$OUTPUT" =~ $EXPECTED ]]; then

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env bash
[[ " checks checks:enable checks:disable help ps:help " == *" $1 "* ]] || exit $DOKKU_NOT_IMPLEMENTED_EXIT
[[ " checks checks:enable checks:disable help ps:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/checks/functions"
@@ -15,7 +15,7 @@ checks_main() {
dokku_col_log_info1_quiet "App Name" "Zero-Downtime Status"
for app in $APPS; do
verify_app_name "$app"
dokku_col_log_msg "$app" "$(is_app_checks_enabled $app)"
dokku_col_log_msg "$app" "$(is_app_checks_enabled "$app")"
done
}
@@ -23,9 +23,10 @@ checks_enable() {
local desc="enable zero-downtime for app"
local APP="$1"; verify_app_name "$APP"
if [[ "$(is_app_checks_enabled $APP)" == "false" ]]; then
if [[ "$(is_app_checks_enabled "$APP")" == "false" ]]; then
dokku_log_info1 "Enabling zero downtime for app ($APP)"
[[ "$2" == "--no-restart" ]] && local CONFIG_SET_ARGS=$2
# shellcheck disable=SC2086
config_set $CONFIG_SET_ARGS $APP DOKKU_CHECKS_ENABLED=1
else
dokku_log_info1 "zero downtime is already enabled for app ($APP)"
@@ -36,9 +37,10 @@ checks_disable() {
local desc="disable zero-downtime for app"
local APP="$1"; verify_app_name "$APP"
if [[ "$(is_app_checks_enabled $APP)" == "true" ]]; then
if [[ "$(is_app_checks_enabled "$APP")" == "true" ]]; then
dokku_log_info1 "Disabling zero downtime for app ($APP)"
[[ "$2" == "--no-restart" ]] && local CONFIG_SET_ARGS=$2
# shellcheck disable=SC2086
config_set $CONFIG_SET_ARGS $APP DOKKU_CHECKS_ENABLED=0
else
dokku_log_info1 "zero downtime is already disable for app ($APP)"
@@ -47,17 +49,17 @@ checks_disable() {
case "$1" in
checks)
checks_main $2
checks_main "$2"
;;
checks:enable)
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
checks_enable $2 --no-restart
checks_enable "$2" --no-restart
;;
checks:disable)
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
checks_disable $2 --no-restart
checks_disable "$2" --no-restart
;;
help | ps:help)
@@ -69,7 +71,7 @@ EOF
;;
*)
exit $DOKKU_NOT_IMPLEMENTED_EXIT
exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
;;
esac

View File

@@ -6,7 +6,7 @@ source "$PLUGIN_AVAILABLE_PATH/config/functions"
is_app_checks_enabled() {
local desc="return app zero-downtime checks status"
local APP="$1"; verify_app_name "$APP"
local DOKKU_CHECKS_ENABLED=$(config_get $APP DOKKU_CHECKS_ENABLED)
local DOKKU_CHECKS_ENABLED=$(config_get "$APP" DOKKU_CHECKS_ENABLED)
if [[ -z "$DOKKU_CHECKS_ENABLED" ]] || [[ "$DOKKU_CHECKS_ENABLED" == "1" ]];then
local status=true

View File

@@ -15,17 +15,17 @@ migrate_checks_vars() {
dokku_log_info2 "Please use dokku checks:[disable|enable] <app> to control zero downtime functionality"
for app in $APPS; do
local APP_SKIP_ALL_CHECKS=$(dokku config:get $app DOKKU_SKIP_ALL_CHECKS || true)
local APP_SKIP_DEFAULT_CHECKS=$(dokku config:get $app DOKKU_SKIP_DEFAULT_CHECKS || true)
local APP_SKIP_ALL_CHECKS=$(dokku config:get "$app" DOKKU_SKIP_ALL_CHECKS || true)
local APP_SKIP_DEFAULT_CHECKS=$(dokku config:get "$app" DOKKU_SKIP_DEFAULT_CHECKS || true)
if [[ "$APP_SKIP_ALL_CHECKS" == "true" ]] || [[ "$APP_SKIP_DEFAULT_CHECKS" == "true" ]] || \
[[ "$GLOBAL_SKIP_ALL_CHECKS" == "true" ]] || [[ "$GLOBAL_SKIP_DEFAULT_CHECKS" == "true" ]]; then
dokku_log_info2 ""
dokku_log_info2 "zero downtime disabled for app ($app)"
config_set --no-restart $app DOKKU_CHECKS_ENABLED=0
config_set --no-restart "$app" DOKKU_CHECKS_ENABLED=0
fi
if [[ -n "$APP_SKIP_ALL_CHECKS" ]] || [[ -n "$APP_SKIP_DEFAULT_CHECKS" ]]; then
config_unset --no-restart $app DOKKU_SKIP_ALL_CHECKS DOKKU_SKIP_DEFAULT_CHECKS
config_unset --no-restart "$app" DOKKU_SKIP_ALL_CHECKS DOKKU_SKIP_DEFAULT_CHECKS
fi
dokku_log_info2 "Migration complete"
dokku_log_info2 ""