#!/bin/sh BASEURL="localhost" SALT_TEAM="connected" OUT_TEAM="./teams" OUT_HTDOCS="./htdocs" MAX_PARAL=10 DEBUG=0 cd `dirname "$0"` if [ "$UID" = "0" ] then SCRIPT=`pwd`/`basename "$0"` su -c "sh -c '$SCRIPT $@'" synchro exit $? fi if [ -f "/tmp/generate_site" ] then echo "This script is already running" 1>&2 echo "Remove the file /tmp/generate_site if you are sure this is not true" 1>&2 exit 1 fi touch /tmp/generate_site WGET_OPT="--no-check-certificate -c" if [ $DEBUG -ne 1 ] then WGET_OPT="-q" fi ./clear_cache.sh top mkdir -p out ORIG_DIR=`pwd` MYTMPDIR=`mktemp -d` cd "$MYTMPDIR" # First, remove existing version if any rm -rf "$BASEURL" "$OUT_TEAM" wget $WGET_OPT -m -b "http://$BASEURL:8080/" -o /dev/null mkdir -p "$BASEURL" ln -sf "$ORIG_DIR/files/" "$BASEURL/files" # Get list of teams TEAMS= if [ $# -gt 0 ] then while [ $# -gt 0 ] do TEAMS="$TEAMS /$SALT_TEAM/$1/" shift done FULLSYNC=0 else for l in $(curl -k "http://$BASEURL:8080/$SALT_TEAM/" 2> /dev/null | grep -oE "/[^/]+/[0-9]+/") do TEAMS="$TEAMS $l" done FULLSYNC=1 fi echo "Team list to generate: $TEAMS" NB=0 PIDLIST= # Fetch them in parallel for l in $TEAMS do ( if ! wget $WGET_OPT -m "http://$BASEURL:8080/$l" then exit 1 fi for m in $(grep -R "
&2 exit $ERR else MOREOPT= if [ "$FULL" = "1" ] then MOREOPT="--delete" fi # Ok, now, sync files with prod rsync -av $MOREOPT * "$ORIG_DIR/out" cd "$ORIG_DIR" rm -rf "$MYTMPDIR" fi