-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup
executable file
·61 lines (49 loc) · 1.33 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
#!/usr/bin/env bash
set -eo pipefail
CODE_DIR="${HOME}/code"
MAC_SETUP_REPO="https://github.com/perryao/mac-setup.git"
MAC_SETUP_DIR="${CODE_DIR}/personal/github.com/perryao/mac-setup"
echo "Starting machine setup"
install_or_upgrade_brew() {
echo "Verifying homebrew is installed."
if [ -f /opt/homebrew/bin/brew ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
if ! command -v brew >/dev/null 2>&1; then
echo "installing homebrew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
else
echo "homebrew already installed. ensuring we're up-to-date"
brew update
fi
}
clone_or_pull_setup_repo() {
echo "Cloning setup scripts"
if [ ! -d "${MAC_SETUP_DIR}" ]; then
git clone --recurse-submodules "${MAC_SETUP_REPO}" "${MAC_SETUP_DIR}"
else
pushd "${MAC_SETUP_DIR}"
git pull
git submodule update --init --recursive
popd
fi
}
brew_bundle() {
echo "Installing homebrew packages"
pushd "${MAC_SETUP_DIR}"
brew bundle
popd
}
ansible_playbook() {
echo "Running ansible playbook"
pushd "${MAC_SETUP_DIR}/ansible"
ansible-galaxy install -r requirements.yml
ansible-playbook playbook.yml -i inventory
popd
}
mkdir -p "${CODE_DIR}"
install_or_upgrade_brew
clone_or_pull_setup_repo
brew_bundle
ansible_playbook
echo "setup complete"