Follow bashstyle where possible

This commit is contained in:
Jose Diaz-Gonzalez
2015-09-14 21:20:35 -07:00
parent 1c53250211
commit 27a2478a33
20 changed files with 89 additions and 89 deletions

View File

@@ -137,8 +137,8 @@ case "$1" in
else
DOKKU_LOGS_ARGS="--tail 100"
fi
for CID in "${CONTAINER_IDS[@]}";do
if [[ "$CID" != "$LAST_CONTAINER_ID" ]];then
for CID in "${CONTAINER_IDS[@]}"; do
if [[ "$CID" != "$LAST_CONTAINER_ID" ]]; then
DOKKU_LOGS_CMD+="docker logs $DOKKU_LOGS_ARGS $CID& "
else
DOKKU_LOGS_CMD+="docker logs $DOKKU_LOGS_ARGS $CID; "

View File

@@ -6,7 +6,7 @@ PLUGIN_DIR="$(dirname $0)"
case "$1" in
events)
if [[ -f $DOKKU_EVENTS_LOGFILE ]] ; then
if [[ -f $DOKKU_EVENTS_LOGFILE ]]; then
if [[ $2 == "-t" ]]; then
tail -f $DOKKU_EVENTS_LOGFILE
else
@@ -30,7 +30,7 @@ case "$1" in
if [[ "$DOKKU_EVENTS" ]]; then
logged="$(find $PLUGIN_DIR -type l -printf '%f ' | sort)"
dokku_col_log_info2_quiet "Events currently logged"
for hook in $logged ; do
for hook in $logged; do
dokku_col_log_msg "$hook"
done
else

View File

@@ -41,7 +41,7 @@ case "$1" in
plugn trigger pre-delete $APP $IMAGE_TAG
DOKKU_APP_CIDS=$(get_app_container_ids $APP)
if [[ -n $DOKKU_APP_CIDS ]]; then
for ID in $DOKKU_APP_CIDS;do
for ID in $DOKKU_APP_CIDS; do
docker stop $ID > /dev/null || true
docker rm $ID > /dev/null || true
done

View File

@@ -102,13 +102,13 @@ fi
# Reads name/value pairs, sets the WAIT and TIMEOUT variables
exec < "$FILENAME"
while read LINE ; do
while read LINE; do
# Name/value pair
if [[ "$LINE" =~ ^.+= ]] ; then
if [[ "$LINE" =~ ^.+= ]]; then
TRIM=${LINE%#*}
NAME=${TRIM%=*}
VALUE=${TRIM#*=}
[[ "$NAME" = "WAIT" ]] && WAIT=$VALUE
[[ "$NAME" = "WAIT" ]] && WAIT=$VALUE
[[ "$NAME" = "TIMEOUT" ]] && TIMEOUT=$VALUE
[[ "$NAME" = "ATTEMPTS" ]] && ATTEMPTS=$VALUE
fi
@@ -137,7 +137,7 @@ do
fi
exec < "$FILENAME"
while read CHECK_URL EXPECTED ; do
while read CHECK_URL EXPECTED; do
# Ignore empty lines and lines starting with #
# shellcheck disable=SC1001
[[ -z "$CHECK_URL" || "$CHECK_URL" =~ ^\# ]] && continue
@@ -145,14 +145,14 @@ do
# shellcheck disable=SC1001
! [[ "$CHECK_URL" =~ ^(http(s)?:)?\/.* ]] && continue
if [[ "$CHECK_URL" =~ ^https?: ]] ; then
if [[ "$CHECK_URL" =~ ^https?: ]]; then
URL_PROTOCOL=${CHECK_URL%:*}
CHECK_URL=${CHECK_URL#*:}
else
URL_PROTOCOL="http"
fi
if [[ "$CHECK_URL" =~ ^//.+ ]] ; then
if [[ "$CHECK_URL" =~ ^//.+ ]]; then
# To test a URL with specific host name, we still make request to localhost,
# but we set Host header to $SEND_HOST.
#
@@ -178,9 +178,9 @@ do
[[ $DOKKU_TRACE ]] && dokku_log_verbose "$ curl $CURL_ARGS"
# Capture HTTP response or CURL error message
if OUTPUT=$(curl -# $CURL_ARGS 2>&1) ; then
if OUTPUT=$(curl -# $CURL_ARGS 2>&1); then
# OUTPUT contains the HTTP response
if [[ ! "$OUTPUT" =~ $EXPECTED ]] ; then
if [[ ! "$OUTPUT" =~ $EXPECTED ]]; then
dokku_log_warn "$LOG_URL: expected to but did not find: \"$EXPECTED\""
FAILEDCHECKS=$(( FAILEDCHECKS + 1 ))
fi
@@ -191,7 +191,7 @@ do
fi
done
if [ $FAILEDCHECKS -gt 0 ]; then
if [[ $FAILEDCHECKS -gt 0 ]]; then
dokku_log_warn "Check attempt $ATTEMPT/$ATTEMPTS failed."
SUCCESS=0
else
@@ -199,7 +199,7 @@ do
fi
done
if [ $FAILEDCHECKS -gt 0 ]; then
if [[ $FAILEDCHECKS -gt 0 ]]; then
dokku_log_fail "Could not start due to $FAILEDCHECKS failed checks."
exit 1
fi

View File

@@ -18,7 +18,7 @@ dokku_log_info2() {
}
dokku_log_info1_quiet() {
if [[ -z "$DOKKU_QUIET_OUTPUT" ]];then
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
echo "-----> $@"
else
return 0
@@ -26,7 +26,7 @@ dokku_log_info1_quiet() {
}
dokku_log_info2_quiet() {
if [[ -z "$DOKKU_QUIET_OUTPUT" ]];then
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
echo "=====> $@"
else
return 0
@@ -38,7 +38,7 @@ dokku_col_log_info1() {
}
dokku_col_log_info1_quiet() {
if [[ -z "$DOKKU_QUIET_OUTPUT" ]];then
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
printf "%-25s %-25s %-25s %-25s\n" "-----> $@"
else
return 0
@@ -50,7 +50,7 @@ dokku_col_log_info2() {
}
dokku_col_log_info2_quiet() {
if [[ -z "$DOKKU_QUIET_OUTPUT" ]];then
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
printf "%-25s %-25s %-25s %-25s\n" "=====> $@"
else
return 0
@@ -62,7 +62,7 @@ dokku_col_log_msg() {
}
dokku_col_log_msg_quiet() {
if [[ -z "$DOKKU_QUIET_OUTPUT" ]];then
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
printf "%-25s %-25s %-25s %-25s\n" "$@"
else
return 0
@@ -70,7 +70,7 @@ dokku_col_log_msg_quiet() {
}
dokku_log_verbose_quiet() {
if [[ -z "$DOKKU_QUIET_OUTPUT" ]];then
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
echo " $@"
else
return 0
@@ -170,7 +170,7 @@ is_image_herokuish_based() {
is_number() {
local NUMBER=$1; local NUM_RE='^[0-9]+$'
if [[ $NUMBER =~ $NUM_RE ]];then
if [[ $NUMBER =~ $NUM_RE ]]; then
return 0
else
return 1
@@ -247,7 +247,7 @@ get_app_running_container_ids() {
! (is_deployed $APP) && dokku_log_fail "App $APP has not been deployed"
local CIDS=$(get_app_container_ids $APP)
for CID in $CIDS;do
for CID in $CIDS; do
local APP_CONTAINER_STATUS=$(docker inspect -f '{{.State.Running}}' "$CID" || true)
[[ "$APP_CONTAINER_STATUS" == "true" ]] && local APP_RUNNING_CONTAINER_IDS+="$CID "
done
@@ -257,7 +257,7 @@ get_app_running_container_ids() {
is_deployed() {
local APP="$1"
if [[ -f "$DOKKU_ROOT/$APP/CONTAINER" ]] || [[ $(ls $DOKKU_ROOT/$APP/CONTAINER.* &> /dev/null; echo $?) -eq 0 ]];then
if [[ -f "$DOKKU_ROOT/$APP/CONTAINER" ]] || [[ $(ls $DOKKU_ROOT/$APP/CONTAINER.* &> /dev/null; echo $?) -eq 0 ]]; then
return 0
else
return 1

View File

@@ -48,7 +48,7 @@ config_parse_args() {
config_create () {
local ENV_FILE=$1
[ -f $ENV_FILE ] || touch $ENV_FILE
[[ -f $ENV_FILE ]] || touch $ENV_FILE
}
config_styled_hash () {
@@ -58,7 +58,7 @@ config_styled_hash () {
while read -r word; do
KEY=$(echo $word | cut -d"=" -f1)
if [ ${#KEY} -gt ${#longest} ]; then
if [[ ${#KEY} -gt ${#longest} ]]; then
longest=$KEY
fi
done <<< "$vars"
@@ -69,7 +69,7 @@ config_styled_hash () {
num_zeros=$((${#longest} - ${#KEY}))
zeros=" "
while [ $num_zeros -gt 0 ]; do
while [[ $num_zeros -gt 0 ]]; do
zeros="$zeros "
num_zeros=$((num_zeros - 1))
done
@@ -131,7 +131,7 @@ config_get() {
fi
config_create "$ENV_FILE"
if [[ ! -s $ENV_FILE ]] ; then
if [[ ! -s $ENV_FILE ]]; then
exit 0
fi
@@ -181,7 +181,7 @@ ${var}"
done
ENV_ADD=$(echo "$ENV_ADD" | tail -n +2) #remove first empty line
if [ $RESTART_APP ]; then
if [[ $RESTART_APP ]]; then
dokku_log_info1 "Setting config vars"
config_styled_hash "$ENV_ADD" " "

View File

@@ -55,7 +55,7 @@ display_phase_options() {
display_all_phases_options() {
for phase in "${PHASES[@]}"; do
get_phase_file_path $phase
if [[ -s $phase_file_path ]] ; then
if [[ -s $phase_file_path ]]; then
display_phase_options $phase $phase_file_path
fi
done
@@ -66,7 +66,7 @@ display_passed_phases_options() {
local phase
for phase in "${passed_phases[@]}"; do
get_phase_file_path $phase
if [ ! -s $phase_file_path ] ; then
if [[ ! -s $phase_file_path ]]; then
echo "${phase^} options: none"
else
display_phase_options $phase $phase_file_path

View File

@@ -45,12 +45,12 @@ case "$1" in
APP="$2"; VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
if [[ ! -f $VHOST_PATH ]]; then
if [[ -f "$DOKKU_ROOT/VHOST" ]];then
if [[ -f "$DOKKU_ROOT/VHOST" ]]; then
VHOST=$(< "$DOKKU_ROOT/VHOST")
else
VHOST=$(< "$DOKKU_ROOT/HOSTNAME")
fi
if [[ "$VHOST" =~ $RE_IPV4 ]] || [[ "$VHOST" =~ $RE_IPV6 ]];then
if [[ "$VHOST" =~ $RE_IPV4 ]] || [[ "$VHOST" =~ $RE_IPV6 ]]; then
dokku_log_info2 "unsupported vhost config found. disabling vhost support"
config_set --no-restart $APP NO_VHOST=1
else
@@ -90,13 +90,13 @@ case "$1" in
shift 2
dokku domains:setup $APP
for DOMAIN in "$@";do
for DOMAIN in "$@"; do
echo "$DOMAIN" >> "$DOKKU_ROOT/$APP/VHOST"
done
# we need to restart the app to make sure we're binding to the appropriate network interface
dokku nginx:build-config $APP
plugn trigger post-domains-update $APP
for DOMAIN in "$@";do
for DOMAIN in "$@"; do
dokku_log_info1 "Added $DOMAIN to $APP"
done
@@ -127,11 +127,11 @@ case "$1" in
shift 2
dokku domains:setup $APP
for DOMAIN in "$@";do
for DOMAIN in "$@"; do
sed -i "/^$DOMAIN$/d" "$DOKKU_ROOT/$APP/VHOST"
done
plugn trigger post-domains-update $APP
for DOMAIN in "$@";do
for DOMAIN in "$@"; do
dokku_log_info1 "Removed $DOMAIN from $APP"
done

View File

@@ -31,11 +31,10 @@ case "$1" in
git-hook)
APP=$2
while read oldrev newrev refname
do
while read oldrev newrev refname; do
# Only run this script for the master branch. You can remove this
# if block if you wish to run it for others as well.
if [[ $refname = "refs/heads/master" ]] ; then
if [[ $refname = "refs/heads/master" ]]; then
# broken out into plugin so we might support other methods to receive an app
plugn trigger receive-app $APP $newrev
else
@@ -67,7 +66,7 @@ case "$1" in
git-build-locked)
APP="$2"
if [[ $# -ge 3 ]];then
if [[ $# -ge 3 ]]; then
REF="$3"
else
REF=$(< "$DOKKU_ROOT/$APP/refs/heads/master")

View File

@@ -5,7 +5,7 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
APP="$1"; REV="$2"
# Don't trigger git build if there is no git repository.
if [ ! -d "$DOKKU_ROOT/$APP/refs" ]; then
if [[ ! -d "$DOKKU_ROOT/$APP/refs" ]]; then
true
else
dokku git-build $APP $REV

View File

@@ -40,7 +40,7 @@ case "$1" in
if [[ -z "$DOKKU_APP_LISTEN_PORT" ]] && [[ -z "$DOKKU_APP_LISTEN_IP" ]]; then
shopt -s nullglob
for DOKKU_APP_IP_FILE in $DOKKU_ROOT/$APP/IP.web.*;do
for DOKKU_APP_IP_FILE in $DOKKU_ROOT/$APP/IP.web.*; do
DOKKU_APP_PORT_FILE=$(echo $DOKKU_APP_IP_FILE | sed -e "s:IP:PORT:g")
DOKKU_APP_LISTENER_IP=$(< $DOKKU_APP_IP_FILE)
DOKKU_APP_LISTENER_PORT=$(< $DOKKU_APP_PORT_FILE)
@@ -61,7 +61,7 @@ case "$1" in
if [[ ! -n "$NO_VHOST" ]] && [[ -f "$DOKKU_ROOT/$APP/VHOST" ]]; then
NONSSL_VHOSTS=$(get_app_domains $APP)
if [[ -n "$(is_ssl_enabled $APP)" ]];then
if [[ -n "$(is_ssl_enabled $APP)" ]]; then
SSL_HOSTNAME=$(get_ssl_hostnames $APP)
[[ -n "$SSL_HOSTNAME" ]] && SSL_HOSTNAME_REGEX=$(echo "$SSL_HOSTNAME" | xargs | sed 's|\.|\\.|g' | sed 's/\*/\[^\.\]\*/g' | sed 's/ /|/g')
@@ -123,7 +123,7 @@ EOF
echo "upstream $APP { server $DOKKU_APP_LISTEN_IP:$DOKKU_APP_LISTEN_PORT; }" >> $NGINX_CONF
elif [[ -n "$DOKKU_APP_LISTENERS" ]]; then
echo "upstream $APP { " >> $NGINX_CONF
for listener in $DOKKU_APP_LISTENERS;do
for listener in $DOKKU_APP_LISTENERS; do
echo " server $listener;" >> $NGINX_CONF
done
echo "}" >> $NGINX_CONF

View File

@@ -91,7 +91,7 @@ case "$1" in
shift 2
generate_scale_file "$APP" "$IMAGE_TAG"
if [[ -z "$@" ]];then
if [[ -z "$@" ]]; then
dokku_log_info1 "Scaling for $APP"
dokku_log_info2 "$(< $DOKKU_SCALE_FILE)"
else

View File

@@ -4,8 +4,7 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
print_dokku_scale_file() {
local APP="$1"; local DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
while read line || [ -n "$line" ]
do
while read line || [[ -n "$line" ]]; do
dokku_log_info2_quiet "$line"
done < "$DOKKU_SCALE_FILE"
}
@@ -36,7 +35,7 @@ set_scale() {
PROC_COUNT=${procscale#*=}
is_number $PROC_COUNT || dokku_log_fail "ps:scale $PROC_COUNT is not a number"
dokku_log_info1_quiet "Scaling $APP:$PROC_NAME to $PROC_COUNT"
if (egrep -q ^${PROC_NAME}= $DOKKU_SCALE_FILE > /dev/null 2>&1);then
if (egrep -q ^${PROC_NAME}= $DOKKU_SCALE_FILE > /dev/null 2>&1); then
sed --in-place "s:^${PROC_NAME}=.*:$PROC_NAME=$PROC_COUNT:g" $DOKKU_SCALE_FILE
else
echo "$PROC_NAME=$PROC_COUNT" >> $DOKKU_SCALE_FILE

View File

@@ -25,7 +25,7 @@ case "$1" in
line=$(echo $line | trim)
CMD=$(echo $line | awk '{ print $1 }')
[ -z $CMD ] && continue
[[ -z $CMD ]] && continue
[[ "$line" != "$(fc -ln -1 | trim)" ]] && history -s "$line"

View File

@@ -5,7 +5,7 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
APP="$1"; REV="$2"
# Don't trigger tar build if there is no tarball.
if [ ! -f "$DOKKU_ROOT/$APP/src.tar" ]; then
if [[ ! -f "$DOKKU_ROOT/$APP/src.tar" ]]; then
true
else
dokku tar-build $APP