Skip to content

Commit

Permalink
Use 2 spaces for formatting bash
Browse files Browse the repository at this point in the history
Also remove extra trailing newlines
  • Loading branch information
josegonzalez committed Nov 16, 2014
1 parent f13c103 commit 7b361e5
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 68 deletions.
1 change: 0 additions & 1 deletion plugins/00_dokku-standard/backup-check
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ for app in $APPS; do
done

exit $ret

8 changes: 4 additions & 4 deletions plugins/00_dokku-standard/backup-import
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ TARGET_DIR="$3"

[[ -f $IMPORT_DIR/.sshcommand ]] && mv $IMPORT_DIR/.sshcommand $TARGET_DIR/.sshcommand
if [[ -f $IMPORT_DIR/.ssh/authorized_keys ]]; then
mkdir -p $TARGET_DIR/.ssh
cat $IMPORT_DIR/.ssh/authorized_keys $TARGET_DIR/.ssh/authorized_keys | uniq > $TARGET_DIR/.ssh/authorized_keys
chmod 0700 $TARGET_DIR/.ssh
chmod 0600 $TARGET_DIR/.ssh/*
mkdir -p $TARGET_DIR/.ssh
cat $IMPORT_DIR/.ssh/authorized_keys $TARGET_DIR/.ssh/authorized_keys | uniq > $TARGET_DIR/.ssh/authorized_keys
chmod 0700 $TARGET_DIR/.ssh
chmod 0600 $TARGET_DIR/.ssh/*
fi
[[ -f $IMPORT_DIR/HOSTNAME ]] && mv $IMPORT_DIR/HOSTNAME $TARGET_DIR/HOSTNAME
[[ -f $IMPORT_DIR/VHOST ]] && mv $IMPORT_DIR/VHOST $TARGET_DIR/VHOST
13 changes: 6 additions & 7 deletions plugins/00_dokku-standard/commands
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ case "$1" in

run)
if [[ -z $2 ]]; then
echo "Please specify an app to run the command on"
exit 1
echo "Please specify an app to run the command on"
exit 1
fi
APP="$2"; IMAGE="dokku/$APP"
if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then
echo "App $APP does not exist"
exit 1
echo "App $APP does not exist"
exit 1
fi
shift 2

Expand All @@ -48,8 +48,8 @@ case "$1" in
url)
APP="$2";
if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then
echo "App $APP does not exist"
exit 1
echo "App $APP does not exist"
exit 1
fi

if [[ -f "$DOKKU_ROOT/$APP/URL" ]]; then
Expand All @@ -74,4 +74,3 @@ EOF
;;

esac

2 changes: 1 addition & 1 deletion plugins/00_dokku-standard/install
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x

if [[ ! -f "$DOKKU_ROOT/HOSTNAME" ]]; then
echo $(hostname -f) > $DOKKU_ROOT/HOSTNAME
echo $(hostname -f) > $DOKKU_ROOT/HOSTNAME
fi

# temporary hack for https://github.com/progrium/dokku/issues/82
Expand Down
1 change: 0 additions & 1 deletion plugins/apps/commands
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,3 @@ EOF
;;

esac

16 changes: 8 additions & 8 deletions plugins/backup/commands
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x

CURRENT_BACKUP_VERSION=1
set -e; case "$1" in

case "$1" in
backup:export)
OUTPUT_FILE="$2"
BACKUP_DIR="$DOKKU_ROOT"
Expand All @@ -25,9 +26,9 @@ set -e; case "$1" in

# if no file specified, output to stdout
if [[ -z $OUTPUT_FILE ]]; then
cat $BACKUP_TMP_FILE
cat $BACKUP_TMP_FILE
else
mv $BACKUP_TMP_FILE $OUTPUT_FILE
mv $BACKUP_TMP_FILE $OUTPUT_FILE
fi

rm -rf $BACKUP_TMP_DIR
Expand All @@ -49,14 +50,14 @@ set -e; case "$1" in
tar xf $INPUT_FILE --directory=$BACKUP_TMP_DIR

if [[ ! -f $BACKUP_TMP_DIR/.dokku_backup_version ]]; then
echo "Unable to determine backup version"
exit 1
echo "Unable to determine backup version"
exit 1
fi

VERSION=$(< $BACKUP_TMP_DIR/.dokku_backup_version)
if [[ $VERSION -ne 1 ]]; then
echo "Unknown format version $VERSION"
exit 1
echo "Unknown format version $VERSION"
exit 1
fi

echo "Importing a version $VERSION backup..."
Expand Down Expand Up @@ -92,4 +93,3 @@ EOF
;;

esac

32 changes: 16 additions & 16 deletions plugins/checks/check-deploy
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ WAIT="${DOKKU_CHECKS_WAIT:-5}"
# after successfully copying the file. Thus, we suppress stderr.
# ref: https://github.com/dotcloud/docker/issues/3986
if [[ ! -f "$FILENAME" ]] ; then
echo " check-deploy: $FILENAME not found. attempting to retrieve it from container ..."
TMPDIR=$(mktemp -d /tmp/CHECKS.XXXXX)
docker cp $CONTAINERID:/app/CHECKS $TMPDIR 2> /dev/null || true
if [[ ! -s "${TMPDIR}/CHECKS" ]] ; then
echo " CHECKS file not found in container. skipping checks."
rm -rf $TMPDIR
exit 0
else
echo " CHECKS file found in container"
FILENAME=${TMPDIR}/CHECKS
echo " check-deploy: $FILENAME not found. attempting to retrieve it from container ..."
TMPDIR=$(mktemp -d /tmp/CHECKS.XXXXX)
docker cp $CONTAINERID:/app/CHECKS $TMPDIR 2> /dev/null || true
if [[ ! -s "${TMPDIR}/CHECKS" ]] ; then
echo " CHECKS file not found in container. skipping checks."
rm -rf $TMPDIR
exit 0
else
echo " CHECKS file found in container"
FILENAME=${TMPDIR}/CHECKS

function cleanup() {
echo " removing CHECKS file copied from container"
rm -rf $TMPDIR
}
trap cleanup EXIT
fi
function cleanup() {
echo " removing CHECKS file copied from container"
rm -rf $TMPDIR
}
trap cleanup EXIT
fi
fi

echo "Waiting $WAIT seconds ..."
Expand Down
2 changes: 1 addition & 1 deletion plugins/config/backup-import
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ TARGET_DIR="$3"

cd $IMPORT_DIR
for file in */ENV; do
cp $file "$TARGET_DIR/$file"
cp $file "$TARGET_DIR/$file"
done
2 changes: 0 additions & 2 deletions plugins/config/commands
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ config_write() {
}

case "$1" in

config)
APP="$2"

Expand Down Expand Up @@ -186,4 +185,3 @@ EOF
;;

esac

12 changes: 6 additions & 6 deletions plugins/git/backup-import
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ IMPORT_DIR="$2"
TARGET_DIR="$3"
APPS="$4"

while read APP; do
APP_PATH="$TARGET_DIR/$APP";
git init --bare $APP_PATH > /dev/null
PRERECEIVE_HOOK="$APP_PATH/hooks/pre-receive"
cat > $PRERECEIVE_HOOK <<EOF
while read APP; do
APP_PATH="$TARGET_DIR/$APP";
git init --bare $APP_PATH > /dev/null
PRERECEIVE_HOOK="$APP_PATH/hooks/pre-receive"
cat > $PRERECEIVE_HOOK <<EOF
#!/usr/bin/env bash
set -e; set -o pipefail;
cat | DOKKU_ROOT="$DOKKU_ROOT" dokku git-hook $APP
EOF
chmod +x $PRERECEIVE_HOOK
chmod +x $PRERECEIVE_HOOK
done < $APPS > /dev/null
37 changes: 18 additions & 19 deletions plugins/git/commands
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x

git_archive_all() {
APP=$1; REV=$2
TMP_WORK_DIR=$(mktemp -d)
chmod 755 $TMP_WORK_DIR
unset GIT_DIR GIT_WORK_TREE
git clone $DOKKU_ROOT/$APP $TMP_WORK_DIR &> /dev/null
pushd $TMP_WORK_DIR > /dev/null
git config advice.detachedHead false
git checkout $REV &> /dev/null
git submodule update --init --recursive &> /dev/null
find -name .git -prune -exec rm -rf {} \; > /dev/null
tar c .
popd > /dev/null
rm -rf $TMP_WORK_DIR > /dev/null
APP=$1; REV=$2
TMP_WORK_DIR=$(mktemp -d)
chmod 755 $TMP_WORK_DIR
unset GIT_DIR GIT_WORK_TREE
git clone $DOKKU_ROOT/$APP $TMP_WORK_DIR &> /dev/null
pushd $TMP_WORK_DIR > /dev/null
git config advice.detachedHead false
git checkout $REV &> /dev/null
git submodule update --init --recursive &> /dev/null
find -name .git -prune -exec rm -rf {} \; > /dev/null
tar c .
popd > /dev/null
rm -rf $TMP_WORK_DIR > /dev/null
}

case "$1" in
Expand All @@ -31,7 +31,6 @@ case "$1" in
echo $'\e[1G\e[K'"-----> WARNING: deploy did not complete, you must push to master."
echo $'\e[1G\e[K'"-----> for example, try 'git push <dokku> ${refname/refs\/heads\/}:master'"
fi

done
;;

Expand All @@ -40,15 +39,15 @@ case "$1" in
APP_PATH=$DOKKU_ROOT/$APP

if [[ $1 == "git-receive-pack" && ! -d "$APP_PATH/refs" ]]; then
git init --bare $APP_PATH > /dev/null
PRERECEIVE_HOOK="$APP_PATH/hooks/pre-receive"
cat > $PRERECEIVE_HOOK <<EOF
git init --bare $APP_PATH > /dev/null
PRERECEIVE_HOOK="$APP_PATH/hooks/pre-receive"
cat > $PRERECEIVE_HOOK <<EOF
#!/usr/bin/env bash
set -e; set -o pipefail;
cat | DOKKU_ROOT="$DOKKU_ROOT" dokku git-hook $APP
EOF
chmod +x $PRERECEIVE_HOOK
chmod +x $PRERECEIVE_HOOK
fi

args=$@
Expand All @@ -58,5 +57,5 @@ EOF
help)
cat
;;
esac

esac
4 changes: 2 additions & 2 deletions plugins/nginx-vhosts/backup-import
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ TARGET_DIR="$3"
cd $IMPORT_DIR

for file in */tls/server.*; do
mkdir -p $(dirname $TARGET_DIR$file)
cp $file $TARGET_DIR$file
mkdir -p $(dirname $TARGET_DIR$file)
cp $file $TARGET_DIR$file
done

0 comments on commit 7b361e5

Please sign in to comment.