forked from OWASP/CheatSheetSeries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Generate_Site.sh
46 lines (46 loc) · 1.8 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
#!/bin/bash
# Dependencies:
# sudo apt install -y nodejs
# sudo npm install gitbook-cli -g
# Note:
# PDF generation is not possible because the content is cutted 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."
python Update_CheatSheets_Index.py
python Generate_CheatSheets_TOC.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/.
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
echo "Step 5/5: Cleanup."
rm -rf cheatsheets
rm -rf node_modules
rm book.json
echo "Generation finished to the folder: $WORK/$GENERATED_SITE"