#! /bin/bash # Adapted from github.com/gkilleen33/overleaf-offline under the MIT license # .autoltx file contents as per line numbers: # 1. build date in epoch, for checking for updates. # CD into the main directory echo cd /app/project || exit 2 if test -d "pdf/"; then rm -r pdf/ fi requiresUpdate=0 settingsExists=0 # Check for updates if test -f "/app/project/.autoltx"; then buildDate=`cat /app/setupFiles/buildDate` installedVersion=`sed -n "1p" /app/project/.autoltx` settingsExists=1 if [[ installedVersion -eq buildDate ]]; then requiresUpdate=0 echo AutoLTX already installed, skipping steup... else requiresUpdate=1 echo Found old AutoLTX files, updating... fi else echo "1" > /app/project/.autoltx requiresUpdate=1 echo AutoLTX not installed, configuring... fi # Update files if necessary if [[ requiresUpdate -eq 1 ]]; then # Add latexmk rc file to build files cp /app/setupFiles/latexmkrc /app/project/ # Add compile script to build files cp /app/setupFiles/compile.sh /app/project/ chmod +x compile.sh if test -f "/app/project/.gitignore"; then # Adding build files to .gitignore grep -qxF 'pdf/' .gitignore || echo 'pdf/' >> .gitignore grep -qxF 'latexmkrc' .gitignore || echo 'latexmkrc' >> .gitignore grep -qxF 'compile.sh' .gitignore || echo 'compile.sh' >> .gitignore grep -qxF '.autoltx' .gitignore || echo '.autoltx' >> .gitignore grep -qxF 'output.pdf' .gitignore || echo 'output.pdf' >> .gitignore grep -qxF '*.aux' .gitignore || echo '*.aux' >> .gitignore else # Creates .gitignore file echo Configuring .gitignore for this project printf 'pdf/\nlatexmkrc\ncompile.sh\n.autoltx\noutput.pdf\n*.aux\n' >> /app/project/.gitignore fi sed -i "1s/.*/$buildDate/" /app/project/.autoltx fi echo