1#!/bin/bash
2# Copyright (c) PLUMgrid, Inc.
3# Licensed under the Apache License, Version 2.0 (the "License")
4
5# this script:
6#  1. checks for bower to be installed
7#  2. clones the chord-transitions UI from github
8#  3. installs locally the packages required by the UI
9
10function which_() { hash "$1" &>/dev/null; }
11
12if [[ ! -d chord-transitions ]]; then
13  git clone https://github.com/iovisor/chord-transitions.git
14fi
15
16cd chord-transitions
17
18export PATH=node_modules/.bin:$PATH
19
20if ! which_ bower; then
21  if ! which_ npm; then
22    echo "Error: required binary 'npm' not found, please install nodejs"
23    exit 1
24  fi
25  npm install bower
26fi
27
28if [[ "$(id -u)" = "0" ]]; then
29  args="--allow-root"
30fi
31
32bower install $args
33