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

@@ -31,7 +31,7 @@ which curl > /dev/null || apt-get install -qq -y curl
dokku_install_source() { dokku_install_source() {
apt-get install -qq -y git make software-properties-common apt-get install -qq -y git make software-properties-common
cd /root cd /root
if [ ! -d /root/dokku ]; then if [[ ! -d /root/dokku ]]; then
git clone $DOKKU_REPO /root/dokku git clone $DOKKU_REPO /root/dokku
fi fi

View File

@@ -6,7 +6,7 @@ NAMES=(SEED GRASS FLOWE SHAD CABR SNAKE GOLD COW GUIKI PEDAL DELAN B-FLY BIDE KE
random_number() { random_number() {
[[ -n "$1" ]] && RANGE="$1" [[ -n "$1" ]] && RANGE="$1"
if [[ -n "$RANGE" ]];then if [[ -n "$RANGE" ]]; then
number=$RANDOM number=$RANDOM
let "number %= $RANGE" let "number %= $RANGE"
else else
@@ -58,7 +58,7 @@ if [[ ! -z $DOKKU_HOST ]]; then
true true
;; ;;
apps:destroy) apps:destroy)
if [[ -z "$2" ]] || [[ "$2" == "force" ]];then if [[ -z "$2" ]] || [[ "$2" == "force" ]]; then
donotshift="YES" donotshift="YES"
fi fi
;; ;;
@@ -72,7 +72,7 @@ if [[ ! -z $DOKKU_HOST ]]; then
appname=$(random_name) appname=$(random_name)
counter=0 counter=0
while ssh "dokku@$DOKKU_HOST" apps 2>/dev/null| grep -q "$appname"; do while ssh "dokku@$DOKKU_HOST" apps 2>/dev/null| grep -q "$appname"; do
if [[ $counter -ge 100 ]];then if [[ $counter -ge 100 ]]; then
echo "Error: could not reasonably generate a new app name. try cleaning up some apps..." echo "Error: could not reasonably generate a new app name. try cleaning up some apps..."
ssh "dokku@$DOKKU_HOST" apps ssh "dokku@$DOKKU_HOST" apps
exit 1 exit 1
@@ -102,16 +102,16 @@ if [[ ! -z $DOKKU_HOST ]]; then
if [[ ! "$1" =~ --* ]]; then if [[ ! "$1" =~ --* ]]; then
verb=$1 verb=$1
shift shift
if [[ "$1" == "$appname" ]]; then if [[ "$1" == "$appname" ]]; then
shift shift
fi fi
args="$*" args="$*"
else else
long_args="--" long_args="--"
for arg in "$@";do for arg in "$@"; do
if [[ "$arg" =~ --* ]];then if [[ "$arg" =~ --* ]]; then
long_args+=" $arg" long_args+=" $arg"
args=("${args[@]/$arg}") args=("${args[@]/$arg}")
else else

View File

@@ -3,15 +3,15 @@
# <UDF name="ssh_key" default="" label="Public SSH Key for root user" example="Sets the root user's public ssh key, which is also automatically imported into the dokku installer"> # <UDF name="ssh_key" default="" label="Public SSH Key for root user" example="Sets the root user's public ssh key, which is also automatically imported into the dokku installer">
# <UDF name="notify_email" default="" Label="Send Finish Notification To" example="Email address to send notification to when finished." /> # <UDF name="notify_email" default="" Label="Send Finish Notification To" example="Email address to send notification to when finished." />
function logit { logit() {
# Simple logging function that prepends an easy-to-find marker '=> ' and a timestamp to a message # Simple logging function that prepends an easy-to-find marker '=> ' and a timestamp to a message
TIMESTAMP=$(date -u +'%m/%d %H:%M:%S') TIMESTAMP=$(date -u +'%m/%d %H:%M:%S')
MSG="=> ${TIMESTAMP} $1" MSG="=> ${TIMESTAMP} $1"
echo ${MSG} echo ${MSG}
} }
function set_ssh_key { set_ssh_key() {
if [ -n "${SSH_KEY}" ]; then if [[ -n "${SSH_KEY}" ]]; then
logit "Setting root ssh key" logit "Setting root ssh key"
mkdir -p /root/.ssh mkdir -p /root/.ssh
chmod 700 /root/.ssh chmod 700 /root/.ssh
@@ -21,20 +21,20 @@ function set_ssh_key {
fi fi
} }
function set_passwordless_ssh { set_passwordless_ssh() {
logit "Turn off password authentication and root login for SSH" logit "Turn off password authentication and root login for SSH"
echo 'PasswordAuthentication no' >> /etc/ssh/sshd_config echo 'PasswordAuthentication no' >> /etc/ssh/sshd_config
service ssh restart service ssh restart
} }
function system_primary_ip { system_primary_ip() {
# returns the primary IP assigned to eth0 # returns the primary IP assigned to eth0
ifconfig eth0 | awk -F: '/inet addr:/ {print $2}' | awk '{ print $1 }' ifconfig eth0 | awk -F: '/inet addr:/ {print $2}' | awk '{ print $1 }'
} }
function set_hostname { set_hostname() {
logit "Set up hostname" logit "Set up hostname"
if [ -n "${HOSTNAME}" ]; then if [[ -n "${HOSTNAME}" ]]; then
echo $HOSTNAME > /etc/hostname echo $HOSTNAME > /etc/hostname
echo $IPADDR $FQDN $HOSTNAME >> /etc/hosts echo $IPADDR $FQDN $HOSTNAME >> /etc/hosts
else else
@@ -46,7 +46,7 @@ function set_hostname {
hostname -F /etc/hostname hostname -F /etc/hostname
} }
function postfix_install_loopback_only { postfix_install_loopback_only() {
logit "Installing and configuring Postfix" logit "Installing and configuring Postfix"
# Installs postfix and configure to listen only on the local interface. Also # Installs postfix and configure to listen only on the local interface. Also
# allows for local mail delivery # allows for local mail delivery
@@ -62,8 +62,8 @@ function postfix_install_loopback_only {
touch /tmp/restart-postfix touch /tmp/restart-postfix
} }
function notify_install_via_email { notify_install_via_email() {
if [ -n "${NOTIFY_EMAIL}" ]; then if [[ -n "${NOTIFY_EMAIL}" ]]; then
logit "Sending notification email to ${NOTIFY_EMAIL}" logit "Sending notification email to ${NOTIFY_EMAIL}"
/usr/sbin/sendmail "${NOTIFY_EMAIL}" <<EOD /usr/sbin/sendmail "${NOTIFY_EMAIL}" <<EOD
To: ${NOTIFY_EMAIL} To: ${NOTIFY_EMAIL}
@@ -77,8 +77,8 @@ EOD
fi fi
} }
function notify_restart_via_email { notify_restart_via_email() {
if [ -n "${NOTIFY_EMAIL}" ]; then if [[ -n "${NOTIFY_EMAIL}" ]]; then
logit "Sending notification email to ${NOTIFY_EMAIL} of required restart" logit "Sending notification email to ${NOTIFY_EMAIL} of required restart"
/usr/sbin/sendmail "${NOTIFY_EMAIL}" <<EOD /usr/sbin/sendmail "${NOTIFY_EMAIL}" <<EOD
To: ${NOTIFY_EMAIL} To: ${NOTIFY_EMAIL}
@@ -103,7 +103,7 @@ EOD
fi fi
} }
function setup_linode { setup_linode() {
logit "Installing via linode" logit "Installing via linode"
DEBIAN_FRONTEND=noninteractive apt-get install -qq -y linux-virtual DEBIAN_FRONTEND=noninteractive apt-get install -qq -y linux-virtual
DEBIAN_FRONTEND=noninteractive apt-get purge -qq -y grub2 grub-pc DEBIAN_FRONTEND=noninteractive apt-get purge -qq -y grub2 grub-pc
@@ -133,7 +133,7 @@ EOF
chmod +x /etc/rc.local chmod +x /etc/rc.local
} }
function install_prerequisites { install_prerequisites() {
logit "Installing pre-requisites" logit "Installing pre-requisites"
sudo apt-get update -qq > /dev/null sudo apt-get update -qq > /dev/null
sudo apt-get install -qq -y apt-transport-https curl > /dev/null 2>&1 sudo apt-get install -qq -y apt-transport-https curl > /dev/null 2>&1
@@ -147,7 +147,7 @@ function install_prerequisites {
sudo apt-get update -qq > /dev/null sudo apt-get update -qq > /dev/null
} }
function install_dokku { install_dokku() {
logit "Installing pre-requisites" logit "Installing pre-requisites"
sudo apt-get install -qq -y linux-image-extra-"$(uname -r)" > /dev/null 2>&1 sudo apt-get install -qq -y linux-image-extra-"$(uname -r)" > /dev/null 2>&1
@@ -165,7 +165,7 @@ postfix_install_loopback_only
set_hostname set_hostname
install_prerequisites install_prerequisites
if [ -n "$LINODE_ID" ]; then if [[ -n "$LINODE_ID" ]]; then
setup_linode setup_linode
notify_restart_via_email notify_restart_via_email
else else

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -5,7 +5,7 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
APP="$1"; REV="$2" APP="$1"; REV="$2"
# Don't trigger git build if there is no git repository. # 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 true
else else
dokku git-build $APP $REV 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 if [[ -z "$DOKKU_APP_LISTEN_PORT" ]] && [[ -z "$DOKKU_APP_LISTEN_IP" ]]; then
shopt -s nullglob 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_PORT_FILE=$(echo $DOKKU_APP_IP_FILE | sed -e "s:IP:PORT:g")
DOKKU_APP_LISTENER_IP=$(< $DOKKU_APP_IP_FILE) DOKKU_APP_LISTENER_IP=$(< $DOKKU_APP_IP_FILE)
DOKKU_APP_LISTENER_PORT=$(< $DOKKU_APP_PORT_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 if [[ ! -n "$NO_VHOST" ]] && [[ -f "$DOKKU_ROOT/$APP/VHOST" ]]; then
NONSSL_VHOSTS=$(get_app_domains $APP) 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) 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') [[ -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 echo "upstream $APP { server $DOKKU_APP_LISTEN_IP:$DOKKU_APP_LISTEN_PORT; }" >> $NGINX_CONF
elif [[ -n "$DOKKU_APP_LISTENERS" ]]; then elif [[ -n "$DOKKU_APP_LISTENERS" ]]; then
echo "upstream $APP { " >> $NGINX_CONF echo "upstream $APP { " >> $NGINX_CONF
for listener in $DOKKU_APP_LISTENERS;do for listener in $DOKKU_APP_LISTENERS; do
echo " server $listener;" >> $NGINX_CONF echo " server $listener;" >> $NGINX_CONF
done done
echo "}" >> $NGINX_CONF echo "}" >> $NGINX_CONF

View File

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

View File

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

View File

@@ -25,7 +25,7 @@ case "$1" in
line=$(echo $line | trim) line=$(echo $line | trim)
CMD=$(echo $line | awk '{ print $1 }') CMD=$(echo $line | awk '{ print $1 }')
[ -z $CMD ] && continue [[ -z $CMD ]] && continue
[[ "$line" != "$(fc -ln -1 | trim)" ]] && history -s "$line" [[ "$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" APP="$1"; REV="$2"
# Don't trigger tar build if there is no tarball. # 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 true
else else
dokku tar-build $APP dokku tar-build $APP

View File

@@ -2,7 +2,7 @@
is_number() { is_number() {
local NUMBER=$1; local NUM_RE='^[0-9]+$' local NUMBER=$1; local NUM_RE='^[0-9]+$'
if [[ $NUMBER =~ $NUM_RE ]];then if [[ $NUMBER =~ $NUM_RE ]]; then
return 0 return 0
else else
return 1 return 1

View File

@@ -12,7 +12,7 @@ TEST_APP=my-cool-guy-test-app
# test functions # test functions
flunk() { flunk() {
{ if [ "$#" -eq 0 ]; then cat - { if [[ "$#" -eq 0 ]]; then cat -
else echo "$*" else echo "$*"
fi fi
} }
@@ -20,23 +20,23 @@ flunk() {
} }
assert_success() { assert_success() {
if [ "$status" -ne 0 ]; then if [[ "$status" -ne 0 ]]; then
flunk "command failed with exit status $status" flunk "command failed with exit status $status"
elif [ "$#" -gt 0 ]; then elif [[ "$#" -gt 0 ]]; then
assert_output "$1" assert_output "$1"
fi fi
} }
assert_failure() { assert_failure() {
if [ "$status" -eq 0 ]; then if [[ "$status" -eq 0 ]]; then
flunk "expected failed exit status" flunk "expected failed exit status"
elif [ "$#" -gt 0 ]; then elif [[ "$#" -gt 0 ]]; then
assert_output "$1" assert_output "$1"
fi fi
} }
assert_equal() { assert_equal() {
if [ "$1" != "$2" ]; then if [[ "$1" != "$2" ]]; then
{ echo "expected: $1" { echo "expected: $1"
echo "actual: $2" echo "actual: $2"
} | flunk } | flunk
@@ -45,34 +45,36 @@ assert_equal() {
assert_output() { assert_output() {
local expected local expected
if [ $# -eq 0 ]; then expected="$(cat -)" if [[ $# -eq 0 ]]; then
else expected="$1" expected="$(cat -)"
else
expected="$1"
fi fi
assert_equal "$expected" "$output" assert_equal "$expected" "$output"
} }
assert_line() { assert_line() {
if [ "$1" -ge 0 ] 2>/dev/null; then if [[ "$1" -ge 0 ]] 2>/dev/null; then
assert_equal "$2" "${lines[$1]}" assert_equal "$2" "${lines[$1]}"
else else
local line local line
for line in "${lines[@]}"; do for line in "${lines[@]}"; do
if [ "$line" = "$1" ]; then return 0; fi [[ "$line" = "$1" ]] && return 0
done done
flunk "expected line \`$1'" flunk "expected line \`$1'"
fi fi
} }
refute_line() { refute_line() {
if [ "$1" -ge 0 ] 2>/dev/null; then if [[ "$1" -ge 0 ]] 2>/dev/null; then
local num_lines="${#lines[@]}" local num_lines="${#lines[@]}"
if [ "$1" -lt "$num_lines" ]; then if [[ "$1" -lt "$num_lines" ]]; then
flunk "output has $num_lines lines" flunk "output has $num_lines lines"
fi fi
else else
local line local line
for line in "${lines[@]}"; do for line in "${lines[@]}"; do
if [ "$line" = "$1" ]; then if [[ "$line" = "$1" ]]; then
flunk "expected to not find line \`$line'" flunk "expected to not find line \`$line'"
fi fi
done done