-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·44 lines (41 loc) · 1.33 KB
/
build.sh
File metadata and controls
executable file
·44 lines (41 loc) · 1.33 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
#!/bin/bash
#set -x
# Function to display usage
usage() {
echo "Usage: $0 [-b] [-s]" 1>&2
echo "Options:" 1>&2
echo " -b Build the blog site" 1>&2
echo " -s Serve the blog site" 1>&2
exit 1
}
# Parse command line options
while getopts ":bs" opt; do
case ${opt} in
b)
echo "Start building the blog site..." 1>&2
# Build the static other directory
# 1) Build the safe and secure rust book
SECURE_RUST_BOOK_NAME="safe_secure_rust_book"
mdbook build /app/content/other/${SECURE_RUST_BOOK_NAME} || { echo "Error: Failed to build ${SECURE_RUST_BOOK_NAME} mdbook" 1>&2; exit 1; }
# 2) Copy the book to the static directory
cp -r /app/content/other/${SECURE_RUST_BOOK_NAME}/book /app/static/other/${SECURE_RUST_BOOK_NAME}
# Build the blog site
zola build || { echo "Error: Failed to build blog site." 1>&2; exit 1; }
# Cleanup public output directory
rm -f /app/public/other/.gitignore
;;
s)
echo "Start serving the blog site..." 1>&2
zola serve --interface 0.0.0.0 --port 8080 --base-url localhost || { echo "Error: Failed to serve blog site." 1>&2; exit 1; }
;;
\?)
echo "Invalid option: -$OPTARG" 1>&2
usage
;;
:)
echo "Option -$OPTARG requires an argument." 1>&2
usage
;;
esac
done
shift $((OPTIND -1))