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)
|
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-17 18:23:19 +02:00
|
|
|
#If output format is missing, define PDF
|
|
|
|
convertTo="${3:-pdf}"
|
2021-04-02 18:23:05 +02:00
|
|
|
|
2021-04-17 18:23:19 +02:00
|
|
|
curl -v -X POST "http://jodconverter:8080/lool/convert-to/$convertTo" \
|
2021-04-02 18:23:05 +02:00
|
|
|
-H "accept: application/octet-stream" \
|
|
|
|
-H "Content-Type: multipart/form-data" \
|
2021-04-28 16:07:22 +02:00
|
|
|
-F "data=@${source}" > ${dest}
|
2021-04-02 18:23:05 +02:00
|
|
|
|
|
|
|
exit 0
|