forked from alu0101238944/savvily-book-converter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert.sh
executable file
·59 lines (49 loc) · 1.27 KB
/
convert.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
#!/bin/sh
set -e
if [ $# -eq 1 ]; then
echo "Sorry, I need a valid manuscript path to work"
exit 1
elif [ $# -eq 2 ]; then
manuscript=$2
else
echo "Wrong input"
exit 1
fi
case "$1" in
-p | --print) scriptToRun="python3 -B src/pdf-print.py .tmp-manuscript" ;;
-lp | --legacy-print) scriptToRun="python3 -B src/pdf-print.py legacy .tmp-manuscript" ;;
\
-s | --screen) scriptToRun="python3 -B src/pdf-screen.py .tmp-manuscript" ;;
-ls | --legacy-screen) scriptToRun="python3 -B src/pdf-screen.py legacy .tmp-manuscript" ;;
\
-e | --epub) scriptToRun="python3 -B src/epub.py .tmp-manuscript" ;;
-le | --legacy-epub) scriptToRun="python3 -B src/epub.py legacy .tmp-manuscript" ;;
\
-a | --all)
./convert.sh -e "$manuscript"
./convert.sh -p "$manuscript"
./convert.sh -s "$manuscript"
exit
;;
-la | --legacy-all)
./convert.sh -le "$manuscript"
./convert.sh -lp "$manuscript"
./convert.sh -ls "$manuscript"
exit
;;
\
*)
printf "Unknown option %s\n" "$1"
exit 1
;;
esac
if [ -d .tmp-manuscript ]; then
rm -rf .tmp-manuscript
fi
mkdir -p .tmp-manuscript && cp -r "$manuscript"/* ./.tmp-manuscript
docker run --rm \
--volume "$PWD":/data \
-u "$(id -u "$USER"):$(id -g "$USER")" \
savvily-book-generator \
"$scriptToRun"
rm -rf .tmp-manuscript