|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Copyright 2020 The SQLFlow Authors. All rights reserved. |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +set -e |
| 17 | + |
| 18 | +if [[ "$1" == "inchina" ]]; then |
| 19 | + export WE_ARE_IN_CHINA=true |
| 20 | +fi |
| 21 | + |
| 22 | +echo |
| 23 | +echo "Welcome to SQLFlow playground!" |
| 24 | +echo |
| 25 | + |
| 26 | +if ! which vagrant >/dev/null; then |
| 27 | + echo "Install vagrant first, please refer to https://www.vagrantup.com/downloads.html" |
| 28 | + echo |
| 29 | + echo "If you are using macOS, the operation system may prevent you from installing the web-downloaded package, you can try use brew to install vagrant. like:" |
| 30 | + echo "brew cask install vagrant" |
| 31 | + echo |
| 32 | + echo "Fix this and re-run this script again please!" |
| 33 | + exit 0 |
| 34 | +fi |
| 35 | + |
| 36 | +if [[ -n "$(vagrant global-status --prune | grep -o 'playground')" ]]; then |
| 37 | + echo "It seems you have already installed our playground, exiting..." |
| 38 | + exit 0 |
| 39 | +fi |
| 40 | + |
| 41 | +if [[ "$WE_ARE_IN_CHINA" ]]; then |
| 42 | + if [[ -z "$(vagrant box list | grep -o ubuntu/bionic64)" ]]; then |
| 43 | + echo "Download ubuntu box beforehand..." |
| 44 | + mkdir -p downloads |
| 45 | + # try with https://mirrors.ustc.edu.cn/ if below not work |
| 46 | + wget -c -nv --show-progress -O downloads/ubuntu-bionic64.box "https://mirrors.ustc.edu.cn/ubuntu-cloud-images/bionic/current/bionic-server-cloudimg-amd64-vagrant.box" |
| 47 | + vagrant box add ubuntu/bionic64 downloads/ubuntu-bionic64.box |
| 48 | + fi |
| 49 | +fi |
| 50 | + |
| 51 | +echo "Start and provision the playgound now..." |
| 52 | +vagrant up |
| 53 | + |
0 commit comments