-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate.sh
executable file
·46 lines (38 loc) · 1.05 KB
/
generate.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
#
# This script executes all generator scripts in an input directory.
#
# Arguments:
# 1: Input directory path
# 2: Output directory path
#
# Author: Mirko Myllykoski ([email protected]), 2020
#
set -e
INPUT_DIR=`realpath "${1}"`
OUTPUT_DIR=`realpath "${2}"`
[[ -d "${INPUT_DIR}" ]] || exit 1
# source include files
for d in `ls "include/"`; do
source include/${d}
done
function generate {
echo "Generate \"${1}\""
mkdir -p "${OUTPUT_DIR}/${1}"
(
cd "${OUTPUT_DIR}/${1}"
rsync -a --exclude='generate.sh' --exclude='LECTURE.md' --delete "${INPUT_DIR}/${1}/" "./"
if [ -f "${INPUT_DIR}/${1}/generate.sh" ]; then
. "${INPUT_DIR}/${1}/generate.sh" 2>&1 | sed 's/^/ /'
fi
# if command -v pandoc &> /dev/null && [ -f "${INPUT_DIR}/${1}/LECTURE.md" ]; then
# pandoc -t beamer LECTURE.md -o test.pdf
# fi
)
for d in `ls "${INPUT_DIR}/${1}"`; do
if [ -d "${INPUT_DIR}/${1}/${d}" ]; then
generate "${1}/${d}"
fi
done
}
generate ""