2017-10-23 02:47:26 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
BASE=/app
|
2017-11-24 19:37:40 +00:00
|
|
|
DATA=$BASE/data
|
2017-10-23 02:47:26 +00:00
|
|
|
|
2017-11-24 19:37:40 +00:00
|
|
|
if [ ! -f "$BASE/oj/custom_settings.py" ]; then
|
|
|
|
echo SECRET_KEY=\"$(cat /dev/urandom | head -1 | md5sum | head -c 32)\" >> $BASE/oj/custom_settings.py
|
2017-10-23 02:47:26 +00:00
|
|
|
fi
|
|
|
|
|
2017-11-24 19:37:40 +00:00
|
|
|
mkdir -p $DATA/log $DATA/testcase $DATA/public/upload
|
2017-10-23 02:47:26 +00:00
|
|
|
|
|
|
|
cd $BASE
|
2017-10-23 12:59:44 +00:00
|
|
|
|
|
|
|
n=0
|
2017-11-24 19:37:40 +00:00
|
|
|
while [ $n -lt 5 ]
|
2017-10-23 12:59:44 +00:00
|
|
|
do
|
2017-11-24 19:37:40 +00:00
|
|
|
python manage.py migrate --no-input &&
|
|
|
|
python manage.py initinstall &&
|
|
|
|
break
|
|
|
|
n=$(($n+1))
|
|
|
|
echo "Failed to migrate, going to retry..."
|
|
|
|
sleep 8
|
2017-10-23 12:59:44 +00:00
|
|
|
done
|
|
|
|
|
2017-11-24 19:37:40 +00:00
|
|
|
cp $BASE/deploy/oj.conf /etc/nginx/conf.d/default.conf
|
2017-10-23 12:59:44 +00:00
|
|
|
|
2017-11-24 19:37:40 +00:00
|
|
|
chown -R nobody:nogroup $DATA $BASE/dist
|
2017-10-23 12:59:44 +00:00
|
|
|
exec supervisord -c /app/deploy/supervisor.conf
|