|
| 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 | +cat <<EOF |
| 19 | + ___ ___ _ ___ _ |
| 20 | +/ __|/ _ \| | | __| |_____ __ __ |
| 21 | +\__ \ (_) | |__| _|| / _ \ V V / |
| 22 | +|___/\__\_\____|_| |_\___/\_/\_/ |
| 23 | +
|
| 24 | +EOF |
| 25 | + |
| 26 | +if ! which vagrant >/dev/null; then |
| 27 | + cat <<EOF |
| 28 | +We need Vagrant to run the playground. |
| 29 | +
|
| 30 | +Linux users can refer to https://www.vagrantup.com/downloads.html for the |
| 31 | +installation guide. |
| 32 | +
|
| 33 | +macOS users can install Vagrant using Homebrew: |
| 34 | + brew cask install vagrant |
| 35 | +EOF |
| 36 | + exit 1 |
| 37 | +fi |
| 38 | + |
| 39 | +if [[ -n "$(vagrant global-status --prune | grep -o 'playground')" ]]; then |
| 40 | + echo "The playground VM is running." |
| 41 | + exit 0 |
| 42 | +fi |
| 43 | + |
| 44 | +if [[ -z "$(vagrant plugin list | grep -o 'vagrant-disksize')" ]]; then |
| 45 | + echo "Install Vagrant disk size plugin ..." |
| 46 | + vagrant plugin install vagrant-disksize |
| 47 | +fi |
| 48 | + |
| 49 | +if [[ -z "$(vagrant box list | grep 'ubuntu/bionic64')" ]]; then |
| 50 | + CACHED_BOX="$HOME/.cache/sqlflow/ubuntu-bionic64.box" |
| 51 | + if [[ -f $CACHED_BOX ]]; then |
| 52 | + echo "Found and use cached box $CACHED_BOX" |
| 53 | + vagrant box add ubuntu/bionic64 $CACHED_BOX |
| 54 | + fi |
| 55 | +fi |
| 56 | + |
| 57 | +echo "Start and provision the playgound VM ..." |
| 58 | +vagrant up |
0 commit comments