docker/mod/bbb-web/office-convert.sh

37 lines
861 B
Bash
Raw Normal View History

2021-04-02 18:23:05 +02:00
#!/bin/bash
2021-04-28 16:07:22 +02:00
set -e
set -u
PATH="/bin/:/usr/bin/"
2021-04-17 18:23:19 +02:00
# This script receives three params
2021-04-02 18:23:05 +02:00
# Param 1: Input office file path (e.g. "/tmp/test.odt")
# Param 2: Output pdf file path (e.g. "/tmp/test.pdf")
2021-04-17 18:23:19 +02:00
# Param 3: Destination Format (pdf default)
# Param 4: Timeout (secs) (optional)
2021-04-28 16:07:22 +02:00
if (( $# == 0 )); then
echo "Missing parameter 1 (Input office file path)";
exit 1
elif (( $# == 1 )); then
echo "Missing parameter 2 (Output pdf file path)";
exit 1
fi;
source="$1"
dest="$2"
2021-04-28 16:07:22 +02:00
# If output format is missing, define PDF
2021-04-17 18:23:19 +02:00
convertTo="${3:-pdf}"
2021-04-02 18:23:05 +02:00
# If timeout is missing, define 60
timeoutSecs="${4:-60}"
# Truncate timeout to max 3 digits (as expected by sudoers)
timeoutSecs="${timeoutSecs:0:3}"
# The timeout is important.
timeout $(printf %03d $timeoutSecs)s curl -F "data=@${source}" -k https://collabora:9980/cool/convert-to/$convertTo > "${dest}"
2021-04-02 18:23:05 +02:00
exit 0