-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathserve_site.sh
executable file
·85 lines (68 loc) · 1.98 KB
/
serve_site.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
#!/usr/bin/env bash
# #############################################################################
# Script to convert all .puml files into .puml.svg files then to serve the
# site on a Hugo dev server running at localhost:1313.
# Relies on docker and its buildx plugin to do the svg generation and to run
# Hugo.
# #############################################################################
set -e
setup_echo_colours() {
# Exit the script on any error
set -e
# shellcheck disable=SC2034
if [ "${MONOCHROME}" = true ]; then
RED=''
GREEN=''
YELLOW=''
BLUE=''
BLUE2=''
DGREY=''
NC='' # No Colour
else
RED='\033[1;31m'
GREEN='\033[1;32m'
YELLOW='\033[1;33m'
BLUE='\033[1;34m'
BLUE2='\033[1;34m'
DGREY='\e[90m'
NC='\033[0m' # No Colour
fi
}
debug_value() {
local name="$1"; shift
local value="$1"; shift
if [ "${IS_DEBUG}" = true ]; then
echo -e "${DGREY}DEBUG ${name}: ${value}${NC}"
fi
}
debug() {
local str="$1"; shift
if [ "${IS_DEBUG}" = true ]; then
echo -e "${DGREY}DEBUG ${str}${NC}"
fi
}
check_prerequisites() {
if ! docker version >/dev/null 2>&1; then
echo -e "${RED}ERROR: Docker is not installed. Please install Docker or Docker Desktop.${NC}"
exit 1
fi
if ! docker buildx version >/dev/null 2>&1; then
echo -e "${RED}ERROR: Docker buildx plugin is not installed. Please install it. See https://github.com/docker/buildx#installing${NC}"
exit 1
fi
}
main() {
IS_DEBUG=false
local repo_root
repo_root="$(git rev-parse --show-toplevel)"
pushd "${repo_root}" > /dev/null
setup_echo_colours
check_prerequisites
local puml_svg_count
puml_svg_count="$(find "${repo_root}" -name "*.puml.svg" | wc -l )"
echo -e "${GREEN}No PlantUML SVG files found (*.puml.svg) so running SVG generation process.${NC}"
./container_build/runInPumlDocker.sh SVG
echo -e "${GREEN}Running the Hugo server on localhost:1313${NC}"
./container_build/runInHugoDocker.sh server
}
main "$@"