mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
124 lines
4.2 KiB
Bash
Executable File
124 lines
4.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
BUNDLE_VERSION=0.3.32
|
|
|
|
# OS Check. Put here because here is where we download the precompiled
|
|
# bundles that are arch specific.
|
|
UNAME=$(uname)
|
|
if [ "$UNAME" != "Linux" -a "$UNAME" != "Darwin" ] ; then
|
|
echo "Sorry, this OS is not supported."
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$UNAME" = "Darwin" ] ; then
|
|
if [ "i386" != "$(uname -p)" -o "1" != "$(sysctl -n hw.cpu64bit_capable 2>/dev/null || echo 0)" ] ; then
|
|
|
|
# Can't just test uname -m = x86_64, because Snow Leopard can
|
|
# return other values.
|
|
echo "Only 64-bit Intel processors are supported at this time."
|
|
exit 1
|
|
fi
|
|
ARCH="x86_64"
|
|
elif [ "$UNAME" = "Linux" ] ; then
|
|
ARCH="$(uname -m)"
|
|
if [ "$ARCH" != "i686" -a "$ARCH" != "x86_64" ] ; then
|
|
echo "Unsupported architecture: $ARCH"
|
|
echo "Meteor only supports i686 and x86_64 for now."
|
|
exit 1
|
|
fi
|
|
fi
|
|
PLATFORM="${UNAME}_${ARCH}"
|
|
|
|
# Find the script dir, following one level of symlink. Note that symlink
|
|
# can be relative or absolute. Too bad 'readlink -f' is not portable.
|
|
ORIG_DIR=$(pwd)
|
|
cd "$(dirname "$0")"
|
|
if [ -L "$(basename "$0")" ] ; then
|
|
cd "$(dirname $(readlink $(basename "$0") ) )"
|
|
fi
|
|
SCRIPT_DIR=$(pwd -P)
|
|
cd "$ORIG_DIR"
|
|
|
|
|
|
|
|
function install_dev_bundle {
|
|
set -e
|
|
trap "echo Failed to install dependency kit." EXIT
|
|
|
|
TARBALL="dev_bundle_${PLATFORM}_${BUNDLE_VERSION}.tar.gz"
|
|
BUNDLE_TMPDIR="$SCRIPT_DIR/dev_bundle.xxx"
|
|
|
|
rm -rf "$BUNDLE_TMPDIR"
|
|
mkdir "$BUNDLE_TMPDIR"
|
|
|
|
# fyi: URL duplicated in packages/dev-bundle-fetcher/dev-bundle
|
|
DEV_BUNDLE_URL_ROOT="https://d3sqy0vbqsdhku.cloudfront.net/"
|
|
# If you set $USE_TEST_DEV_BUNDLE_SERVER then we will download
|
|
# dev bundles copied by copy-dev-bundle-from-jenkins.sh without --prod.
|
|
# It still only does this if the version number has changed
|
|
# (setting it won't cause it to automatically delete a prod dev bundle).
|
|
if [ -n "$USE_TEST_DEV_BUNDLE_SERVER" ] ; then
|
|
DEV_BUNDLE_URL_ROOT="https://com.meteor.static.s3.amazonaws.com/test/"
|
|
fi
|
|
|
|
if [ -f "$SCRIPT_DIR/$TARBALL" ] ; then
|
|
echo "Skipping download and installing kit from $SCRIPT_DIR/$TARBALL" >&2
|
|
tar -xzf "$SCRIPT_DIR/$TARBALL" -C "$BUNDLE_TMPDIR"
|
|
elif [ -n "$SAVE_DEV_BUNDLE_TARBALL" ] ; then
|
|
# URL duplicated in tools/server/target.sh.in
|
|
curl -# "$DEV_BUNDLE_URL_ROOT$TARBALL" >"$SCRIPT_DIR/$TARBALL"
|
|
tar -xzf "$SCRIPT_DIR/$TARBALL" -C "$BUNDLE_TMPDIR"
|
|
else
|
|
curl -# "$DEV_BUNDLE_URL_ROOT$TARBALL" | tar -xzf - -C "$BUNDLE_TMPDIR"
|
|
fi
|
|
|
|
test -x "${BUNDLE_TMPDIR}/bin/node" # bomb out if it didn't work, eg no net
|
|
|
|
# Delete old dev bundle and rename the new one on top of it.
|
|
rm -rf "$SCRIPT_DIR/dev_bundle"
|
|
mv "$BUNDLE_TMPDIR" "$SCRIPT_DIR/dev_bundle"
|
|
|
|
echo "Installed dependency kit v${BUNDLE_VERSION} in dev_bundle." >&2
|
|
echo >&2
|
|
|
|
trap - EXIT
|
|
set +e
|
|
}
|
|
|
|
|
|
if [ -d "$SCRIPT_DIR/.git" ] || [ -f "$SCRIPT_DIR/.git" ]; then
|
|
# In a checkout.
|
|
if [ ! -d "$SCRIPT_DIR/dev_bundle" ] ; then
|
|
echo "It's the first time you've run Meteor from a git checkout." >&2
|
|
echo "I will download a kit containing all of Meteor's dependencies." >&2
|
|
install_dev_bundle
|
|
elif [ ! -f "$SCRIPT_DIR/dev_bundle/.bundle_version.txt" ] ||
|
|
grep -qvx "$BUNDLE_VERSION" "$SCRIPT_DIR/dev_bundle/.bundle_version.txt" ; then
|
|
echo "Your dependency kit is out of date. I will download the new one." >&2
|
|
install_dev_bundle
|
|
fi
|
|
|
|
DEV_BUNDLE="$SCRIPT_DIR/dev_bundle"
|
|
METEOR="$SCRIPT_DIR/tools/main.js"
|
|
else
|
|
# In an install
|
|
DEV_BUNDLE=$(dirname "$SCRIPT_DIR")
|
|
METEOR="$DEV_BUNDLE/tools/main.js"
|
|
fi
|
|
|
|
|
|
# Bump our file descriptor ulimit as high as it will go. This is a
|
|
# temporary workaround for dependancy watching holding open too many
|
|
# files: https://app.asana.com/0/364581412985/472479912325
|
|
if [ "$(ulimit -n)" != "unlimited" ] ; then
|
|
ulimit -n 16384 > /dev/null 2>&1 || \
|
|
ulimit -n 8192 > /dev/null 2>&1 || \
|
|
ulimit -n 4096 > /dev/null 2>&1 || \
|
|
ulimit -n 2048 > /dev/null 2>&1 || \
|
|
ulimit -n 1024 > /dev/null 2>&1 || \
|
|
ulimit -n 512 > /dev/null 2>&1
|
|
fi
|
|
|
|
export NODE_PATH="$DEV_BUNDLE/lib/node_modules"
|
|
exec "$DEV_BUNDLE/bin/node" "$METEOR" "$@"
|