这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 7 additions & 7 deletions contrib/dokku_client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
;;
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
32 changes: 16 additions & 16 deletions contrib/stackscript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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}
Expand All @@ -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}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions plugins/00_dokku-standard/commands
Original file line number Diff line number Diff line change
Expand Up @@ -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; "
Expand Down
4 changes: 2 additions & 2 deletions plugins/20_events/commands
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion plugins/apps/commands
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions plugins/checks/check-deploy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -137,22 +137,22 @@ 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
# Ignore if it's not a URL in a supported format
# 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.
#
Expand All @@ -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
Expand All @@ -191,15 +191,15 @@ do
fi
done

if [ $FAILEDCHECKS -gt 0 ]; then
if [[ $FAILEDCHECKS -gt 0 ]]; then
dokku_log_warn "Check attempt $ATTEMPT/$ATTEMPTS failed."
SUCCESS=0
else
SUCCESS=1
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
Expand Down
18 changes: 9 additions & 9 deletions plugins/common/functions
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ dokku_log_info2() {
}

dokku_log_info1_quiet() {
if [[ -z "$DOKKU_QUIET_OUTPUT" ]];then
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
echo "-----> $@"
else
return 0
fi
}

dokku_log_info2_quiet() {
if [[ -z "$DOKKU_QUIET_OUTPUT" ]];then
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
echo "=====> $@"
else
return 0
Expand All @@ -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
Expand All @@ -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
Expand All @@ -62,15 +62,15 @@ 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
fi
}

dokku_log_verbose_quiet() {
if [[ -z "$DOKKU_QUIET_OUTPUT" ]];then
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
echo " $@"
else
return 0
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading