Files
docker/latex/entrypoint.sh

51 lines
975 B
Bash
Executable File

#!/bin/sh
set -e
WORKDIR="$1"
INSTALL_HELPERS="$2"
EXTRA_ARGS="$3"
EXTRA_PKGS="$4"
if [ -n "$EXTRA_PKGS" ]; then
for pkg in $EXTRA_PKGS; do
echo "Install $pkg with pacman"
pacman -S "$pkg"
done
fi
if [ -n "$INSTALL_HELPERS" ]; then
if [ "$INSTALL_HELPERS" == "true" ]; then
CURR_DIR=$(pwd)
mkdir ~/projects/ || true
cd ~/projects/
git clone https://git.janishutz.com/janishutz/latex || true
echo "
Downloaded helpers, returning to $CURR_DIR
"
cd "$CURR_DIR"
fi
fi
echo "
Setting workdir from current dir, which is $(pwd)
"
if [ -n "$WORKDIR" ]; then
cd "$WORKDIR"
fi
echo "
Compiling document using latexmk with extra arguments: $EXTRA_ARGS
"
latexmk -pdf -latexoption=-file-line-error -latexoption=-interaction=nonstopmode -shell-escape $EXTRA_ARGS >/tmp/log.txt || compile_fail=1
if [ ${compile_fail:-0} -eq 1 ]; then
cat /tmp/log.txt
echo "
==> Compile has failed. See log above
"
else
echo "Compile successful, log omitted"
fi