-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·60 lines (49 loc) · 1.54 KB
/
setup.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
set -e
install_jenv() {
if ! grep -q jenv "$1"; then
echo "export PATH=""$HOME"/.jenv/bin:"$PATH""" >> "$1"
echo "eval "$(jenv init -)"" >> "$1"
$("$2 $1")
fi
}
echo '--- FormFlow Setup Script ---'
if ! brew --version; then
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
else
brew update
fi
echo 'Installing brew packages'
brew install --cask temurin@21
brew install jenv gradle postgresql@14
# Install jenv in either the .bashrc or zshrc, whichever is present
if [ -f ~/.bashrc ]; then
install_jenv "$HOME/.bashrc" "sh"
elif [ -f ~/.zshrc ]; then
install_jenv "$HOME/.zshrc" "zsh"
else
echo 'No shell config file found, cant install jenv'
exit 1
fi
# M1 Mac install stuff
if [[ $(uname -m) == 'arm64' ]]; then
export PATH="$HOME/.jenv/bin:$PATH"
export JENV_ROOT="/opt/homebrew/Cellar/jenv/"
eval "$(/opt/homebrew/bin/brew shellenv)"
eval "$(jenv init -)"
fi
# Check if jenv can find java 21
if ! jenv versions | grep -q 21; then
jenv add /Library/Java/JavaVirtualMachines/temurin-21.jdk/Contents/Home
fi
# If the postgres service isn't running in brew, start it
if ! brew services list | grep postgresql@14 | grep started; then
brew services start postgresql@14
fi
# Create form-flow-test databases and users in postgres, if they don't exist
if ! psql -lqt | cut -d \| -f 1 | tr -d ' ' | grep -qx form-flow-test; then
createdb form-flow-test
createuser -s form-flow-test
fi
# Build the jar and run tests
./gradlew clean webJar jar test
echo '--- FormFlow Setup Script Complete ---'