-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootstrap.sh
106 lines (80 loc) · 3.04 KB
/
bootstrap.sh
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/sh
# exit script, if error
set -e
# define colors
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
NOCOLOR=$(tput sgr0)
SCRIPT_FILE="bootstrap.sh"
SCRIPT_SOURCE="https://raw.githubusercontent.com/num42/n42-buildscripts/master/${SCRIPT_FILE}"
echo "${GREEN}Running N42 Bootstrap v2.02 (2020-10-28)${NOCOLOR}"
echo "${GREEN}If the script fails, there might be a newer Version on $SCRIPT_SOURCE ${NOCOLOR}"
echo "${GREEN}You can directly download it with 'curl -L $SCRIPT_SOURCE -o ${SCRIPT_FILE}' ${NOCOLOR}"
echo "${GREEN}You can update the script by running "sh ${SCRIPT_FILE} -u"' ${NOCOLOR}"
if [[ $1 == "-u" ]] ; then
echo ""
echo "${GREEN} Updating ${SCRIPT_FILE} ${NOCOLOR}";
curl -L $SCRIPT_SOURCE?"$(date +%s)" -o "$0"
exit 1
fi
if [ \( -e ".env-sample" \) ] && [ \( ! -e ".env" \) ]; then
echo ""
echo "${GREEN} COPYING .env-sample TO .env ${NOCOLOR}";
cp .env-sample .env
fi
if [ -e "Brewfile" ]; then
echo ""
echo "${GREEN} INSTALLING BREW DEPENDENCIES ${NOCOLOR}";
echo "${GREEN} HINT: If any tools (e.g. n, rbenv, protobuf) are not found during bootstrap, adding them to the Brewfile might solve the issue.${NOCOLOR}";
echo "${GREEN} For an example Brewfile, see https://github.com/Homebrew/homebrew-bundle${NOCOLOR}";
brew update
brew bundle
fi
if [ -e ".ruby-version" ]; then
echo ""
echo "${GREEN} SETTING UP RUBY ${NOCOLOR}";
# install ruby version from .ruby-version, skipping if already installed (-s)
rbenv install -s
fi
if [ -e "Gemfile" ]; then
echo ""
echo "${GREEN} INSTALLING GEMS ${NOCOLOR}";
# install bundler gem for ruby dependency management
gem install bundler --no-document || echo "${RED} FAILED TO INSTALL BUNDLER ${NOCOLOR}";
bundle install || echo "${RED} FAILED TO INSTALL BUNDLE ${NOCOLOR}";
fi
if [ -e ".node-version" ]; then
echo ""
echo "${GREEN} SETTING UP NODE ${NOCOLOR}";
# install node version from .node-version
n auto
fi
if [ -e "package-lock.json" ]; then
echo ""
echo "${GREEN} INSTALLING node-modules (NPM) ${NOCOLOR}";
# we expect npm to be installed via node.
npm install || echo "${RED} FAILED TO INSTALL NODE-MODULES (NPM) ${NOCOLOR}";
fi
if [ -e "yarn.lock" ]; then
echo ""
echo "${GREEN} INSTALLING node-modules (YARN) ${NOCOLOR}";
# we expect yarn to be installed via brew(file)
yarn install || echo "${RED} FAILED TO INSTALL NODE-MODULES (YARN) ${NOCOLOR}";
fi
if [ -e "mix.exs" ]; then
echo ""
echo "${GREEN} INSTALLING elixir(MIX) DEPENDENCIES ${NOCOLOR}";
mix deps.get || echo "${RED} FAILED TO INSTALL ELIXIR(MIX) DEPENDENCIES ${NOCOLOR}";
fi
if [ -e ".gitmodules" ]; then
echo ""
echo "${GREEN} SETTING UP GITMODULES ${NOCOLOR}";
# keep submodules up to date, see https://git-scm.com/book/en/v2/Git-Tools-Submodules
git submodule init || echo "${RED} FAILED TO INIT SUBMODULES ${NOCOLOR}";
git submodule update || echo "${RED} FAILED TO UPDATE SUBMODULES ${NOCOLOR}";
fi
if [ -e "bootstrap-specialized.sh" ]; then
echo ""
echo "${GREEN} RUNNING SPECIALIZED BOOTSTRAP SCRIPT ${NOCOLOR}";
. bootstrap-specialized.sh
fi