forked from OWASP/CheatSheetSeries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Generate_Site.sh
55 lines (55 loc) · 2.28 KB
/
Generate_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
#!/bin/bash
# Dependencies:
# sudo apt install -y nodejs
# sudo npm install gitbook-cli -g
# Note:
# PDF generation is not possible because the content is cut in
# some CS like for example the abuse case one
GENERATED_SITE=site
WORK=../generated
echo "Generate a offline portable website with all the cheat sheets..."
echo "Step 1/5: Init work folder."
rm -rf $WORK 1>/dev/null 2>&1
mkdir $WORK
mkdir $WORK/cheatsheets
echo "Step 2/5: Generate the summary markdown page and the RSS News feed."
python Update_CheatSheets_Index.py
python Generate_CheatSheets_TOC.py
python Generate_RSS_Feed.py
echo "Step 3/5: Create the expected GitBook folder structure."
cp ../book.json $WORK/.
cp ../Preface.md $WORK/cheatsheets/.
mv TOC.md $WORK/cheatsheets/.
mv News.xml $WORK/.
cp -r ../cheatsheets $WORK/cheatsheets/cheatsheets
cp -r ../assets $WORK/cheatsheets/assets
cp ../Index.md $WORK/cheatsheets/cheatsheets/Index.md
cp ../IndexASVS.md $WORK/cheatsheets/cheatsheets/IndexASVS.md
cp ../IndexProactiveControls.md $WORK/cheatsheets/cheatsheets/IndexProactiveControls.md
sed -i 's/assets\//..\/assets\//g' $WORK/cheatsheets/cheatsheets/Index.md
sed -i 's/assets\//..\/assets\//g' $WORK/cheatsheets/cheatsheets/IndexASVS.md
sed -i 's/assets\//..\/assets\//g' $WORK/cheatsheets/cheatsheets/IndexProactiveControls.md
sed -i 's/cheatsheets\///g' $WORK/cheatsheets/cheatsheets/Index.md
sed -i 's/cheatsheets\///g' $WORK/cheatsheets/cheatsheets/IndexASVS.md
sed -i 's/cheatsheets\///g' $WORK/cheatsheets/cheatsheets/IndexProactiveControls.md
echo "Step 4/5: Generate the site."
cd $WORK
gitbook install --log=error
gitbook build . $WORK/$GENERATED_SITE --log=info
if [[ $? != 0 ]]
then
echo "Error detected during the generation of the site, generation failed!"
exit 1
fi
# Move the generated RSS feed
mv News.xml site/.
# Replace the default favicon by the OWASP one
# I did not achieve to find a stable and "trustable" gitbook plugin to do that
# So I only replace the default images: https://www.npmjs.com/search?q=gitbook%20favicon
cp ../assets/WebSite_Favicon.png site/gitbook/images/apple-touch-icon-precomposed-152.png
cp ../assets/WebSite_Favicon.ico site/gitbook/images/favicon.ico
echo "Step 5/5: Cleanup."
rm -rf cheatsheets
rm -rf node_modules
rm book.json
echo "Generation finished to the folder: $WORK/$GENERATED_SITE"