forked from ScoDoc/ScoDoc
54 lines
1.3 KiB
Bash
54 lines
1.3 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
# Lancement d'un python scodoc interactif
|
||
|
# dans l'environnement d'un département
|
||
|
# et avec chargement des scripts indiqués
|
||
|
# via from ... import *
|
||
|
#
|
||
|
# Si -r est utilisé, veiller à créer au préalable
|
||
|
# le département via l'interface web (Zope)
|
||
|
|
||
|
usage() {
|
||
|
echo "Usage: $0 [-r] dept [script...]"
|
||
|
echo "Lance un environnement interactif python/ScoDoc"
|
||
|
echo " -r: supprime et recrée le département (attention: efface la base !)"
|
||
|
exit 1
|
||
|
}
|
||
|
|
||
|
set -euo pipefail
|
||
|
cd /opt/scodoc/Products/ScoDoc || exit 2
|
||
|
source config/utils.sh
|
||
|
|
||
|
if [ $# -lt 1 ]
|
||
|
then
|
||
|
usage
|
||
|
fi
|
||
|
|
||
|
if [ "$1" = "-r" ]
|
||
|
then
|
||
|
shift
|
||
|
recreate_dept=1
|
||
|
fi
|
||
|
|
||
|
|
||
|
DEPT="$1"
|
||
|
shift
|
||
|
|
||
|
if [ "$recreate_dept" = 1 ]
|
||
|
then
|
||
|
(cd config || terminate "no config directory"; ./delete_dept.sh -n "$DEPT") || terminate "error deleting dept $DEPT"
|
||
|
(cd config || terminate "no config directory"; ./create_dept.sh -n "$DEPT") || terminate "error creating dept $DEPT"
|
||
|
systemctl start scodoc
|
||
|
fi
|
||
|
|
||
|
cmd="from __future__ import print_function;from Zope2 import configure;configure('/opt/scodoc/etc/zope.conf');import Zope2; app=Zope2.app();from debug import *;context = go_dept(app, '""$DEPT""');"
|
||
|
|
||
|
for f in "$@"
|
||
|
do
|
||
|
cmd="${cmd}exec(open(\"${f}\").read());"
|
||
|
done
|
||
|
|
||
|
/opt/zope213/bin/python -i -c "$cmd"
|
||
|
|
||
|
|