From fe9d0941e26fc659638526927f4334ae3d0fb96d Mon Sep 17 00:00:00 2001 From: nemunaire Date: Fri, 19 Jan 2018 15:20:39 +0100 Subject: [PATCH] synchro: add synchronization script --- configs/synchro.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 configs/synchro.sh diff --git a/configs/synchro.sh b/configs/synchro.sh new file mode 100644 index 00000000..4d50b826 --- /dev/null +++ b/configs/synchro.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# This script synchronizes first, the generated frontend and then +# retrieves submissions + +BASEDIR="/srv" +FRONTEND_HOSTNAME="deimos" + +SSH_OPTS="/usr/bin/ssh -p 22 -i ~/.ssh/id_ed25519 -o ControlMaster=auto -o ControlPath=/root/.ssh/%r@%h:%p -o ControlPersist=2 -o PasswordAuthentication=no -o StrictHostKeyChecking=no" + +cd "${BASEDIR}" + +# Synchronize CA +rsync -e "$SSH_OPTS" -av --delete PKI/shared "${FRONTEND_HOSTNAME}":"${BASEDIR}"/PKI + +I=0 + +touch /tmp/stop +while ! [ -f SETTINGS/stop ] || [ /tmp/stop -nt SETTINGS/stop ] +do + # Synchronize static files pages + rsync -e "$SSH_OPTS" -av --delete TEAMS SETTINGS FILES "${FRONTEND_HOSTNAME}":"${BASEDIR}" + + # Synchronize submissions + rsync -e "$SSH_OPTS" -av --delay-updates --temp-dir=.tmp/ --partial-dir=.tmp/ --remove-source-files "${FRONTEND_HOSTNAME}":"${BASEDIR}"/submissions/ submissions/ + + sleep 0.3 +done + +echo See you