server/launch.sh

55 lines
807 B
Bash
Raw Normal View History

2013-12-14 05:11:14 +00:00
#!/bin/sh
2014-01-14 15:14:31 +00:00
rm /tmp/stop
2013-12-14 05:11:14 +00:00
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
2014-01-14 15:14:31 +00:00
while ! [ -f /tmp/stop ];
2013-12-14 05:11:14 +00:00
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