-
Notifications
You must be signed in to change notification settings - Fork 3
/
run.sh
executable file
·47 lines (39 loc) · 1.13 KB
/
run.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
# /bin/bash
green='32m'
yello='33m'
red='31m'
function myEcho() {
echo "\033[;${2}${1}\033[0m"
}
# check SUDO_PASSWORD variable is passed
SUDO_PASSWORD=${1}
if [[ ${SUDO_PASSWORD} = "" ]]; then
myEcho '**** SUDO_PASSWORD must be pass, and the variable can be set to the first parameters.' ${red}
exit -1
fi
# install homebrew
myEcho '====check homebrew is installed' ${yello}
brew --version
if [ ${?} -ne 0 ]; then
myEcho '--->install homebrew' ${green}
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
else
myEcho '--->homebrew installed' ${green}
fi
# create virtual env for python
myEcho '====check venv is already exist' ${yello}
if [ ! -d venv ]; then
python3 -m venv .venv
else
myEcho '--->venv exist' ${green}
fi
# activate virtual env
source .venv/bin/activate
# install python dependency
myEcho '====install python dependency====' ${yello}
pip3 install poetry
poetry install
# run ansible-playbook
myEcho '====run ansible playbook' ${yello}
ansible-playbook main.yml -i inventory/local --extra-vars "${SUDO_PASSWORD}"
myEcho '====install successfully' ${green}