-
Notifications
You must be signed in to change notification settings - Fork 47
/
setup
executable file
·90 lines (75 loc) · 1.78 KB
/
setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env sh
fancy_echo() {
local fmt="$1"; shift
# shellcheck disable=SC2059
printf "\\n$fmt\\n" "$@"
}
install_linux_deps() {
local LINUX_DEPS="automake autoconf autogen libtool gcc curl cmake"
local flavor=`grep "^ID=" /etc/os-release | cut -d"=" -f 2`
echo $flavor
case $flavor in
debian|ubuntu)
sudo apt-get install -y $LINUX_DEPS libgmp-dev erlang-dev libbz2-dev
;;
fedora|centos)
sudo yum install $LINUX_DEPS gmp-devel bzip2 bzip2-devel
;;
*)
fancy_echo "Unrecognized distribution $flavor"
exit 1
;;
esac
}
install_darwin_deps(){
fancy_echo "Installing dependencies via brew"
brew bundle --file=- <<EOF
brew "automake"
brew "autoconf"
brew "gmp"
brew "libtool"
brew "cmake"
EOF
}
install_deps() {
local sys=`uname -s`
echo $sys
case $sys in
Linux*)
install_linux_deps
;;
Darwin*)
install_darwin_deps
;;
*)
fancy_echo "Unknown system"
exit 1
;;
esac
}
# Exit if any subcommand fails
set -e
# set up secrets if not set up yet
if [ ! -f apps/blockchain/config/dev.secret.exs ]; then
echo "Copying .secret files"
cp apps/blockchain/config/dev.secret.exs.example apps/blockchain/config/dev.secret.exs
fi
install_deps
# Set up Elixir
if ! command -v mix > /dev/null; then
fancy_echo "It looks like you don't have Elixir installed."
echo "See http://elixir-lang.org/install.html for instructions."
exit 1
fi
mix local.hex --force
if ! command -v mix > /dev/null; then
fancy_echo "\`mix\`: command not found"
fancy_echo "Please add \`~/.mix\` to your \$PATH environment variable"
exit 1
fi
fancy_echo "Installing elixir dependencies and compiling."
mix local.hex --force
mix local.rebar --force
mix deps.get
mix compile
fancy_echo "You're all set!"