#!/bin/bashlinux
# This is the script that we install somewhere in your $PATH (as "meteor")
# when you run
# $ curl https://install.meteor.com/ | sh
# In fact, all that the curl script does is install this script and run it
# once. It's the only file that we install globally on your system; each user of
# Meteor gets their own personal package and tools repository, called the
# warehouse, in ~/.meteor/. This means that a user can share packages among
# multiple apps and automatically update to new releases without having to have
# permissions to write them to anywhere global.
#
# All this script does is exec ~/.meteor/meteor. But what if you don't have it
# yet? In that case, it downloads a "bootstrap tarball", which contains the
# latest version of the Meteor tools, and plops it down at ~/.meteor. In fact,
# once you've run this once, you don't even really need this script: you can put
# ~/.meteor/ into your PATH, or a symlink to ~/.meteor/meteor into some other
# PATH directory. No special permissions needed!
# 腳本的目的在於運行 ~/.meteor/meteor。它會下載一個包:bootstrap tarball,包含了最新
# 版本的Meteor的工具,存放在~/.meteor文件夾下面。事實上,你只要已經運行過一次,你就可
# 不準要這個腳本:你能夠把~/.meteor/路徑放到你的PATH目錄下面,或者加一個連接到PATH目錄
# 下面,不準要額外的權限。
#
# To uninstall Meteor from your system, just delete this shell script, and
# delete your warehouse (~/.meteor/).
# 卸載就直接刪除~/.meteor/文件夾就好了。
#
# We'll keep around a copy of this file at
# ~/.meteor/engines/latest/launch-meteor just in case you ever want to find it
# again. And if you put it somewhere that other users on your system can run it,
# then when they run it they'll get their very own warehouse too!
# ~/.meteor/engines/latest/launch-meteor 是這個文件的副本,若是你把這個共享給了其餘
# 用,那麼他們也會有本身的倉庫。shell
set -e
set -u
set -o pipefail # so curl failure triggers the "set -e"bootstrap
# 設置兩個地址
BOOTSTRAP_URL='https://install-bootstrap.meteor.com/'
METEOR_WAREHOUSE_DIR="${METEOR_WAREHOUSE_DIR:-$HOME/.meteor}"bash
if [ ! -x "$METEOR_WAREHOUSE_DIR/meteor" ]; then # 測試目錄
if [ -e "$METEOR_WAREHOUSE_DIR" ]; then
echo "'$METEOR_WAREHOUSE_DIR' exists, but '$METEOR_WAREHOUSE_DIR/meteor' is not executable." 1>&2
echo 1>&2
echo "Remove it and try again." 1>&2
exit 1
fi # 發現倉庫路徑 但路徑裏面出現錯誤app
# Bootstrap .meteor from a tarball. First, figure out our architecture.curl
UNAME=$(uname)
if [ "$UNAME" != "Linux" -a "$UNAME" != "Darwin" ] ; then
echo "Sorry, this OS is not supported yet." 1>&2
exit 1
fi # 系統是否正確工具
# If you change this, also change host() in tools/archinfo.js
if [ "$UNAME" = "Darwin" ] ; then # osx 系統
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." 1>&2
exit 1 # osx 必定須要64位
fi
ARCH="x86_64"
elif [ "$UNAME" = "Linux" ] ; then # linux 系統
ARCH="$(uname -m)"
if [ "$ARCH" != "i686" -a "$ARCH" != "x86_64" ] ; then
echo "Unsupported architecture: $ARCH" 1>&2
echo "Meteor only supports i686 and x86_64 for now." 1>&2
exit 1 # 32和64都須要
fi
fi
PLATFORM="${UNAME}_${ARCH}" # 平臺字符串測試
# This returns something like https://warehouse.meteor.com/bootstrap/0.6.1
ROOT_URL="$(curl -s --fail $BOOTSTRAP_URL)" # 判斷是否提供
TARBALL_URL="${ROOT_URL}/meteor-bootstrap-${PLATFORM}.tar.gz" # 工具包地址this
INSTALL_TMPDIR="$(dirname "$METEOR_WAREHOUSE_DIR")/.meteor-install-tmp" # 安裝是的臨時目錄
rm -rf "$INSTALL_TMPDIR" # 清空安裝臨時目錄
mkdir "$INSTALL_TMPDIR" # 建立目錄
if [ -n "$USER" ]; then # 提示
echo "$USER, this is your first time using Meteor!" 1>&2
else
echo "This is your first time using Meteor!" 1>&2
fi
echo "Installing a Meteor distribution in your home directory." 1>&2
curl --progress-bar --fail "$TARBALL_URL" | tar -xzf - -C "$INSTALL_TMPDIR" # 下載工具包而且解壓到臨時目錄裏面
# bomb out if it didn't work, eg no net
test -x "${INSTALL_TMPDIR}/.meteor/meteor" # 是否有目錄
mv "${INSTALL_TMPDIR}/.meteor" "$METEOR_WAREHOUSE_DIR"
rmdir "${INSTALL_TMPDIR}" # 刪除臨時文件
# just double-checking :)
test -x "$METEOR_WAREHOUSE_DIR/meteor" # 是否安裝好
fiurl
exec "$METEOR_WAREHOUSE_DIR/meteor" "$@" # 執行