forked from ArduPilot/ardupilot_wiki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker_update_py.sh
executable file
·69 lines (60 loc) · 2.03 KB
/
docker_update_py.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
#!/bin/bash
# utility script to build the ardupilot_wiki with docker
BOLD='\e[1m'
RED='\e[31m'
GREEN='\e[32m'
YELLOW='\e[33m'
MAGENTA='\e[35m'
NC='\e[0m' # no color
# check for docker image and offer to build if not present
check_docker_image() {
if ! docker image inspect ardupilot_wiki > /dev/null 2>&1; then
echo -e "\n${BOLD}${RED}Docker image ${NC}${YELLOW}'ardupilot_wiki'${NC}${BOLD}${RED} not found.${NC}"
echo -en "\nBuild image? (Y/n): "
read build_choice
if [[ -z "$build_choice" || "$build_choice" =~ ^([yY][eE][sS]|[yY])$ ]]; then
echo # newline
docker build . -t ardupilot_wiki --build-arg USER_UID=$(id -u) --build-arg USER_GID=$(id -g)
else
exit 1
fi
fi
}
show_menu() {
echo -e "\n${BOLD}${YELLOW}Select ArduPilot Wiki site to build:${NC}\n"
echo -e " ${MAGENTA}1) Copter${NC}"
echo -e " ${MAGENTA}2) Plane${NC}"
echo -e " ${MAGENTA}3) Rover${NC}"
echo -e " ${MAGENTA}4) Dev${NC}"
echo -e " ${MAGENTA}5) All${NC}"
echo -en "\nEnter choice [1-5]: "
read choice
case $choice in
1) site_option="--site copter" ;;
2) site_option="--site plane" ;;
3) site_option="--site rover" ;;
4) site_option="--site dev" ;;
5) site_option="" ;;
*) echo -e "\n${BOLD}${RED}Invalid choice.${NC}" && show_menu ;;
esac
echo -en "\nBuild fast? (Y/n): "
read fast_choice
if [[ -z "$fast_choice" || "$fast_choice" =~ ^([yY][eE][sS]|[yY])$ ]]; then
fast_option="--fast"
else
fast_option=""
fi
echo -e "\nRunning: ${BOLD}${GREEN}update.py $fast_option $site_option${NC}\n"
run_command $fast_option $site_option
}
run_command() {
docker run --rm -it -v "${PWD}:/ardupilot_wiki" -u "$(id -u):$(id -g)" ardupilot_wiki python3 update.py "$@"
}
check_docker_image
if [ "$#" -eq 0 ]; then
# if no arguments given, show menu of options for building
show_menu
else
# build with docker using arguments passed via CLI
run_command "$@"
fi