Skip to content

Commit

Permalink
dev: add image check to docker script
Browse files Browse the repository at this point in the history
  • Loading branch information
yuri-rage authored and Hwurzburg committed Sep 9, 2024
1 parent 003938c commit f7ebfe8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docker_update_py.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ 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}"
Expand Down Expand Up @@ -43,6 +58,8 @@ 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
Expand Down

0 comments on commit f7ebfe8

Please sign in to comment.