54 lines
780 B
Bash
54 lines
780 B
Bash
|
#!/bin/sh
|
||
|
|
||
|
cd `dirname "$0"`
|
||
|
|
||
|
if [ "$UID" = "0" ]
|
||
|
then
|
||
|
SCRIPT=`pwd`/`basename "$0"`
|
||
|
su -c "sh $SCRIPT" synchro
|
||
|
exit $?
|
||
|
fi
|
||
|
|
||
|
touch ./logs/checks.log
|
||
|
tail -f ./logs/checks.log &
|
||
|
|
||
|
FULLREGEN=0
|
||
|
|
||
|
while true;
|
||
|
do
|
||
|
if [ "$FULLREGEN" != "0" ]
|
||
|
then
|
||
|
./synchro.sh
|
||
|
else
|
||
|
./synchro.sh delete
|
||
|
fi
|
||
|
|
||
|
if [ `ls submission | wc -l` -gt 1 ]
|
||
|
then
|
||
|
TMPF=`mktemp`
|
||
|
if ! ./check.pl 2>> ./logs/checks.log > "$TMPF"
|
||
|
then
|
||
|
FULLREGEN=1
|
||
|
fi
|
||
|
|
||
|
if [ `cat "$TMPF" | wc -l` -gt 0 ]
|
||
|
then
|
||
|
while ! cat "$TMPF" | xargs ./gen_site.sh
|
||
|
do
|
||
|
echo "FAIL regeneration, retry..." 1>&2
|
||
|
done
|
||
|
fi
|
||
|
rm "$TMPF"
|
||
|
|
||
|
elif [ "$FULLREGEN" != "0" ]
|
||
|
then
|
||
|
while ! ./gen_site.sh; do
|
||
|
echo "FAIL regeneration, retry..." 1>&2
|
||
|
done
|
||
|
FULLREGEN=0
|
||
|
|
||
|
else
|
||
|
sleep 1
|
||
|
fi
|
||
|
done
|