Follow bashstyle where possible
This commit is contained in:
1 parent
1c53250211
commit
27a2478a33
11 files changed
+44
-44
No files matched your search
+1
-1
@@ -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
|
||||
|
||||
|
||||
+16
-16
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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" " "
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -31,8 +31,7 @@ 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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
+15
-13
@@ -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