Unverified Commit e79e9206 authored by Vít Starý Novotný's avatar Vít Starý Novotný
Browse files

Merge remote-tracking branch 'helper-scripts/master'

parents 9feb4dc0 c7388854
Loading
Loading
Loading
Loading
Loading
+15 −0
Original line number Original line Diff line number Diff line
#!/bin/bash
# Uploads an updated version of the Overleaf template for faculty $1 to
# Overleaf.
TMPDIR=`mktemp -d`
trap 'rm -rf $TMPDIR' EXIT

set -e
. overleaf-meta/$1/overleaf-upload.def
git clone https://git.overleaf.com/$DOCUMENT_ID $TMPDIR
rm -rf overleaf/$1/.git
mv $TMPDIR/.git overleaf/$1/.git
cd overleaf/$1
git add .
git commit -m "Uploaded new version." || true
git push

install-overleaf.sh

0 → 100755
+93 −0
Original line number Original line Diff line number Diff line
#!/bin/bash
# Prepares and submits the Overleaf archives for every workplace.
#
# Usage: ./install-overleaf.sh [OPTION...]
#
# Options:
#
#   --only-generate : only produces the dist/ and overleaf/ directories
#   --only-upload   : only uploads the overleaf/ directories to Overleaf over Git
#   --only-publish  : only publishes the Overleaf documents to Overleaf Gallery
set -e
shopt -s extglob
shopt -s nullglob

WORKPLACES=(arch ceitec cerit ctt czs econ fi fsps fss iba ics is kariera \
  lang law med mu muzeu ped phil press ptceitec rect sci skm teiresias ucb \
  uct)

if [[ $# != 0 && $1 != --only-publish && $1 != --only-upload && $1 != --only-generate ]]; then
  printf 'Unexpected "%s" parameter.\n' "$1" 2>&1
  exit 1
fi

if [[ $1 != --only-publish && $1 != --only-upload ]]; then

  # Clean up
  rm -rf /tmp/overleaf overleaf dist

  # Prepare the files
  xetex muletter.ins
  latexmk -pdf muletter.dtx
  latexmk -c muletter.dtx
  rm *.{bbl,bib,glo,gls,hd,run.xml}
  (cd example
   xetex example.ins)
  mkdir /tmp/overleaf
  
  for WORKPLACE in ${WORKPLACES[@]}; do
    TMPDIR=/tmp/overleaf/$WORKPLACE
    mkdir -p $TMPDIR/muletter
    # Copy top-level example files
    cp -v example/{$WORKPLACE{,-color}.tex,signature.pdf} muletter.cls $TMPDIR
    # Copy remaining files
    tar cv {label,logo}/muletter-$WORKPLACE-{english,czech}{,-color}.pdf locale/*.def \
      muletter.{dtx,pdf,ins} LICENSE.tex README.md | tar xC $TMPDIR/muletter
    (cd $TMPDIR
     # Typeset top-level example files
     for DOCUMENT in $WORKPLACE*.tex; do
        latexmk -pdf $DOCUMENT &
     done
     wait
     latexmk -c $WORKPLACE*.tex
     # Prepare a zip archive
     zip -r ../$WORKPLACE *)
  done
  
  mv -v /tmp/overleaf dist
  cp -v -r --reflink=always dist overleaf
  rm -v overleaf/{*.zip,*/muletter/*.*}
  for WORKPLACE in ${WORKPLACES[@]}; do
    rm -v overleaf/$WORKPLACE/$WORKPLACE*.pdf
  done

fi

if [[ $1 != --only-publish && $1 != --only-generate ]]; then

  # Upload to Git.
  parallel --halt=2 --bar --jobs 9 -- ./install-overleaf-git-upload.sh ::: ${WORKPLACES[@]}

fi

if [[ $1 != --only-upload && $1 != --only-publish && $1 != --only-generate ]]; then

  # Sleep for a while to make sure that Overleaf is aware that a new version
  # has been uploaded.
  sleep 5s

fi

if [[ $1 != --only-upload && $1 != --only-generate ]]; then

  # Publish to Overleaf gallery.
  parallel --halt=2 --bar --jobs 1 -- 'overleaf-upload {} && sleep 5s' ::: \
    `for WORKPLACE in ${WORKPLACES[@]}; do echo overleaf-meta/$WORKPLACE/overleaf-upload.def; done`

fi

if [[ $1 != --only-upload && $1 != --only-publish && $1 != --only-generate ]]; then

  rm -rf overleaf

fi
+8 −0
Original line number Original line Diff line number Diff line
TITLE='A Letter Template for the University Archives at the Masaryk University in Brno'
AUTHOR='Vít Novotný'
DESCRIPTION="<p>A template for muletter, a document class for the typesetting of letters at the Masaryk Univer­sity (Brno, Czech Repub­lic).</p>"
LICENSE=cc_by_4.0
SHOW_SOURCE=1

COOKIE_JAR=/home/witiko/cookies.txt
DOCUMENT_ID=5e49f6a5fc8943000103a528
+8 −0
Original line number Original line Diff line number Diff line
TITLE='A Letter Template for the Central European Institute of Technology at the Masaryk University in Brno'
AUTHOR='Vít Novotný'
DESCRIPTION="<p>A template for muletter, a document class for the typesetting of letters at the Masaryk University (Brno, Czech Republic).</p>"
LICENSE=cc_by_4.0
SHOW_SOURCE=1

COOKIE_JAR=/home/witiko/cookies.txt
DOCUMENT_ID=5e49f6c445064600010368eb
+8 −0
Original line number Original line Diff line number Diff line
TITLE='A Letter Template for CERIT at the Masaryk University in Brno'
AUTHOR='Vít Novotný'
DESCRIPTION="<p>A template for muletter, a document class for the typesetting of letters at the Masaryk Univer­sity (Brno, Czech Repub­lic).</p>"
LICENSE=cc_by_4.0
SHOW_SOURCE=1

COOKIE_JAR=/home/witiko/cookies.txt
DOCUMENT_ID=5e49f6be3107a20001fa2fc0
Loading