implement update system, cleaned output text
All checks were successful
/ Build Container (push) Successful in 1h12m54s

This commit is contained in:
2025-10-05 13:23:40 +05:30
parent fc64e871b9
commit c510c102f7
4 changed files with 49 additions and 26 deletions

View File

@@ -1,6 +1,9 @@
#! /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
cd /app/project || exit 2
@@ -8,29 +11,47 @@ if test -d "pdf/"; then
rm -r pdf/
fi
# Update old installation
if test -f ".autoltxXenon"; then # Intentional wrong file name checking, to ensure the files are updated everytime the container starts. To implement version checking in later version.
echo AutoLTX already installed, skipping steup
else
if test -f ".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
touch .autoltx
echo Configuring AutoLTX for this project
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
# Creating .gitignore file
printf 'pdf/\nlatexmkrc\ncompile.sh\n.autoltx\noutput.pdf\n' >> .gitignore
touch .autoltx
requiresUpdate=1
echo Found old AutoLTX files, updating...
fi
# 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
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
else
# Creates .gitignore file
echo Configuring .gitignore for this project
printf 'pdf/\nlatexmkrc\ncompile.sh\n.autoltx\noutput.pdf\n' >> /app/project/.gitignore
fi
sed -i "1s/.*/$buildDate/" /app/project/.autoltx
fi