nutools/lib/nulib/templates/webpyapp/appshell

48 lines
1.3 KiB
Plaintext
Raw Normal View History

2018-04-26 23:19:17 +04:00
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
scriptdir="$(dirname -- "$0")"; scriptdir="$(cd "$scriptdir"; pwd)"
cd "$scriptdir"
appname="$(basename -- "$(pwd)")"
if [ -n "$NULIBDIR" -a "$NULIBDIR" == "$NULIBINIT" ]; then
: # nulib est déjà chargé
elif [ -f "$scriptdir/nulib/load.sh" ]; then
# mode développement
source "$scriptdir/nulib/load.sh"
elif [ -f /etc/nulib.sh ]; then
# mode production
source /etc/nulib.sh
else
echo "ERROR: impossible de trouver nulib" 1>&2
exit 1
fi
# Environnement
export BASEDIR="$scriptdir"
[ -n "$PYTHONPATH" ] && PYTHONPATH=":$PYTHONPATH"
export PYTHONPATH="$BASEDIR/config:$BASEDIR/python$PYTHONPATH"
# Paramètres
DEFAULT_PYTHON=python2.7
SLPATH=
VIRTUAL_ENV=
PYTHON=
source "$BASEDIR/config/server.conf"
if [ -n "$VIRTUAL_ENV" ]; then
PYTHON="$VIRTUAL_ENV/bin/python"
elif [ -z "$PYTHON" ]; then
PYTHON="$DEFAULT_PYTHON"
fi
# Répertoires contenant des librairies Python supplémentaires
if [ -n "$SLPATH" ]; then
export PYTHONPATH="$PYTHONPATH:$SLPATH"
[ -n "$LD_LIBRARY_PATH" ] && LD_LIBRARY_PATH="$LD_LIBRARY_PATH:"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$SLPATH"
fi
#
echo ">>> Shell Python pour $appname"
exec "$PYTHON" -i -c "$(<"$BASEDIR/config/appshell.py")"