From 1f90f617dab663ef6710cca74504cee4104c9a15 Mon Sep 17 00:00:00 2001
From: robjmcgibbon <robjmcgibbon@gmail.com>
Date: Tue, 27 May 2025 14:30:59 +0200
Subject: [PATCH] No errors from make_page

---
 make_page.sh | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/make_page.sh b/make_page.sh
index 2d5f92a..d2f2217 100755
--- a/make_page.sh
+++ b/make_page.sh
@@ -1,15 +1,18 @@
 #!/bin/bash
 
+set -e
+
 # Tested on winkel.strw.leidenuniv.nl
 module purge
 module load localhosts
 
-# Uncomment to create new venv
-# python -m venv venv
+# Create venv if it doesn't exist
+[ ! -d "venv" ] && python -m venv venv
 source venv/bin/activate
-
+pip install --upgrade pip
 pip install -r requirements.txt
 
+# Create main webpage
 git pull
 rm -r gallery
 cp -r /home/mcgibbon/public_html/SWIFT/webpage_image_gallery gallery
@@ -20,31 +23,31 @@ rsync -auv compiled/* ../
 
 [ ! -d "swift" ] && git clone "git@gitlab.cosma.dur.ac.uk:swift/swiftsim.git" "swift"
 cd swift
-git checkout master
+[ "$(git rev-parse --abbrev-ref HEAD)" != "master" ] && git checkout master
 git pull
 # Generate read the docs
 cd doc/RTD
-rm -rf build
+[ -d "build" ] && rm -rf build
 make html > docbuild.out 2> docbuild.err
 # Generate onboarding guide
 cd ../onboardingGuide
-rm -rf build
+[ -d "build" ] && rm -rf build
 make latexpdf > onbuild.out 2> onbuild.err
 # Copy both to webpage
 cd ../../..
-rm -rf ../docs/*
+[ -d "../docs" ] && rm -rf ../docs
 cp -r swift/doc/RTD/build/html/ ../docs
 cp swift/doc/onboardingGuide/build/latex/onboarding.pdf ../onboarding.pdf
  
 # Generate read the docs for the zoom branch
 [ ! -d "swift_will" ] && git clone "git@gitlab.cosma.dur.ac.uk:swift/swiftsim.git" "swift_will"
 cd swift_will
-git checkout zoom_docs
+[ "$(git rev-parse --abbrev-ref HEAD)" != "zoom_docs" ] && git checkout zoom_docs
 git pull
 cd doc/RTD
-rm -rf build
+[ -d "build" ] && rm -rf build
 make html > docbuild.out 2> docbuild.err
 cd ../../..
-rm -rf ../docs_will/*
+[ -d "../docs_will" ] && rm -rf ../docs_will
 cp -r swift_will/doc/RTD/build/html/ ../docs_will
 
-- 
GitLab