-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·163 lines (128 loc) · 5.48 KB
/
setup.sh
File metadata and controls
executable file
·163 lines (128 loc) · 5.48 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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/usr/bin/env bash
# shellcheck disable=SC1091
set -e
SCRIPT_DIR=$(readlink -f "$(dirname "$0")")
CLR_GREEN="\033[32m"
CLR_RED="\033[31m"
CLR_RESET="\033[0m"
INSTALL_NVIDIA=true
DOWNLOAD_ARTIFACTS=false
#### Functions ####
print_help() {
echo "Setup runtime environment for Autoware Open AD Kit"
echo "Usage: setup.sh [OPTIONS]"
echo "Options:"
echo " --help Display this help message"
echo " -h Display this help message"
echo " --no-nvidia Skip installation of NVIDIA container toolkit"
echo " --download-artifacts Download Autoware artifacts"
echo ""
}
parse_args() {
while [[ $# -gt 0 ]]; do
case $1 in
--help|-h)
print_help
exit 0
;;
--no-nvidia)
INSTALL_NVIDIA=false
shift
;;
--download-artifacts)
DOWNLOAD_ARTIFACTS=true
shift
;;
*)
echo "Unknown option: $1"
print_help
exit 1
;;
esac
done
}
install_nvidia_container_toolkit() {
echo "Installing NVIDIA Container Toolkit..."
# Remove any pre-existing NVIDIA container toolkit repo configuration
sudo rm -f /etc/apt/sources.list.d/nvidia-container-toolkit*.list
sudo rm -f /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
# Install prerequisites for GPG key handling
sudo apt-get update && sudo apt-get install -y --no-install-recommends \
ca-certificates curl gnupg2
# Add NVIDIA container toolkit GPG key (dearmored per official NVIDIA docs)
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | \
sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
# Add NVIDIA container toolkit repository using official repo list
curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list > /dev/null
# Install NVIDIA Container Toolkit
sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
# Add NVIDIA runtime support to docker engine
sudo nvidia-ctk runtime configure --runtime=docker
# Restart docker daemon
sudo systemctl restart docker
echo -e "${CLR_GREEN}NVIDIA Container Toolkit installed successfully!${CLR_RESET}"
}
install_docker() {
echo "Installing Docker..."
if command -v docker &> /dev/null; then
echo "Docker is already installed. Skipping installation."
return
fi
# Remove old docker packages
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do
sudo apt-get remove -y "$pkg" 2>/dev/null || true
done
# Install ca-certificates curl
sudo apt-get update && sudo apt-get install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add Docker's official GPG key
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install Docker
sudo apt-get update && sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Add user to docker group
sudo groupadd docker 2>/dev/null || true
sudo usermod -aG docker "$USER"
echo -e "${CLR_GREEN}Docker installed successfully!${CLR_RESET}"
echo -e "${CLR_GREEN}Please log out and log back in for Docker group changes to take effect.${CLR_RESET}"
}
download_autoware_artifacts() {
echo "Downloading Autoware artifacts..."
# Remove apt installed ansible (In Ubuntu 22.04, ansible the version is old)
sudo apt-get purge ansible
# Install pipx
sudo apt-get -y update
sudo apt-get -y install pipx
# Add pipx to the system PATH
python3 -m pipx ensurepath
# Install ansible
pipx install --include-deps --force "ansible==6.*"
# Clone Autoware
git clone https://github.com/autowarefoundation/autoware.git ~/autoware
# Get the user home directory from the sudo user
USER_HOME=$(getent passwd "$SUDO_USER" | cut -d: -f6)
# Install Autoware artifacts
cd ~/autoware # The root directory of the cloned repository
ansible-galaxy collection install -f -r "ansible-galaxy-requirements.yaml"
ansible-playbook autoware.dev_env.download_artifacts -e "data_dir=$USER_HOME/autoware_data"
chown -R "$SUDO_USER:$SUDO_USER" "$USER_HOME/autoware_data"
# Remove the cloned Autoware directory
rm -rf ~/autoware
echo -e "${CLR_GREEN}Autoware artifacts downloaded successfully!${CLR_RESET}"
}
#### Main ####
parse_args "$@"
if ! sudo -n true 2>/dev/null; then
echo -e "${CLR_RED}This script requires sudo privileges. Please run with a user that has sudo access.${CLR_RESET}"
exit 1
fi
[ "$DOWNLOAD_ARTIFACTS" = true ] && download_autoware_artifacts && exit 0
install_docker
[ "$INSTALL_NVIDIA" = true ] && install_nvidia_container_toolkit
echo -e "${CLR_GREEN}Setup completed!${CLR_RESET}"