|
|
@ -8,13 +8,6 @@ BINDIP=0.0.0.0 |
|
|
|
export FLASK_APP=nfgame.py |
|
|
|
export FLASK_APP=nfgame.py |
|
|
|
export NFGAME_SETTINGS=nfgame.cfg |
|
|
|
export NFGAME_SETTINGS=nfgame.cfg |
|
|
|
|
|
|
|
|
|
|
|
# If working in debug mode |
|
|
|
|
|
|
|
if [[ $1 == 'debug' ]]; then |
|
|
|
|
|
|
|
export FLASK_DEBUG=1 |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
export FLASK_DEBUG=0 |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If the database does not exists, create it. |
|
|
|
# If the database does not exists, create it. |
|
|
|
if [ ! -f nfgame.db ]; then |
|
|
|
if [ ! -f nfgame.db ]; then |
|
|
|
python -m flask initdb |
|
|
|
python -m flask initdb |
|
|
@ -22,6 +15,27 @@ fi |
|
|
|
|
|
|
|
|
|
|
|
if [ ! -f nfgame.cfg ]; then |
|
|
|
if [ ! -f nfgame.cfg ]; then |
|
|
|
echo "Please copy nfgame.cfg-example to nfgame.cfg and edit the options!" |
|
|
|
echo "Please copy nfgame.cfg-example to nfgame.cfg and edit the options!" |
|
|
|
else |
|
|
|
exit 1 |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If working in debug mode |
|
|
|
|
|
|
|
if [[ $1 == 'start' ]]; then |
|
|
|
|
|
|
|
if [[ $2 == 'debug' ]]; then |
|
|
|
|
|
|
|
export FLASK_DEBUG=1 |
|
|
|
python -m flask run --host=$BINDIP --port=$RUNPORT |
|
|
|
python -m flask run --host=$BINDIP --port=$RUNPORT |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
if [ -f twistd.pid ]; then |
|
|
|
|
|
|
|
echo "Game is still running." |
|
|
|
|
|
|
|
echo "Stop the game first, or remove the file twistd.pid" |
|
|
|
|
|
|
|
exit 1 |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
twistd web --port $RUNPORT --logfile=nfgame.log --wsgi=nfgame.app |
|
|
|
|
|
|
|
echo "Game is started!" |
|
|
|
|
|
|
|
echo "Have fun!" |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [[ $1 == 'stop' ]]; then |
|
|
|
|
|
|
|
kill `cat twistd.pid` |
|
|
|
|
|
|
|
echo "Game is over!" |
|
|
|
fi |
|
|
|
fi |
|
|
|