forked from twistlock/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_site.sh
executable file
·267 lines (209 loc) · 5.42 KB
/
build_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
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#!/bin/bash
#
# This script builds the Prisma Cloud Compute static doc site.
#
show_help() {
echo "
Usage: build_site.sh [OPTIONS] [DOC_SOURCE]
build_site.sh builds the Prisma Cloud Compute static site.
OPTIONS:
-r Populate release notes with CDN download links
DOC_SOURCE:
path Path to AsciiDoctor doc source from the twistlock/docs repo
(default: current working directory)
"
}
clear_output_dir() {
# Delete all files in the output dir, except the .git dir.
glob="$output_dir""/*"
glob_expansion=($glob)
for p in "${glob_expansion[@]}"; do
rm -r "$p"
done
}
optspec=":r"
while getopts "${optspec}" opt; do
case "${opt}" in
r )
publish_cdn_links=true
;;
\?)
show_help
exit
;;
esac
done
shift "$((OPTIND-1))"
echo "Building static site..."
if [ "$1" != "" ]; then
doc_dir=$(dirname "$1")
else
doc_dir="."
fi
work_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
output_dir="$work_dir""/output"
srcAdmin="$doc_dir""/admin_guide"
srcRN="$doc_dir""/rn"
srcOps="$doc_dir""/ops_guide"
srcRefArch="$doc_dir""/ref_arch"
srcHistorical="$doc_dir""/historical"
srcTroubleshooting="$doc_dir""/troubleshooting"
# Delete previous build.
if [ -d "$output_dir" ]
then
rm -rf "$output_dir"
fi
# Delete Python virtualenv.
pyenv uninstall -f build_site_env
# Create output dir.
mkdir "$output_dir"
# Set up Python env.
echo "Set up Python env"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
pyenv virtualenv 3.7.4 build_site_env
pyenv activate build_site_env
pip install -r requirements.txt
# Initialize a git repo.
cd "$output_dir"
git init
git config user.name "build"
git config user.email "<>"
cd "$work_dir"
#
# ADMIN GUIDE (self-hosted)
#
# Copy admin guide files into place.
# https://stackoverflow.com/questions/3643848/copy-files-from-one-directory-into-an-existing-directory
echo "Copy admin guide files"
cp -R "$srcAdmin""/." "$output_dir"
cp -R "$work_dir""/_files/." "$output_dir"
# Rename topic map file.
mv "$output_dir""/_topic_map_compute_edition.yml" "$output_dir""/_topic_map.yml"
# Fix up doc tree source files.
python "_build/format_fixup.py" "$output_dir""/_topic_map.yml"
# Commit files.
cd "$output_dir"
git add -A
git commit -q -m "Commit admin guide (Compute Edition)"
#
# ADMIN GUIDE (SaaS)
#
# The second distro needs its own index file in the main branch.
cp "index-main.html" "index-main2.html"
git add -A
git commit -q -m "Commit index file for SaaS book"
# Create a branch
git checkout -b pcee
# Rename topic map file.
mv "$output_dir""/_topic_map_prisma_cloud.yml" "$output_dir""/_topic_map.yml"
# Commit files.
echo "Commit SaaS files"
git add -A
git commit -q -m "Commit admin guide (SaaS)"
#
# RELEASE NOTES
#
# Create a branch.
git checkout -b rn
# Delete all files.
clear_output_dir
# Copy files into place.
echo "Copy release notes files"
cd "$work_dir"
cp -R "$work_dir""/_files/." "$output_dir"
cp -R "$srcRN""/." "$output_dir"
mv "$output_dir""/_topic_map_static_site.yml" "$output_dir""/_topic_map.yml"
# Fix adoc source files
python "_build/format_fixup.py" "$output_dir""/_topic_map.yml"
if [ "$publish_cdn_links" == "true" ]; then
python rn_details.py "$output_dir""/_topic_map.yml" "../../release_info.yml"
fi
# Commit files.
echo "Commit release files"
cd "$output_dir"
git add -A
git commit -q -m "Commit release notes"
#
# OPS GUIDE
#
# Create a branch.
git checkout -b ops
# Delete all files.
clear_output_dir
# Copy files into place.
echo "Copy Ops Guide files"
cd "$work_dir"
cp -R "$work_dir""/_files/." "$output_dir"
cp -R "$srcOps""/." "$output_dir"
# Fix adoc source files
python "_build/format_fixup.py" "$output_dir""/_topic_map.yml"
# Commit files.
echo "Commit Ops Guide files"
cd "$output_dir"
git add -A
git commit -q -m "Commit Ops Guide"
#
# REFERENCE ARCHITECTURE
#
# Create a branch.
git checkout -b ref_arch
# Delete all files.
clear_output_dir
# Copy files into place.
echo "Copy Ref Arch files"
cd "$work_dir"
cp -R "$work_dir""/_files/." "$output_dir"
cp -R "$srcRefArch""/." "$output_dir"
# Fix adoc source files
python "_build/format_fixup.py" "$output_dir""/_topic_map.yml"
# Commit files.
echo "Commit Ref Arch files"
cd "$output_dir"
git add -A
git commit -q -m "Commit Ref Arch"
#
# HISTORICAL
#
# Create a branch.
git checkout -b historical
# Delete all files.
clear_output_dir
# Copy files into place.
echo "Copy Historical files"
cd "$work_dir"
cp -R "$work_dir""/_files/." "$output_dir"
cp -R "$srcHistorical""/." "$output_dir"
# Fix adoc source files
python "_build/format_fixup.py" "$output_dir""/_topic_map.yml"
# Commit files.
echo "Commit Historical files"
cd "$output_dir"
git add -A
git commit -q -m "Commit Historical"
#
# TROUBLESHOOTING
#
# Create a branch.
git checkout -b troubleshooting
# Delete all files.
clear_output_dir
# Copy files into place.
echo "Copy Troubleshooting files"
cd "$work_dir"
cp -R "$work_dir""/_files/." "$output_dir"
cp -R "$srcTroubleshooting""/." "$output_dir"
# Fix adoc source files (not required for the Troubleshooting content).
#python format_fixup.py "$output_dir""_topic_map.yml"
# Commit files.
echo "Commit Troubleshooting files"
cd "$output_dir"
git add -A
git commit -q -m "Commit Troubleshooting"
# Generate the static site.
# asciibinder_pan package -l debug
echo "Generate static site"
git checkout master
asciibinder_pan package
cd "$output_dir""/_package/main"
cp -R "../main2/enterprise_edition" "."