Files
cloudron-box/scripts/createSourceTarball.sh
T
Girish Ramakrishnan 409f919d4d Ensure top level directory is readable by others
tar --list --verbose --file=box.tar now shows:
drwxr-xr-x girishra/staff    0 2015-01-17 16:57 ./

Without this change, mktemp was creating directories have no r,x for
others and group. This meant that nginx which was running www-user
was unable to access the website inside box code.
2015-01-17 13:59:58 -08:00

31 lines
971 B
Bash
Executable File

#!/bin/bash
# set -x
set -e
[ ! -f "$HOME/.s3cfg" ] && echo "~/.s3cfg missing" && exit 1
SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd )"
VERSION=$(cd "$SOURCE_DIR" && git rev-parse HEAD)
# why is this not set on mint?
TMPDIR=${TMPDIR:-/tmp}
BUNDLE_DIR=$(mktemp -d -t box 2>/dev/null || mktemp -d box-XXXXXXXXXX --tmpdir=$TMPDIR)
chmod "o+rx,g+rx" "$BUNDLE_DIR" # otherwise extracted tarball director won't be readable by others/group
echo "Checking out code [$VERSION] into $BUNDLE_DIR"
(cd "$SOURCE_DIR" && git archive --format=tar HEAD | (cd "$BUNDLE_DIR" && tar xf -))
echo "Installing modules"
cd "$BUNDLE_DIR" && npm install --production
BUNDLE_FILE="$TMPDIR/box-${VERSION}.tar.gz"
cd "$BUNDLE_DIR" && tar czvf "$BUNDLE_FILE" .
echo "Uploading bundle to S3"
$SOURCE_DIR/node_modules/.bin/s3-cli put --acl-public "$BUNDLE_FILE" "s3://cloudron-releases/box-${VERSION}.tar.gz"
echo "Cleaning up $BUNDLE_DIR"
rm -rf "$BUNDLE_DIR" "$BUNDLE_FILE"