-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfromwebtopdf.sh
executable file
·114 lines (100 loc) · 1.69 KB
/
fromwebtopdf.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
#!/bin/bash
cd $(dirname $0)
source ./src/config.sh
rebuild=0
clean=0
log=0
parallel_runs=$default_parallel_runs
function get_args {
while [[ $# -gt 0 ]]
do
arg=$1
case $arg in
-r|--rebuild)
rebuild=1
shift
;;
-c|--clean)
clean=1
shift
;;
-l|--log)
log=1
shift
;;
-p|--parallel)
parallel_runs=$2
shift
shift
;;
-i|--input)
list=$2
shift
shift
;;
-h|--help)
cat "./src/helper.txt"
exit
;;
*)
echo "Error: Unknow option \"$1\""
exit 1
;;
esac
done
}
function init {
if [ $clean = 1 ]
then
rm -f log-*.txt
rm -f fail-*.txt
fi
if [ $log = 0 ]
then
log_file="/dev/null"
fi
if [ ! -d "./dist" ]
then
mkdir "./dist"
fi
}
function check_list {
if [ -z $list ]
then
echo "Error: You have to specify a list"
exit 1
else
if [ ! -f $list ]
then
echo "Error: The specified list does not exist"
exit 1
fi
fi
}
function build_docker_image {
echo -ne "[..] Build docker image (This may take a long time)\r"
if [ $rebuild = 1 ]
then
docker build --no-cache -t fromwebtopdf -f ./docker/Dockerfile . >> $log_file
else
docker build -t fromwebtopdf -f ./docker/Dockerfile . >> $log_file
fi
if [ $? = 0 ]
then
echo -e "[${GREEN}OK${NORMAL}]"
else
echo -e "[${RED}KO${NORMAL}]"
exit 1
fi
}
function launch_container {
docker run $docker_flags fromwebtopdf /mnt/src/generator.sh $list $log_file $fail_file $parallel_runs
}
function main {
get_args $@
init
check_list
build_docker_image
launch_container
}
main $@