-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstall.sh
executable file
·65 lines (55 loc) · 1.36 KB
/
install.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
#!/usr/bin/env bash
DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
MACHINE_REPO=${MACHINE_REPO:-https://github.com/markosamuli/macos-machine.git}
MACHINE_BRANCH=${MACHINE_BRANCH:-master}
MACHINE=${MACHINE:-$HOME/.machine}
error() {
echo "$@" 1>&2
}
configure_machine() {
if [ -e "${DIR}/install.sh" ] && [ ! -d "${MACHINE}" ]; then
MACHINE="${DIR}"
fi
}
# Download repository with Git
download_machine() {
# Do we need to download the machine repository?
if [ ! -d "${MACHINE}" ]; then
echo "*** Cloning macos-machine from GitHub..."
git clone "${MACHINE_REPO}" "${MACHINE}" || {
error "couldn't clone ${MACHINE_REPO}"
exit 1
}
(cd "${MACHINE}" && git checkout "${MACHINE_BRANCH}") || {
error "couldn't checkout ${MACHINE_BRANCH}"
exit 1
}
fi
}
# Check that Xcode is installed
setup_xcode() {
command -v xcode-select 1>/dev/null 2>&1 || {
error "Xcode is not installed"
exit 1
}
}
# Check that Git is installed
setup_git() {
command -v git 1>/dev/null 2>&1 || {
error "Git is not installed"
exit 1
}
}
# Run setup script
setup_machine() {
cd "${MACHINE}" || {
error "${MACHINE} not found"
exit 1
}
./setup --sudo
}
setup_xcode
setup_git
configure_machine
download_machine
setup_machine