github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/scripts/install.sh (about) 1 #!/bin/bash 2 # 3 # Tilt installer 4 # 5 # Usage: 6 # curl -fsSL https://raw.githubusercontent.com/tilt-dev/tilt/master/scripts/install.sh | bash 7 8 # When releasing Tilt, the releaser should update this version number 9 # AFTER they upload new binaries. 10 VERSION="0.33.14" 11 BREW=$(command -v brew) 12 13 set -e 14 15 function copy_binary() { 16 if [[ ":$PATH:" == *":$HOME/.local/bin:"* ]]; then 17 if [ ! -d "$HOME/.local/bin" ]; then 18 mkdir -p "$HOME/.local/bin" 19 fi 20 mv tilt "$HOME/.local/bin/tilt" 21 else 22 echo "Installing Tilt to /usr/local/bin which is write protected" 23 echo "If you'd prefer to install Tilt without sudo permissions, add \$HOME/.local/bin to your \$PATH and rerun the installer" 24 sudo mv tilt /usr/local/bin/tilt 25 fi 26 } 27 28 function brew_install_or_upgrade() { 29 set -x 30 brew bundle --file=- <<< "brew 'tilt'" 31 32 set +x 33 location=$(command -v tilt) 34 brew_root=$(brew --prefix) 35 brew_tilt="$brew_root/bin/tilt" 36 if [[ "$location" != "$brew_root"* ]]; then 37 echo "Warning: you have a conflicting binary at: $location" 38 echo " Brew installed Tilt as: $brew_tilt" 39 echo "" 40 echo " If you want to use the Tilt you just installed, you can:" 41 echo " 1) Remove the other binary: rm $location" 42 echo " 2) Adjust your PATH to put Brew first: export PATH=\"$brew_root/bin:\$PATH\"" 43 echo " 3) Alias tilt: alias tilt=$brew_tilt" 44 exit 1 45 fi 46 } 47 48 function install_tilt() { 49 if [[ "$OSTYPE" == "linux"* ]]; then 50 if [[ "$BREW" != "" ]]; then 51 brew_install_or_upgrade 52 53 # linux-homebrew is relatively recent. Make sure that tilt 54 # under $HOME/.local/bin isn't overriding the homebrew one. 55 rm -f "$HOME/.local/bin/tilt" || true 56 else 57 # On Linux, "uname -m" reports "aarch64" on ARM 64 bits machines, 58 # and armv7l on ARM 32 bits machines like the Raspberry Pi. 59 # This is a small workaround so that the install script works on ARM. 60 case $(uname -m) in 61 aarch64) ARCH=arm64;; 62 armv7l) ARCH=arm;; 63 *) ARCH=$(uname -m);; 64 esac 65 set -x 66 curl -fsSL https://github.com/tilt-dev/tilt/releases/download/v$VERSION/tilt.$VERSION.linux.$ARCH.tar.gz | tar -xzv tilt 67 copy_binary 68 fi 69 elif [[ "$OSTYPE" == "darwin"* ]]; then 70 if [[ "$BREW" != "" ]]; then 71 brew_install_or_upgrade 72 else 73 # On macOS, "uname -m" reports "arm64" on ARM 64 bits machines 74 ARCH=$(uname -m) 75 set -x 76 curl -fsSL https://github.com/tilt-dev/tilt/releases/download/v$VERSION/tilt.$VERSION.mac.$ARCH.tar.gz | tar -xzv tilt 77 copy_binary 78 fi 79 else 80 set +x 81 echo "The Tilt installer does not work for your platform: $OSTYPE" 82 echo "For other installation options, check the following page:" 83 echo "https://docs.tilt.dev/install.html#alternative-installations" 84 echo "If you think your platform should be supported, please file an issue:" 85 echo "https://github.com/tilt-dev/tilt/issues/new" 86 echo "Thank you!" 87 exit 1 88 fi 89 90 set +x 91 } 92 93 function version_check() { 94 VERSION_FROM_BIN="$(tilt version 2>&1 || true)" 95 RUBY_TILT_PATTERN="template engine not found" 96 TILT_DEV_PATTERN='^v[0-9]+\.[0-9]+\.[0-9]+(-dev)?, built [0-9]+-[0-9]+-[0-9]+$' 97 if [[ $VERSION_FROM_BIN =~ $RUBY_TILT_PATTERN ]]; then 98 echo "Tilt installed!" 99 echo 100 echo "Note: the ruby templating program named 'tilt' (at $(command -v tilt)) appears before tilt.dev's tilt in your \$PATH." 101 echo "You'll need to adjust your \$PATH, uninstall the other tilt, rename tilt, or use an absolute path to run tilt.dev's tilt. See https://docs.tilt.dev/faq.html." 102 exit 1 103 elif ! [[ $VERSION_FROM_BIN =~ $TILT_DEV_PATTERN ]]; then 104 echo "Tilt installed!" 105 echo 106 echo "Note: it looks like it is not the first program named 'tilt' in your path. \`tilt version\` (running from $(command -v tilt)) did not return a tilt.dev version string." 107 echo "It output this instead:" 108 echo 109 echo "$VERSION_FROM_BIN" 110 echo 111 echo "Perhaps you have a different program named tilt in your \$PATH?" 112 exit 1 113 else 114 echo "Tilt installed!" 115 echo "For the latest Tilt news, subscribe: https://tilt.dev/subscribe" 116 echo "Run \`tilt up\` to start." 117 fi 118 } 119 120 # so that we can skip installation in CI and just test the version check 121 if [[ -z $NO_INSTALL ]]; then 122 install_tilt 123 fi 124 125 version_check 126 127 tilt verify-install 128