Document some script + centralize script configuration

This commit is contained in:
nemunaire 2014-11-19 18:29:46 +01:00
parent 9a57642029
commit 96805a5e1b
7 changed files with 49 additions and 15 deletions

View File

@ -1,21 +1,24 @@
#!/bin/sh
cd `dirname "$0"`
TO_BCKP="/mnt/backup"
# This script mades backup of important things
chown synchro "$TO_BCKP"
cd `dirname "$0"`
source config.sh
chown "$SYNCHRO_USER" "$TO_BCKP"
if [ "$UID" = "0" ]
then
SCRIPT=`pwd`/`basename "$0"`
su -c "sh $SCRIPT $@" synchro
su -c "sh $SCRIPT $@" "$SYNCHRO_USER"
exit $?
fi
if mount | grep "$TO_BCKP" > /dev/null
then
mysqldump -u backup --password="Riuy6of sae^W0Sh" fic > "$TO_BCKP"/db/`date +%Y%m%d-%H%M`.sql
mysqldump -u backup --password="$BCKP_PASS" fic > "$TO_BCKP"/db/`date +%Y%m%d-%H%M`.sql
rsync -avL misc "$TO_BCKP"
rsync -avL .git "$TO_BCKP"
@ -24,5 +27,5 @@ then
rsync -avL true_files "$TO_BCKP"
else
echo No volume mount on $TO_BCKP
echo No volume mounted on $TO_BCKP
fi

View File

@ -1,7 +1,11 @@
#!/bin/sh
# This script deletes Onyx framework cache
cd `dirname "$0"`
source config.sh
for n in "$@"
do
MD5=`echo -n $n | md5sum | cut -d " " -f 1`

11
config.sh Normal file
View File

@ -0,0 +1,11 @@
# The name of the frontend, like indicated in /etc/hosts
FRONTEND_HOSTNAME="phobos"
# Username of the unpriviledge user that runs scripts
SYNCHRO_USER="synchro"
# Directory where backup should be made
TO_BCKP="/mnt/backup"
# Password of the MySQL user backup (with RO rights)
BCKP_PASS="Riuy6of sae^W0Sh"

View File

@ -1,12 +1,16 @@
#!/bin/sh
# This script does all actions in backend production environment
rm -f /tmp/stop
cd `dirname "$0"`
source config.sh
if [ "$UID" = "0" ]
then
SCRIPT=`pwd`/`basename "$0"`
su -c "sh $SCRIPT" synchro
su -c "sh $SCRIPT" "$SYNCHRO_USER"
exit $?
fi

View File

@ -1,3 +1,6 @@
#!/bin/sh
# Generate from database (exported XML from the website) the part of nginx
# configuration file authenticating teams
curl http://localhost/admin/teams/export 2> /dev/null | grep "<name id" | sed -E 's@^.*id="([0-9]+)".*>(.*)<.*$@ if ($ssl_client_s_dn ~ "/C=FR/ST=France/O=Epita/OU=SRS/CN=\2/") { set $team \1; }@'

View File

@ -1,3 +1,5 @@
#!/bin/sh
# Best way to stop the launch.sh script
touch /tmp/stop

View File

@ -1,11 +1,16 @@
#!/bin/sh
# This script synchronizes first, the generated frontend and then
# retrieves submissions
cd `dirname "$0"`
source config.sh
if [ "$UID" = "0" ]
then
SCRIPT=`pwd`/`basename "$0"`
su -c "sh $SCRIPT $@" synchro
su -c "sh $SCRIPT $@" "$SYNCHRO_USER"
exit $?
fi
@ -15,13 +20,15 @@ then
OPTS="$OPTS --delete"
fi
rsync -e ssh -av $OPTS out/errors phobos:~/
rsync -e ssh -av $OPTS out/htdocs phobos:~/
rsync -e ssh -av $OPTS out/teams phobos:~/
rsync -e ssh -avL $OPTS files phobos:~/
rsync -e ssh -av $OPTS nginx.conf submission.php misc/server.crt misc/server.key misc/pki/cacert.crt misc/pki/crl.pem phobos:~/
# Synchronize HTML pages
rsync -e ssh -av $OPTS out/errors "$FRONTEND_HOSTNAME":~/
rsync -e ssh -av $OPTS out/htdocs "$FRONTEND_HOSTNAME":~/
rsync -e ssh -av $OPTS out/teams "$FRONTEND_HOSTNAME":~/
rsync -e ssh -avL $OPTS files "$FRONTEND_HOSTNAME":~/
rsync -e ssh -av $OPTS nginx.conf submission.php misc/server.crt misc/server.key misc/pki/cacert.crt misc/pki/crl.pem "$FRONTEND_HOSTNAME":~/
rsync -e ssh -av phobos:~/submission/ submission/
ssh phobos "rm -fv ~/submission/*"
# Synchronize submissions
rsync -e ssh -av "$FRONTEND_HOSTNAME":~/submission/ submission/
ssh "$FRONTEND_HOSTNAME" "rm -fv ~/submission/*"
exit $?