-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·63 lines (53 loc) · 1.58 KB
/
install.sh
File metadata and controls
executable file
·63 lines (53 loc) · 1.58 KB
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
#!/usr/bin/env bash
GIT_REPO="https://github.com/nacl30d/macos_bootstrap"
GIT_DIR="${HOME}/.macos_bootstrap"
: "Meet pre-requirements" && {
if ! xcode-select --install 2>&1 | grep -q "already installed"; then
echo "Find installation dialog and install xcode-select."
exit 1;
fi
}
: "Download Ansible Playbooks" && {
if type git > /dev/null 2>&1; then
if [ -d "${GIT_DIR}" ]; then
cd "${GIT_DIR}"
git pull --no-ff
else
git clone "${GIT_REPO}.git" "${GIT_DIR}"
fi
elif type curl > /dev/null 2>&1; then
curl -LO "${GIT_REPO}/archive/master.tar.gz"
tar zxvf master.tar.gz "${GIT_DIR}"
else
echo 'Required: git or curl'
exit 1;
fi
}
: "Into working directory" && {
cd "${GIT_DIR}" || (echo "ERROR: Unknown directory '${GIT_DIR}'" && exit 1)
}
: "Install ansible" && {
if type ansible > /dev/null 2>&1; then
echo 'You have already install ansible!'
else
if ! type python3 > /dev/null 2>&1; then
echo "ERROR: python3 not found."
exit 1;
fi
# Setup virtual environment
python3 -m venv "${GIT_DIR}"
source "${GIT_DIR}/bin/activate"
if ! type pip3 > /dev/null 2>&1; then
echo "ERROR: pip3 not found."
exit 1;
fi
pip3 install ansible
if ! type ansible > /dev/null 2>&1; then
echo 'Error: Faild to install ansible'
exit 1;
fi
fi
}
: "Run Ansible Palybook" && {
ansible-playbook main.yml -i inventory/hosts
}