-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-dev-env.sh
executable file
·102 lines (85 loc) · 2.55 KB
/
setup-dev-env.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env bash
# Set up development environment for Autoware Core/Universe.
# Usage: setup-dev-env.sh <installation_type('core' or 'universe')> [-y] [-v] [--no-nvidia]
# Note: -y option is only for CI.
set -e
SCRIPT_DIR=$(readlink -f "$(dirname "$0")")
# Parse arguments
args=()
while [ "$1" != "" ]; do
case "$1" in
-y)
option_yes=true
;;
-v)
option_verbose=true
;;
--no-nvidia)
option_no_nvidia=true
;;
*)
args+=("$1")
;;
esac
shift
done
# Select installation type
installation_type=universe # default
if [ ${#args[@]} -ge 1 ]; then
installation_type=${args[0]}
fi
if [ "$installation_type" != "core" ] && [ "$installation_type" != "universe" ] && [ "$installation_type" != "docker" ]; then
echo -e "\e[31mPlease input a valid installation type 'core', 'universe' or 'docker' as the 1st argument, or keep it empty to use the default.\e[m"
exit 1
fi
# Initialize ansible args
ansible_args=()
# Confirm to start installation
if [ "$option_yes" = "true" ]; then
echo -e "\e[36mRun the setup in non-interactive mode.\e[m"
else
echo -e "\e[33mSetting up the build environment take up to 1 hour.\e[m"
read -rp "> Are you sure to run the setup? [y/N] " answer
# Check whether to cancel
if ! [[ ${answer:0:1} =~ y|Y ]]; then
echo -e "\e[33mCancelled.\e[0m"
exit 1
fi
ansible_args+=("--ask-become-pass")
fi
# Check verbose option
if [ "$option_verbose" = "true" ]; then
ansible_args+=("-v")
fi
# Check NVIDIA Installation
if [ "$option_no_nvidia" = "true" ]; then
ansible_args+=("--extra-vars" "install_nvidia=n")
elif [ "$option_yes" = "true" ]; then
ansible_args+=("--extra-vars" "install_nvidia=y")
fi
# Install sudo
if ! (command -v sudo >/dev/null 2>&1); then
apt-get -y update
apt-get -y install sudo
fi
# Install pip for ansible
if ! (command -v pip3 >/dev/null 2>&1); then
sudo apt-get -y update
sudo apt-get -y install python3-pip
fi
# Install ansible
ansible_version=$(pip3 list | grep -oP "^ansible\s+\K([0-9]+)" || true)
if [ "$ansible_version" != "5" ]; then
sudo pip3 install -U "ansible==5.*"
fi
# Install ansible collections
ansible-galaxy collection install -f -r "$SCRIPT_DIR/ansible-galaxy-requirements.yaml"
# Run ansible
echo Run ansible-playbook "autoware.dev_env.$installation_type" "${ansible_args[@]}"
if ansible-playbook "autoware.dev_env.$installation_type" "${ansible_args[@]}"; then
echo -e "\e[32mCompleted.\e[0m"
exit 0
else
echo -e "\e[31mFailed.\e[0m"
exit 1
fi