-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathunoconv
executable file
·57 lines (49 loc) · 1.45 KB
/
unoconv
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
#!/bin/bash
if [ -z "$COOG_CODE_DIR" ] || [ ! -d "$COOG_CODE_DIR" ] || [ -z "$COOG_DATA_DIR" ]
then
{
echo "Please make sure that these two env vars are set:"
echo " COOG_CODE_DIR: your coog-admin install folder"
echo " COOG_DATA_DIR: the folder where to keep your custom config"
} >&2 && exit 1
fi
_build() {
( cd "$COOG_CODE_DIR/images/unoconv" && ./build "$@" )
}
_run() {
local args
[ -d "$COOG_FONT_DIR" ] && \
args="$args -v $COOG_FONT_DIR:/usr/share/fonts"
docker run \
$args \
$DOCKER_DAEMON_OPTS \
--network "$NETWORK_NAME" \
--name "$NETWORK_NAME-unoconv" \
"$UNOCONV_IMAGE"
}
_docker() {
docker "$@" "$NETWORK_NAME-unoconv"
}
usage() {
echo
echo Available commands
echo
echo " build -> builds unoconv image"
echo " run -> runs a unoconv docker image"
echo " <action> -> calls docker action on unoconv container"
echo
echo "Fonts installed in \$COOG_FONT_DIR (default = /usr/share/fonts) "
echo "will be available when printing."
echo "To install a new font, place it in the appropriate sub-folder, "
echo "then run the \"fc-cache -f -v\" command."
echo
}
main() {
source "$COOG_CODE_DIR/config"
[ -z "$1" ] && usage && return 0
local cmd; cmd="$1"; shift
[ "$cmd" = "build" ] && { _build "$@"; return $?; }
[ "$cmd" = "run" ] && { _run; return $?; }
_docker "$cmd" "$@"
}
main "$@"