2018-01-19 14:20:39 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# This script synchronizes first, the generated frontend and then
|
|
|
|
# retrieves submissions
|
|
|
|
|
|
|
|
BASEDIR="/srv"
|
2023-07-25 05:36:44 +00:00
|
|
|
FRONTEND_HOSTNAME="phobos"
|
2018-01-19 14:20:39 +00:00
|
|
|
|
2022-08-06 20:31:18 +00:00
|
|
|
SSH_OPTS="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"
|
2018-01-19 14:20:39 +00:00
|
|
|
|
|
|
|
cd "${BASEDIR}"
|
|
|
|
|
2020-01-16 14:55:08 +00:00
|
|
|
touch /tmp/stop
|
2018-01-19 14:20:39 +00:00
|
|
|
|
2022-06-02 08:47:09 +00:00
|
|
|
# Establish first ssh connection for controlpersist socket, to avoid delay during time synchronization
|
2022-08-06 20:31:18 +00:00
|
|
|
${SSH_OPTS} ${FRONTEND_HOSTNAME} ls > /dev/null
|
2022-06-02 08:47:09 +00:00
|
|
|
|
|
|
|
# Synchronize the date one time
|
2022-08-06 20:31:18 +00:00
|
|
|
${SSH_OPTS} ${FRONTEND_HOSTNAME} date -s @"$(date +%s)"
|
2022-06-02 08:47:09 +00:00
|
|
|
|
2020-01-16 14:55:08 +00:00
|
|
|
# Synchronize static files in a separate loop (to avoid submissions delays during file synchronization)
|
|
|
|
while ! [ -f SETTINGS/stop ] || [ /tmp/stop -nt SETTINGS/stop ]
|
|
|
|
do
|
|
|
|
rsync -e "$SSH_OPTS" -av --delete FILES "${FRONTEND_HOSTNAME}":"${BASEDIR}"
|
|
|
|
|
2020-01-30 17:51:06 +00:00
|
|
|
# Synchronize logs
|
|
|
|
rsync -e "$SSH_OPTS" -av "${FRONTEND_HOSTNAME}":/var/log/ /var/log/frontend
|
|
|
|
|
2020-01-16 14:55:08 +00:00
|
|
|
sleep 5
|
|
|
|
done &
|
2018-01-19 14:20:39 +00:00
|
|
|
|
|
|
|
while ! [ -f SETTINGS/stop ] || [ /tmp/stop -nt SETTINGS/stop ]
|
|
|
|
do
|
|
|
|
# Synchronize static files pages
|
2024-03-27 20:27:24 +00:00
|
|
|
rsync -e "$SSH_OPTS" -av --delete --delay-updates --partial-dir=.tmp/ PKI TEAMS SETTINGSDIST "${FRONTEND_HOSTNAME}":"${BASEDIR}"
|
2018-01-19 14:20:39 +00:00
|
|
|
|
|
|
|
# Synchronize submissions
|
2019-02-05 02:18:39 +00:00
|
|
|
rsync -e "$SSH_OPTS" -av --ignore-existing --delay-updates --temp-dir=.tmp/ --partial-dir=.tmp/ --remove-source-files "${FRONTEND_HOSTNAME}":"${BASEDIR}"/submissions/ submissions/
|
2018-01-19 14:20:39 +00:00
|
|
|
|
|
|
|
sleep 0.3
|
|
|
|
done
|
|
|
|
|
2020-01-16 14:55:08 +00:00
|
|
|
wait
|
2018-01-19 14:20:39 +00:00
|
|
|
echo See you
|