-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.sh
executable file
·93 lines (79 loc) · 1.4 KB
/
publish.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
#!/usr/bin/env bash
set -euo pipefail
script_lock=$(dirname "${0}")/"publish_lock_dir"
readonly script_lock
function is_already_running()
{
declare -i return_value=0
test -d "${script_lock}" ||
{
return_value=1
}
return "${return_value}"
}
function create_lock()
{
mkdir "${script_lock}" ||
{
printf "Cannot create lock\n"
exit 2
}
}
function remove_lock()
{
rm -rf "${script_lock}" ||
{
printf "Cannot remove lock\n"
exit 3
}
}
if is_already_running
then
printf "Cannot acquire lock (another instance is running?) - exiting.\n"
exit 1
fi
create_lock
./ubuntu_local_build.sh ||
{
remove_lock
printf "Cannot build document.\n"
exit 4
}
if [[ $(find ./*.pdf | wc -l) -ne 1 ]]
then
remove_lock
printf "Unexpected number of documents.\n"
exit 5
fi
output_folder=$(./get_output_folder.sh) ||
{
remove_lock
printf "Cannot get the result folder\n"
exit 5
}
readonly output_folder
rm -rf "$output_folder" ||
{
remove_lock
printf "Cannot clean results folder.\n"
exit 6
}
mkdir "$output_folder" ||
{
remove_lock
printf "Cannot create results folder.\n"
exit 7
}
mv ./*.pdf "$output_folder" ||
{
remove_lock
printf "Cannot move document to the result folder.\n"
exit 8
}
./generate_checksums.sh ||
{
remove_lock
printf "Cannot create checksums.\n"
exit 9
}
remove_lock