Follow bashstyle where possible
This commit is contained in:
@@ -31,7 +31,7 @@ which curl > /dev/null || apt-get install -qq -y curl
|
||||
dokku_install_source() {
|
||||
apt-get install -qq -y git make software-properties-common
|
||||
cd /root
|
||||
if [ ! -d /root/dokku ]; then
|
||||
if [[ ! -d /root/dokku ]]; then
|
||||
git clone $DOKKU_REPO /root/dokku
|
||||
fi
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ NAMES=(SEED GRASS FLOWE SHAD CABR SNAKE GOLD COW GUIKI PEDAL DELAN B-FLY BIDE KE
|
||||
|
||||
random_number() {
|
||||
[[ -n "$1" ]] && RANGE="$1"
|
||||
if [[ -n "$RANGE" ]];then
|
||||
if [[ -n "$RANGE" ]]; then
|
||||
number=$RANDOM
|
||||
let "number %= $RANGE"
|
||||
else
|
||||
@@ -58,7 +58,7 @@ if [[ ! -z $DOKKU_HOST ]]; then
|
||||
true
|
||||
;;
|
||||
apps:destroy)
|
||||
if [[ -z "$2" ]] || [[ "$2" == "force" ]];then
|
||||
if [[ -z "$2" ]] || [[ "$2" == "force" ]]; then
|
||||
donotshift="YES"
|
||||
fi
|
||||
;;
|
||||
@@ -72,7 +72,7 @@ if [[ ! -z $DOKKU_HOST ]]; then
|
||||
appname=$(random_name)
|
||||
counter=0
|
||||
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..."
|
||||
ssh "dokku@$DOKKU_HOST" apps
|
||||
exit 1
|
||||
@@ -102,16 +102,16 @@ if [[ ! -z $DOKKU_HOST ]]; then
|
||||
if [[ ! "$1" =~ --* ]]; then
|
||||
verb=$1
|
||||
shift
|
||||
|
||||
|
||||
if [[ "$1" == "$appname" ]]; then
|
||||
shift
|
||||
fi
|
||||
|
||||
|
||||
args="$*"
|
||||
else
|
||||
long_args="--"
|
||||
for arg in "$@";do
|
||||
if [[ "$arg" =~ --* ]];then
|
||||
for arg in "$@"; do
|
||||
if [[ "$arg" =~ --* ]]; then
|
||||
long_args+=" $arg"
|
||||
args=("${args[@]/$arg}")
|
||||
else
|
||||
|
||||
@@ -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="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
|
||||
TIMESTAMP=$(date -u +'%m/%d %H:%M:%S')
|
||||
MSG="=> ${TIMESTAMP} $1"
|
||||
echo ${MSG}
|
||||
}
|
||||
|
||||
function set_ssh_key {
|
||||
if [ -n "${SSH_KEY}" ]; then
|
||||
set_ssh_key() {
|
||||
if [[ -n "${SSH_KEY}" ]]; then
|
||||
logit "Setting root ssh key"
|
||||
mkdir -p /root/.ssh
|
||||
chmod 700 /root/.ssh
|
||||
@@ -21,20 +21,20 @@ function set_ssh_key {
|
||||
fi
|
||||
}
|
||||
|
||||
function set_passwordless_ssh {
|
||||
set_passwordless_ssh() {
|
||||
logit "Turn off password authentication and root login for SSH"
|
||||
echo 'PasswordAuthentication no' >> /etc/ssh/sshd_config
|
||||
service ssh restart
|
||||
}
|
||||
|
||||
function system_primary_ip {
|
||||
system_primary_ip() {
|
||||
# returns the primary IP assigned to eth0
|
||||
ifconfig eth0 | awk -F: '/inet addr:/ {print $2}' | awk '{ print $1 }'
|
||||
}
|
||||
|
||||
function set_hostname {
|
||||
set_hostname() {
|
||||
logit "Set up hostname"
|
||||
if [ -n "${HOSTNAME}" ]; then
|
||||
if [[ -n "${HOSTNAME}" ]]; then
|
||||
echo $HOSTNAME > /etc/hostname
|
||||
echo $IPADDR $FQDN $HOSTNAME >> /etc/hosts
|
||||
else
|
||||
@@ -46,7 +46,7 @@ function set_hostname {
|
||||
hostname -F /etc/hostname
|
||||
}
|
||||
|
||||
function postfix_install_loopback_only {
|
||||
postfix_install_loopback_only() {
|
||||
logit "Installing and configuring Postfix"
|
||||
# Installs postfix and configure to listen only on the local interface. Also
|
||||
# allows for local mail delivery
|
||||
@@ -62,8 +62,8 @@ function postfix_install_loopback_only {
|
||||
touch /tmp/restart-postfix
|
||||
}
|
||||
|
||||
function notify_install_via_email {
|
||||
if [ -n "${NOTIFY_EMAIL}" ]; then
|
||||
notify_install_via_email() {
|
||||
if [[ -n "${NOTIFY_EMAIL}" ]]; then
|
||||
logit "Sending notification email to ${NOTIFY_EMAIL}"
|
||||
/usr/sbin/sendmail "${NOTIFY_EMAIL}" <<EOD
|
||||
To: ${NOTIFY_EMAIL}
|
||||
@@ -77,8 +77,8 @@ EOD
|
||||
fi
|
||||
}
|
||||
|
||||
function notify_restart_via_email {
|
||||
if [ -n "${NOTIFY_EMAIL}" ]; then
|
||||
notify_restart_via_email() {
|
||||
if [[ -n "${NOTIFY_EMAIL}" ]]; then
|
||||
logit "Sending notification email to ${NOTIFY_EMAIL} of required restart"
|
||||
/usr/sbin/sendmail "${NOTIFY_EMAIL}" <<EOD
|
||||
To: ${NOTIFY_EMAIL}
|
||||
@@ -103,7 +103,7 @@ EOD
|
||||
fi
|
||||
}
|
||||
|
||||
function setup_linode {
|
||||
setup_linode() {
|
||||
logit "Installing via linode"
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -qq -y linux-virtual
|
||||
DEBIAN_FRONTEND=noninteractive apt-get purge -qq -y grub2 grub-pc
|
||||
@@ -133,7 +133,7 @@ EOF
|
||||
chmod +x /etc/rc.local
|
||||
}
|
||||
|
||||
function install_prerequisites {
|
||||
install_prerequisites() {
|
||||
logit "Installing pre-requisites"
|
||||
sudo apt-get update -qq > /dev/null
|
||||
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
|
||||
}
|
||||
|
||||
function install_dokku {
|
||||
install_dokku() {
|
||||
logit "Installing pre-requisites"
|
||||
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
|
||||
install_prerequisites
|
||||
|
||||
if [ -n "$LINODE_ID" ]; then
|
||||
if [[ -n "$LINODE_ID" ]]; then
|
||||
setup_linode
|
||||
notify_restart_via_email
|
||||
else
|
||||
|
||||
@@ -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; "
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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" " "
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
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
|
||||
|
||||
@@ -12,7 +12,7 @@ TEST_APP=my-cool-guy-test-app
|
||||
|
||||
# test functions
|
||||
flunk() {
|
||||
{ if [ "$#" -eq 0 ]; then cat -
|
||||
{ if [[ "$#" -eq 0 ]]; then cat -
|
||||
else echo "$*"
|
||||
fi
|
||||
}
|
||||
@@ -20,23 +20,23 @@ flunk() {
|
||||
}
|
||||
|
||||
assert_success() {
|
||||
if [ "$status" -ne 0 ]; then
|
||||
if [[ "$status" -ne 0 ]]; then
|
||||
flunk "command failed with exit status $status"
|
||||
elif [ "$#" -gt 0 ]; then
|
||||
elif [[ "$#" -gt 0 ]]; then
|
||||
assert_output "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
assert_failure() {
|
||||
if [ "$status" -eq 0 ]; then
|
||||
if [[ "$status" -eq 0 ]]; then
|
||||
flunk "expected failed exit status"
|
||||
elif [ "$#" -gt 0 ]; then
|
||||
elif [[ "$#" -gt 0 ]]; then
|
||||
assert_output "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
assert_equal() {
|
||||
if [ "$1" != "$2" ]; then
|
||||
if [[ "$1" != "$2" ]]; then
|
||||
{ echo "expected: $1"
|
||||
echo "actual: $2"
|
||||
} | flunk
|
||||
@@ -45,34 +45,36 @@ assert_equal() {
|
||||
|
||||
assert_output() {
|
||||
local expected
|
||||
if [ $# -eq 0 ]; then expected="$(cat -)"
|
||||
else expected="$1"
|
||||
if [[ $# -eq 0 ]]; then
|
||||
expected="$(cat -)"
|
||||
else
|
||||
expected="$1"
|
||||
fi
|
||||
assert_equal "$expected" "$output"
|
||||
}
|
||||
|
||||
assert_line() {
|
||||
if [ "$1" -ge 0 ] 2>/dev/null; then
|
||||
if [[ "$1" -ge 0 ]] 2>/dev/null; then
|
||||
assert_equal "$2" "${lines[$1]}"
|
||||
else
|
||||
local line
|
||||
for line in "${lines[@]}"; do
|
||||
if [ "$line" = "$1" ]; then return 0; fi
|
||||
[[ "$line" = "$1" ]] && return 0
|
||||
done
|
||||
flunk "expected line \`$1'"
|
||||
fi
|
||||
}
|
||||
|
||||
refute_line() {
|
||||
if [ "$1" -ge 0 ] 2>/dev/null; then
|
||||
if [[ "$1" -ge 0 ]] 2>/dev/null; then
|
||||
local num_lines="${#lines[@]}"
|
||||
if [ "$1" -lt "$num_lines" ]; then
|
||||
if [[ "$1" -lt "$num_lines" ]]; then
|
||||
flunk "output has $num_lines lines"
|
||||
fi
|
||||
else
|
||||
local line
|
||||
for line in "${lines[@]}"; do
|
||||
if [ "$line" = "$1" ]; then
|
||||
if [[ "$line" = "$1" ]]; then
|
||||
flunk "expected to not find line \`$line'"
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user