reorganized config/tools directories and started updating scripts

This commit is contained in:
Emmanuel Viennet 2021-07-21 23:32:30 +03:00
parent be868497ff
commit 5e78875820
56 changed files with 103 additions and 1414 deletions

View File

@ -274,10 +274,8 @@ else:
SCO_ENCODING = "utf-8" # used by Excel, XML, PDF, ...
SCO_DEFAULT_SQL_USER = "www-data" # should match Zope process UID
SCO_DEFAULT_SQL_PORT = (
"5432" # warning: 5433 for postgresql-8.1 on Debian if 7.4 also installed !
)
SCO_DEFAULT_SQL_USER = "scodoc" # should match Zope process UID
SCO_DEFAULT_SQL_PORT = "5432"
SCO_DEFAULT_SQL_USERS_CNX = "dbname=SCOUSERS port=%s" % SCO_DEFAULT_SQL_PORT
# Valeurs utilisées pour affichage seulement, pas de requetes ni de mails envoyés:

View File

@ -1,56 +0,0 @@
CONFIGURATION DE SCODOC
-----------------------
Emmanuel Viennet, juin 2008, mar 2017
0) INSTALL de base:
- prerequis: apache2, utilisateur www-data
- detarer ScoDoc.tgz (== Zope + produits + scodoc)
1) Creation de la base utilisateurs (initialement vide)
-------
Sept 2013: ScoDoc 7 : python2.7, Debian 7, Zope 2.13.21
Pour la construction de Zope:
attention: on veut bénéficier des paquets python Debian !
donc
apt-get install python-dev
apt-get install python-virtualenv
apt-get install gcc
virtualenv --system-site-packages /opt/zope213
cd zope213/
bin/easy_install -i http://download.zope.org/Zope2/index/2.13.21 Zope2
# ...long...
bin/easy_install Products.ZSQLMethods
bin/easy_install ZPsycopgDA
# Avec Debian 8: probleme install de ZPsycopgDA
# essai en le copiant de la version Debian 7. Semble ok.
# Problemes persistant avec pydot (voir commentaire dans script install)
# Si besoin, création de l'instance Zope:
bin/mkzopeinstance -d /opt/inst
(XXX admin / admin)
2) Migration bases de données
Sur ScoDoc6:
pg_dumpall > scodoc.dump.txt
passage en UTF-8
- sources Python
- locale systeme (scrip install)
- creation des bases (users et depts)
- recodage du dump sql

View File

@ -1,23 +0,0 @@
#!/bin/bash
# Modify ScoDoc install to use systemd
# E. Viennet, 2020-12-04
source config.sh
source utils.sh
check_uid_root "$0"
echo 'Installation du demarrage automatique de ScoDoc (systemd)'
# La variable POSTGRES_SERVICE doit être positionnée dans config.sh
# suivant la version de Debian et de postgresql
[ -z "${POSTGRES_SERVICE}" ] && die "incompatible Debian version"
cat "$SCODOC_DIR/config/etc/scodoc.service" | sed 's/{{postgresql}}/'"${POSTGRES_SERVICE}"'/g' > /etc/systemd/system/scodoc.service
systemctl enable scodoc.service
echo "A partir de maintenant, utiliser"
echo " pour demarrer: systemctl start scodoc"
echo " pour arreter : systemctl stop scodoc"

View File

@ -1,28 +0,0 @@
#!/bin/bash
#
# ScoDoc: creation de la base de donnees d'utilisateurs
#
# Ce script prend en charge la creation de la base de donnees
# et doit être lancé par l'utilisateur unix root dans le repertoire .../config
# ^^^^^^^^^^^^^^^^^^^^^
# E. Viennet, Juin 2008
#
source config.sh
source utils.sh
check_uid_root "$0"
# --- Ensure postgres user www-data exists
init_postgres_user
db_name=SCOUSERS
echo 'Creating postgresql database ' $db_name
su -c "createdb -E UTF-8 -O $POSTGRES_USER -p $POSTGRES_PORT $db_name" "$POSTGRES_SUPERUSER"
echo 'Initializing tables in database ' "$db_name"
echo su -c "$PSQL -U $POSTGRES_USER -p $POSTGRES_PORT $db_name < $SCODOC_DIR/misc/create_user_table.sql" "$POSTGRES_USER"
su -c "$PSQL -U $POSTGRES_USER -p $POSTGRES_PORT $db_name < $SCODOC_DIR/misc/create_user_table.sql" "$POSTGRES_USER"

View File

@ -1,97 +0,0 @@
#!/bin/bash
# Pense bete pour tout nettoyer avant de faire une distribution...
#
#
# E. Viennet, jul 2008
source config.sh
source utils.sh
if [ "$UID" != "0" ]
then
echo "Erreur: le script $0 doit etre lance par root"
exit 1
fi
echo "Changing to directory " "$SCODOC_DIR"/config
cd "$SCODOC_DIR"/config || { echo "directory does not exist"; exit 1; }
echo "Stopping ScoDoc..."
scodocctl stop
# DROITS
echo -n "Verification des droits: proprietaire www-data ? (y/n) [y] "
read -r ans
if [ "$(norm_ans "$ans")" != 'N' ]
then
echo 'changing owner to www-data'
chown -R www-data.www-data ..
fi
echo -n 'Suppression des backups des sources (*~) ? (y/n) [y] '
read -r ans
if [ "$(norm_ans "$ans")" != 'N' ]
then
/bin/rm -f ../*~ ../*/*~
fi
# SVN
echo -n "svn update ? (y/n) [y] "
read -r ans
if [ "$(norm_ans "$ans")" != 'N' ]
then
echo 'Updating from SVN...'
(cd ..; svn update)
fi
# DEPARTEMENTS (maintenant inutile car dans /var)
echo -n "Supprimer les (anciennes) configs de departements ? (y/n) [y] "
read -r ans
if [ "$(norm_ans "$ans")" != 'N' ]
then
echo "moving " depts/*.cfg "to /tmp"
mv depts/*.cfg /tmp
fi
# .../var/
echo -n "Supprimer et recréer .../var (archives, photos, configs, ...) ? (y/n) [y] "
read -r ans
if [ "$(norm_ans "$ans")" != 'N' ]
then
echo "moving ../../../var/scodoc to /tmp"
mv ../../../var/scodoc /tmp
mkdir -p ../../../var/scodoc/config/depts
mkdir ../../../var/scodoc/photos
mkdir ../../../var/scodoc/tmp
mkdir ../../../var/scodoc/archives
chown -R www-data.www-data ../../../var/scodoc/
fi
# LOGS ZOPE
echo -n "Effacer les logs de Zope et ScoDoc ? (y/n) [y] "
read -r ans
if [ "$(norm_ans "$ans")" != 'N' ]
then
(cd ../../../log/; ./purge)
fi
# IMAGE Data.fs
echo -n "Recopier le Data.fs original ? (y/n) [y] "
read -r ans
if [ "$(norm_ans "$ans")" != 'N' ]
then
echo "moving Data.fs to /tmp"
mv ../../../var/Data.fs ../../../var/Data.fs.index /tmp
DATAFS=../../../var/Data.fs.ok-to-distrib-545
echo "copying $DATAFS to Data.fs"
cp -p $DATAFS ../../../var/Data.fs
fi
#
echo
echo "OK, vous pouvez archiver la distribution !"
echo

View File

@ -1,9 +0,0 @@
* Scripts utiles pour l'installation de ScoDoc
- scodoc : script de demarrage a placer dans /etc/rc.*
- scodoc-site-ssl: configuration de site (https) pour Apache, a placer dans
/etc/apache2/sites-available/
puis editer pour remplacer le nom du site et indiquer vos certificats crypto
puis activer par a2ensite scodoc-site-ssl

View File

@ -1,19 +0,0 @@
#
# Exemple de configuration pare-feu firehol minimal pour un serveur ScoDoc
#
# Suppose que l'interface reseau Internet est XXX_INTERFACE_XXX
#
# E. Viennet, juin 2008, jul 2017
#
version 5
FIREHOL_LOG_MODE="ULOG"
interface XXX_INTERFACE_XXX internet
protection strong
client all accept # plutot gentil, a adapter a vos besoins (attention a ntp et aux mises a jour)
server ssh accept
server https accept
# pas de log des paquets venant d'Internet...
server any nolog drop

View File

@ -1,75 +0,0 @@
#!/bin/sh
#
# zope This shell script takes care of starting and stopping
# zope under apache (proxy)
# Emmanuel Viennet @ LIPN, June 2002, Sept 2011 (LSB-compliance for Debian 6)
#
# chkconfig: - 90 10
# description: zope is a web server
### BEGIN INIT INFO
# Provides: ScoDoc
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop ScoDoc server
### END INIT INFO
# Source function library.
#. /etc/init.d/functions
ZOPE_DIR=/opt/scodoc/instance
# [ -x $ZOPE_DIR/bin/python ] || exit 0
RETVAL=0
prog="Zope"
start() {
# Start Zope persistent process
# Start daemons.
echo -n $"Starting $prog: "
echo $ZOPE_DIR/bin/zopectl start
$ZOPE_DIR/bin/zopectl start 2> /dev/null
RETVAL=$?
echo
# [ $RETVAL -eq 0 ] && touch /var/lock/subsys/zope
return $RETVAL
}
stop() {
# Stop daemons.
echo -n 'Stopping zope daemon: '
$ZOPE_DIR/bin/zopectl stop
RETVAL=$?
echo
# [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/zope
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
# status)
# status $ZOPE_DIR/bin/python
# RETVAL=$?
# ;;
restart|reload)
stop
start
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $RETVAL

View File

@ -1,56 +0,0 @@
# Fichier config Apache basique pour ScoDoc
# E. Viennet, juin 2008, sept 2009, mar 2017 (Apache 2.4)
# Apache fonctionne ici en proxy https devant zope (lui meme sur 8080).
# A EDITER !!!
# 1- REMPLACER YOUR.FULL.HOST.NAME par votre nom de site (www.monscodoc.com)
# 2- indiquer vos certificats ssl (.key, .pem)
# 3- eventuellement, le certificat de votre authorite de certif. (CA).
# 4- eventuellement, revoir les fichiers de logs (penser au logrotate !)
NameVirtualHost *:443
<VirtualHost *:443>
ServerAdmin webmaster
ServerName YOUR.FULL.HOST.NAME
SSLEngine on
SSLCertificateFile /etc/apache2/scodoc-ssl/apache.pem
# SSLCertificateKeyFile /etc/apache2/ssl/iutv.univ-paris13.fr.key
# Votre authorite de certification:
# SSLCACertificateFile /etc/apache2/scodoc-ssl/ct_root.pem
# SSLCACertificateFile /etc/apache2/scodoc-ssl/sureserverEDU.pem
DocumentRoot /var/www/
ErrorLog /var/log/apache2/ssl-error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/ssl-access.log combined
RewriteEngine on
# "RewriteLogLevel" n'est plus disponible dans apache2.4, il faut utiliser l'option "rewrite" dans l'instruction "LogLevel"
#LogLevel warn rewrite:trace3
# ScoDoc static content, served directly:
# RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^/ScoDoc/static/(.*) /opt/scodoc/Products/ScoDoc/static/$1 [L]
# Le reste est pour Zope:
RewriteRule ^/(.*) http://localhost:8080/VirtualHostBase/https/YOUR.FULL.HOST.NAME:443/$1 [L,P]
# Log avec utilisateur authentifie par ScoDoc
LogFormat "%h %l %{X-ScoDoc-User}o %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" scodoc
CustomLog "/var/log/apache2/scodoc_access.log" scodoc
</VirtualHost>
<Directory /opt/scodoc/Products/ScoDoc/static/>
Require all granted
</Directory>

View File

@ -1,52 +0,0 @@
# Fichier config Apache basique pour ScoDoc
# E. Viennet, juin 2008, sept 2009
# Apache fonctionne ici en proxy https devant zope (lui meme sur 8080).
# A EDITER !!!
# 1- REMPLACER YOUR.FULL.HOST.NAME par votre nom de site (www.monscodoc.com)
# 2- indiquer vos certificats ssl (.key, .pem)
# 3- eventuellement, le certificat de votre authorite de certif. (CA).
# 4- eventuellement, revoir les fichiers de logs (penser au logrotate !)
NameVirtualHost *:443
<VirtualHost *:443>
ServerAdmin webmaster
ServerName YOUR.FULL.HOST.NAME
SSLEngine on
SSLCertificateFile /etc/apache2/scodoc-ssl/apache.pem
# SSLCertificateKeyFile /etc/apache2/ssl/iutv.univ-paris13.fr.key
# Votre authorite de certification:
# SSLCACertificateFile /etc/apache2/scodoc-ssl/ct_root.pem
# SSLCACertificateFile /etc/apache2/scodoc-ssl/sureserverEDU.pem
DocumentRoot /var/www/
ErrorLog /var/log/apache2/ssl-error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/ssl-access.log combined
RewriteEngine on
RewriteLog /var/log/rewrite.ssl
RewriteLogLevel 0
# ScoDoc static content, served directly:
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^/ScoDoc/static/(.*) /opt/scodoc/instance/Products/ScoDoc/static/$1 [L]
# Le reste est pour Zope:
RewriteRule ^/(.*) http://localhost:8080/VirtualHostBase/https/YOUR.FULL.HOST.NAME:443/$1 [L,P]
# Log avec utilisateur authentifie par ScoDoc
LogFormat "%h %l %{X-ScoDoc-User}o %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" scodoc
CustomLog "/var/log/apache2/scodoc_access.log" scodoc
</VirtualHost>

View File

@ -1,22 +0,0 @@
#
# Config Apache minimale http: redirige tout vers https
# (voir scodoc-site-ssl)
#
NameVirtualHost *
<VirtualHost *>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
<Directory />
AllowOverride None
</Directory>
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>

View File

@ -1,65 +0,0 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
# Script pour ScoDoc7 (python2), obsolete
"""Fix bug #70
Utiliser comme:
scotests/scointeractive.sh DEPT config/fix_bug70_db.py
"""
context = context.Notes # pylint: disable=undefined-variable
REQUEST = REQUEST # pylint: disable=undefined-variable
import scotests.sco_fake_gen as sco_fake_gen # pylint: disable=import-error
import os
import sys
import sco_utils
import notesdb
import sco_formsemestre
import sco_formsemestre_edit
import sco_moduleimpl
G = sco_fake_gen.ScoFake(context.Notes)
def fix_formsemestre_formation_bug70(formsemestre_id):
"""Le bug #70 a pu entrainer des incohérences
lors du clonage avorté de semestres.
Cette fonction réassocie le semestre à la formation
à laquelle appartiennent ses modulesimpls.
2021-04-23
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
cursor = notesdb.SimpleQuery(
context,
"""SELECT m.formation_id
FROM notes_modules m, notes_moduleimpl mi
WHERE mi.module_id = m.module_id
AND mi.formsemestre_id = %(formsemestre_id)s
""",
{"formsemestre_id": formsemestre_id},
)
modimpls_formations = set([x[0] for x in cursor])
if len(modimpls_formations) > 1:
# this is should not occur
G.log(
"Warning: fix_formsemestre_formation_bug70: modules from several formations in sem %s"
% formsemestre_id
)
elif len(modimpls_formations) == 1:
modimpls_formation_id = modimpls_formations.pop()
if modimpls_formation_id != sem["formation_id"]:
# Bug #70: fix
G.log("fix_formsemestre_formation_bug70: fixing %s" % formsemestre_id)
sem["formation_id"] = modimpls_formation_id
context.do_formsemestre_edit(sem, html_quote=False)
formsemestre_ids = [
x[0]
for x in notesdb.SimpleQuery(
context, "SELECT formsemestre_id FROM notes_formsemestre", {}
)
]
for formsemestre_id in formsemestre_ids:
fix_formsemestre_formation_bug70(formsemestre_id)

View File

@ -1,19 +0,0 @@
#!/bin/bash
# Install module(s) for calendars
# (if already installed, do nothing)
# Test if installed
# (NB: don't launch python, to be faster and also to avoid import bug zope vs pytz)
if [ -e /opt/zope213/lib/python2.7/site-packages/icalendar ] || [ /usr/lib/python2.7/dist-packages/icalendar ]
then
exit 0 # already installed
else
echo "Installing icalendar"
/opt/zope213/bin/pip install icalendar
fi

View File

@ -1,69 +0,0 @@
#!/bin/bash
# Migration vers ScoDoc 8
#
# E. Viennet, dec 2020
#
# Passe l'installation courante de ScoDoc 7 à ScoDoc 8
# A ce jour, ScoDoc 8 n'est pas recommandé en production !
#
# - l'installation ScoDoc 7 doit être à jour.
# - passe de SVN à GIT: pas de retour en arrière.
# - déplace la config de config/scodoc_config.py
# vers /opt/scodoc/var/scodoc/config/scodoc_local.py
source config.sh
source utils.sh
check_uid_root "$0"
scodocctl stop
scodoc7=/opt/ScoDoc7
if [ -e "$scodoc7" ]
then
echo "/opt/ScoDoc7 already exists. Move or remove it before retrying."
exit 1;
fi
# 0- Upgrade and check local config
cd "$SCODOC_DIR" || { echo "Fatal error: can't cd to $SCODOC_DIR"; exit 2; }
svn up || { echo "Fatal error: can't apply last svn up"; exit 3; }
local_config_diff=$(svn diff config/scodoc_config.py | wc -l)
# 1- Install git
apt-get update
apt-get update || { echo "apt-get update failed with $?"; exit 4; }
apt-get -y install git
# 2- Download ScoDoc8
printf "\nDownloading files...\n"
cd "$SCODOC_DIR"/.. || { echo "Fatal error: can't cd to $SCODOC_DIR"; exit 2; }
mv ScoDoc "$scodoc7"
git clone https://scodoc.org/git/viennet/ScoDoc.git || { echo "Fatal error: can't clone git repository"; exit 5; }
cd ScoDoc || { echo "Fatal error: can't cd to $SCODOC_DIR"; exit 6; }
git checkout ScoDoc8 || { echo "Fatal error: can't checkout ScoDoc8 branch"; exit 7; }
# 3- Migrate user's configuration if needed
if [ "$local_config_diff" -ne 0 ]
then
src="$scodoc7"/config/scodoc_config.py
dst="${SCODOC_VAR_DIR}/config/scodoc_local.py"
if [ -e "$dst" ]
then
echo "Warning: moving ${dst} to ${dst}.old"
printf "=> vérifiez votre configuration locale avant utilisation.\n\n"
mv "$dst" "$dst".old
fi
echo
echo "Copying local configuration file $src"
echo "to $dst"
cp "$src" "$dst"
fi
printf "\nDone.\nPlease start scodoc to use ScoDoc8: systemctl start scodoc\n"

View File

@ -1,75 +0,0 @@
#!/opt/zope213/bin/python
# -*- coding: utf-8 -*-
"""
ScoDoc post-upgrade script.
This script is launched by upgrade.sh after each SVN update.
Run as "root" with Zope shutted down and postgresql up,
_before_ upgrading the database.
E. Viennet, June 2008
Mar 2017: suppress upgrade of very old Apache configs
Aug 2020: move photos to .../var/scodoc/
Apr 2021: bug #70
"""
import os
import sys
import glob
import shutil
from scodocutils import log, SCODOC_DIR, SCODOC_VAR_DIR, SCODOC_LOGOS_DIR, SCO_TMPDIR
if os.getuid() != 0:
log("postupgrade.py: must be run as root")
sys.exit(1)
# ---
# Migrate photos (2020-08-16, svn 1908)
old_photo_dir = os.path.join(SCODOC_DIR, "static", "photos")
photo_dirs = glob.glob(old_photo_dir + "/F*")
if photo_dirs:
log("Moving photos to new <var> directory...")
shutil.move(old_photo_dir, SCODOC_VAR_DIR)
# Migrate depts (2020-08-17, svn 1909)
old_depts_dir = os.path.join(SCODOC_DIR, "config", "depts")
cfg_files = glob.glob(old_depts_dir + "/*.cfg")
depts_dir = os.path.join(SCODOC_VAR_DIR, "config/depts/")
for cfg in cfg_files:
log("Moving %s to new <var> directory..." % cfg)
shutil.move(cfg, depts_dir)
# Move logos
if not os.path.exists(SCODOC_LOGOS_DIR):
old_logos = os.path.join(SCODOC_DIR, "logos")
if os.path.exists(old_logos):
log("Moving logos to new <var> directory...")
dest = os.path.normpath(os.path.join(SCODOC_LOGOS_DIR, ".."))
shutil.move(old_logos, dest)
else:
log("Warning: logos directory is missing (%s)" % SCODOC_LOGOS_DIR)
# Move dept-specific logos
for d in glob.glob(SCODOC_DIR + "/logos_*"):
log("Moving %s to %s" % (d, SCODOC_LOGOS_DIR))
shutil.move(d, SCODOC_LOGOS_DIR)
# Fix bug #70
depts = [
os.path.splitext(os.path.basename(f))[0] for f in glob.glob(depts_dir + "/*.cfg")
]
for dept in depts:
fixed_filename = SCO_TMPDIR + "/.%s_bug70_fixed" % dept
if not os.path.exists(fixed_filename):
log("fixing #70 on %s" % dept)
os.system("../scotests/scointeractive.sh -x %s config/fix_bug70_db.py" % dept)
# n'essaie qu'une fois, même en cas d'échec
f = open(fixed_filename, "a")
f.close()
# Continue here...
# ---
sys.exit(0)

View File

@ -1,36 +0,0 @@
#!/bin/bash
#
# ScoDoc: reglage du mot de passe admin Zope
# (in Zope terminology, an emergency user)
#
# Doit <20>tre lanc<6E> par l'utilisateur unix root dans le repertoire .../config
# ^^^^^^^^^^^^^^^^^^^^^
# E. Viennet, Juin 2008, Jul 2019
#
source config.sh
source utils.sh
if [ "$UID" != "0" ]
then
echo "Erreur: le script $0 doit etre lance par root"
exit 1
fi
echo "Creation d'un utilisateur d'urgence pour ScoDoc"
echo "(utile en cas de perte de votre mot de passe admin)"
if [ "${debian_version}" != "10" ]
then
mdir=/opt/zope213/lib/python2.7/site-packages/Zope2-2.13.21-py2.7.egg/Zope2/utilities
else
mdir=/opt/zope213/lib/python2.7/site-packages/Zope2/utilities
fi
python $mdir/zpasswd.py "$SCODOC_DIR"/../../access
echo
echo "redemarrer scodoc pour prendre en compte le mot de passe"
echo

View File

@ -1,214 +0,0 @@
#!/bin/bash
# $Id: get-iana.sh,v 1.15 2013/01/06 23:49:08 ktsaou Exp $
#
# $Log: get-iana.sh,v $
# Revision 1.15 2013/01/06 23:49:08 ktsaou
# Removed depedency to get-iana.sh
# It is not usefull any more.
#
# Revision 1.14 2010/06/07 15:44:09 ktsaou
# Made get-iana.sh support the latest IANA format.
#
# Revision 1.13 2010/04/08 22:03:08 ktsaou
# Removed --proxy=off for wget.
#
# Revision 1.12 2008/03/17 22:08:43 ktsaou
# Updated for latest IANA reservations format.
#
# Revision 1.11 2007/06/13 14:40:04 ktsaou
# *** empty log message ***
#
# Revision 1.10 2007/05/05 23:38:31 ktsaou
# Added support for external definitions of:
#
# RESERVED_IPS
# PRIVATE_IPS
# MULTICAST_IPS
# UNROUTABLE_IPS
#
# in files under the same name in /etc/firehol/.
# Only RESERVED_IPS is mandatory (firehol will complain if it is not there,
# but it will still work without it), and is also the only file that firehol
# checks how old is it. If it is 90+ days old, firehol will complain again.
#
# Changed the supplied get-iana.sh script to generate the RESERVED_IPS file.
# FireHOL also instructs the user to use this script if the file is missing
# or is too old.
#
# Revision 1.9 2007/04/29 19:34:11 ktsaou
# *** empty log message ***
#
# Revision 1.8 2005/06/02 15:48:52 ktsaou
# Allowed 127.0.0.1 to be in RESERVED_IPS
#
# Revision 1.7 2005/05/08 23:27:23 ktsaou
# Updated RESERVED_IPS to current IANA reservations.
#
# Revision 1.6 2004/01/10 18:44:39 ktsaou
# Further optimized and reduced PRIVATE_IPS using:
# http://www.vergenet.net/linux/aggregate/
#
# The supplied get-iana.sh uses 'aggregate-flim' if it finds it in the path.
# (aggregate-flim is the name of this program when installed on Gentoo)
#
# Revision 1.5 2003/08/23 23:26:50 ktsaou
# Bug #793889:
# Change #!/bin/sh to #!/bin/bash to allow FireHOL run on systems that
# bash is not linked to /bin/sh.
#
# Revision 1.4 2002/10/27 12:44:42 ktsaou
# CVS test
#
#
# Program that downloads the IPv4 address space allocation by IANA
# and creates a list with all reserved address spaces.
#
# IPV4_ADDRESS_SPACE_URL="http://www.iana.org/assignments/ipv4-address-space"
IPV4_ADDRESS_SPACE_URL="http://www.iana.org/assignments/ipv4-address-space/ipv4-address-space.txt"
# The program will match all rows in the file which start with a number, have a slash,
# followed by another number, for which the following pattern will also match on the
# same rows
IANA_RESERVED="(RESERVED|UNALLOCATED)"
# which rows that are matched by the above, to ignore
# (i.e. not include them in RESERVED_IPS)?
#IANA_IGNORE="(Multicast|Private use|Loopback|Local Identification)"
IANA_IGNORE="Multicast"
tempfile="/tmp/iana.$$.$RANDOM"
AGGREGATE="`which aggregate-flim 2>/dev/null`"
if [ -z "${AGGREGATE}" ]
then
AGGREGATE="`which aggregate 2>/dev/null`"
fi
if [ -z "${AGGREGATE}" ]
then
echo >&2
echo >&2
echo >&2 "WARNING"
echo >&2 "Please install 'aggregate-flim' to shrink the list of IPs."
echo >&2
echo >&2
fi
echo >&2
echo >&2 "Fetching IANA IPv4 Address Space, from:"
echo >&2 "${IPV4_ADDRESS_SPACE_URL}"
echo >&2
wget -O - "${IPV4_ADDRESS_SPACE_URL}" |\
egrep "^ *[0-9]+/[0-9]+.*${IANA_RESERVED}" |\
egrep -vi "${IANA_IGNORE}" |\
sed "s/^ \+//g" |\
cut -d ' ' -f 1 |\
(
while IFS="/" read range net
do
# echo >&2 "$range/$net"
if [ ! $net -eq 8 ]
then
echo >&2 "Cannot handle network masks of $net bits ($range/$net)"
continue
fi
first=`echo $range | cut -d '-' -f 1`
first=`expr $first + 0`
last=`echo $range | cut -d '-' -f 2`
last=`expr $last + 0`
x=$first
while [ ! $x -gt $last ]
do
# test $x -ne 127 && echo "$x.0.0.0/$net"
echo "$x.0.0.0/$net"
x=$[x + 1]
done
done
) | \
(
if [ ! -z "${AGGREGATE}" -a -x "${AGGREGATE}" ]
then
"${AGGREGATE}"
else
cat
fi
) >"${tempfile}"
echo >&2
echo >&2
echo >&2 "FOUND THE FOLLOWING RESERVED IP RANGES:"
printf "RESERVED_IPS=\""
i=0
for x in `cat ${tempfile}`
do
i=$[i + 1]
printf "${x} "
done
printf "\"\n"
if [ $i -eq 0 ]
then
echo >&2
echo >&2
echo >&2 "Failed to find reserved IPs."
echo >&2 "Possibly the file format has been changed, or I cannot fetch the URL."
echo >&2
rm -f ${tempfile}
exit 1
fi
echo >&2
echo >&2
echo >&2 "Differences between the fetched list and the list installed in"
echo >&2 "/etc/firehol/RESERVED_IPS:"
echo >&2 "# diff /etc/firehol/RESERVED_IPS ${tempfile}"
diff /etc/firehol/RESERVED_IPS ${tempfile}
if [ $? -eq 0 ]
then
touch /etc/firehol/RESERVED_IPS
echo >&2
echo >&2 "No differences found."
echo >&2
rm -f ${tempfile}
exit 0
fi
echo >&2
echo >&2
echo >&2 "Would you like to save this list to /etc/firehol/RESERVED_IPS"
echo >&2 "so that FireHOL will automatically use it from now on?"
echo >&2
while [ 1 = 1 ]
do
printf >&2 "yes or no > "
read x
case "${x}" in
yes) cp -f /etc/firehol/RESERVED_IPS /etc/firehol/RESERVED_IPS.old 2>/dev/null
cat "${tempfile}" >/etc/firehol/RESERVED_IPS || exit 1
echo >&2 "New RESERVED_IPS written to '/etc/firehol/RESERVED_IPS'."
break
;;
no)
echo >&2 "Saved nothing."
break
;;
*) echo >&2 "Cannot understand '${x}'."
;;
esac
done
rm -f ${tempfile}

Binary file not shown.

View File

@ -1,59 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Check usage of (published) ScoDoc methods
Quick method: just grep method name in all constant strings from the source code base.
Usage:
check_zope_usage.py publishedmethods.csv string-constants.txt
publishedmethods.csv : fichier texte, module et un nom de méthode / ligne
ZScoUsers get_user_list
comme extrait par zopelistmethods.py
string-constants.txt : les constantes chaines, extraites par extract_code_strings.py
"scolars.py" "</li><li>"
E. Viennet 2021-01-09
"""
from __future__ import print_function
import sys
import glob
methods_filename = sys.argv[1]
constants_filename = sys.argv[2]
with open(methods_filename) as f:
# module, method_name, signature
methods = [l.strip().split("\t") for l in f]
print("%d methods" % len(methods))
with open(constants_filename) as f:
constants = [l[:-1].split("\t")[1] for l in f]
print("%d constants" % len(constants))
# Add JavaScripts
jss = []
for fn in glob.glob("static/js/*.js"):
jss.append(open(fn).read())
print("%d javascripts" % len(jss))
L = []
for method in methods:
n = 0
for c in constants:
if method[1] in c:
n += 1
nj = 0
for js in jss:
if method[1] in js:
nj += 1
L.append(method + [n, nj])
# Sort by decreasing popularity
L.sort(key=lambda x: (x[-1] + x[-2], x[1]), reverse=True)
print("\n".join(["%s\t%s\t%s\t%d\t%d" % tuple(l) for l in L]))

View File

@ -1,51 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Affiche nombre d'inscriptions aux semestres pour chaque etudiant
et supprime les etudiants jamais inscrits ayant un homonyme exact
(erreur passage GEA, fev 2007)
"""
from __future__ import print_function
import csv
import pdb
import sys
import psycopg2
DBCNXSTRING = "host=localhost user=scogea dbname=SCOXXXX password=XXXXX"
SCO_ENCODING = "utf-8"
cnx = psycopg2.connect(DBCNXSTRING)
cursor = cnx.cursor()
cursor.execute("select * from identite i order by nom")
R = cursor.dictfetchall()
nzero = 0
nhomonoins = 0
print("etudid, nom, prenom, nb_inscriptions")
for e in R:
cursor.execute(
"select count(*) from notes_formsemestre_inscription where etudid=%(etudid)s",
{"etudid": e["etudid"]},
)
nbins = cursor.fetchone()[0]
if nbins == 0:
nzero += 1
# recherche homonyme
cursor.execute(
"select * from identite i where nom=%(nom)s and prenom=%(prenom)s", e
)
H = cursor.dictfetchall()
if len(H) == 2:
nhomonoins += 1
print(e["etudid"], e["nom"], e["prenom"], nbins)
# etudiant non inscrit ayant un homonyme exact:
# il doit etre supprimé !!!
# cursor.execute("delete from admissions where etudid=%(etudid)s", e)
# cursor.execute("delete from identite where etudid=%(etudid)s", e)
cnx.commit()
print("= %d etudiants, %d jamais inscrits, %d avec homo" % (len(R), nzero, nhomonoins))

View File

@ -1,27 +0,0 @@
CREATE SEQUENCE sco_users_idgen;
CREATE FUNCTION sco_users_newid( text ) returns text as '
select $1 || to_char( nextval(''sco_users_idgen''), ''FM999999999'' )
as result;
' language SQL;
-- Source pour Zope User Folder
CREATE TABLE sco_users (
user_id text default sco_users_newid('U') PRIMARY KEY,
user_name text unique,
passwd text not null,
roles text,
date_modif_passwd date default now(),
nom text,
prenom text,
email text,
dept text, -- departement d'appartenance
passwd_temp int default 0, -- 0 ok, 1 mot de passe temporaire
status text default NULL, -- NULL actif, 'old' ancien (pas de login possible)
date_expiration date, -- date limite, NULL => sans limite
login_edt text default NULL -- login logiciel emplois du temps (pour decodage ics)
) with oids;

View File

@ -1,39 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Extract all string litterals from our code base.
Useful to check if an API function is used in a generated web page !
Usage:
extract_code_strings.py source.py ... > string-constants.txt
Résultat utilisé par check_zope_usage.py
E. Viennet 2021-01-09
"""
from __future__ import print_function
import sys
import ast
import types
# L = []
for srcfilename in sys.argv[1:]:
# print("processing %s" % srcfilename, file=sys.stderr)
with open(srcfilename) as f:
p = ast.parse(f.read())
# L.extend(x.s.strip() for x in ast.walk(p) if x.__class__ == ast.Str)
for x in ast.walk(p):
if x.__class__ == ast.Str:
if isinstance(x.s, str):
s = x.s
else:
s = x.s.encode("UTF-8")
# remove tabs and cr
s = s.replace("\t", "").replace("\n", "")
if len(s):
print("%s\t%s" % (srcfilename, s))
# L = sorted(set(L)) # uniq | sort
# print("\n".join(L))

View File

@ -1,141 +0,0 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
# Creation d'une formation ISCID à partir d'un xls listant les modules
# XXX TODO : a tester et moderniser (ects, verifier champs, python 3, importer codes depuis ScoDoc ?)
import os, sys, pdb, pprint
from openpyxl import load_workbook # apt-get install python-openpyxl
from xml.etree import ElementTree
SCO_ENCODING = "utf-8"
INPUT_FILENAME = "/tmp/Bachelor.xlsx"
OUTPUT_FILENAME = os.path.splitext(INPUT_FILENAME)[0] + ".xml"
FIRST_SHEET_IDX = 1 # saute première feuille du classeur
# Code de ScoDoc (sco_utils.py)
UE_STANDARD = 0 # UE "fondamentale"
UE_SPORT = 1 # bonus "sport"
UE_STAGE_LP = 2 # ue "projet tuteuré et stage" dans les Lic. Pro.
UE_ELECTIVE = 4 # UE "élective" dans certains parcours (UCAC?, ISCID)
UE_PROFESSIONNELLE = 5 # UE "professionnelle" (ISCID, ...)
# Code du fichier Excel:
UE_TYPE2CODE = {u"UE F": UE_STANDARD, u"UE E": UE_ELECTIVE}
# Lecture du fichier Excel
UE = []
wb = load_workbook(filename=INPUT_FILENAME)
# print wb.get_sheet_names()
for sheet_name in wb.get_sheet_names()[FIRST_SHEET_IDX:]:
print "Importing sheet %s" % sheet_name
sheet = wb.get_sheet_by_name(sheet_name)
# Avance jusqu'à trouver le titre 'CODE' en premiere colonne
i = 0
while i < len(sheet.rows) and sheet.rows[i][0].value != "CODE":
i = i + 1
i = i + 1
ue = None
while i < len(sheet.rows):
code = sheet.rows[i][0].value
type_ue = sheet.rows[i][2].value
if type_ue in UE_TYPE2CODE:
if ue:
UE.append(ue)
# creation UE
acronyme = code # ici l'acronyme d'UE est le code du module
if not acronyme and (i < len(sheet.rows) - 1):
acronyme = sheet.rows[i + 1][0].value # code module sur ligne suivante
# print acronyme
if acronyme: # tres specifique: deduit l'acronyme d'UE du code module
parts = acronyme.split(u"-")
parts[-1] = parts[-1][-1] # ne garde que le dernier chiffre
acronyme = u"-".join(parts) # B1-LV1-EN1 -> B1-LV1-1
# print '->', acronyme
if not acronyme:
acronyme = sheet.rows[i][3].value # fallback: titre
ue = {
"acronyme": acronyme,
"titre": sheet.rows[i][3].value,
"ects": sheet.rows[i][5].value or u"",
"type": UE_TYPE2CODE[type_ue],
"numero": (sheet.rows[i][1].value or 0) * 1000 + i * 10,
"modules": [],
}
i_ue = i
if code:
ue["modules"].append(
{
"code": code,
"heures_td": sheet.rows[i_ue][4].value or u"",
"titre": sheet.rows[i][3].value,
"semestre_id": sheet.rows[i][1].value,
"numero": i * 10,
}
)
i += 1 # next line
if ue:
UE.append(ue)
def sstr(s):
if type(s) is type(u""):
return s.encode(SCO_ENCODING)
else:
return str(s)
# ----- Write to XML
doc = ElementTree.Element(
"formation",
acronyme="Bachelor ISCID",
code_specialite="",
type_parcours="1001",
titre_officiel="Bachelor ISCID",
formation_code="FCOD4",
version="1",
titre="Bachelor ISCID",
formation_id="FORM115",
)
for ue in UE:
x_ue = ElementTree.Element(
"ue",
acronyme=sstr(ue["acronyme"]),
ects=sstr(ue["ects"]),
titre=sstr(ue["titre"]),
numero=sstr(ue["numero"]),
type=sstr(ue["type"]),
)
doc.append(ue)
x_mat = ElementTree.Element(
"matiere", titre=sstr(ue["titre"])
) # useless but necessary
x_ue.append(x_mat)
for m in ue["modules"]:
x_mod = ElementTree.Element(
"module",
coefficient="1.0",
code=sstr(m["code"]),
heures_td=sstr(m["heures_td"]),
titre=sstr(m["titre"]),
abbrev=sstr(m["titre"]),
semestre_id=sstr(m["semestre_id"]),
numero=sstr(m["numero"]),
)
x_mat.append(x_mod)
# ---
print "Writing XML file: ", OUTPUT_FILENAME
f = open(OUTPUT_FILENAME, "w")
f.write("""<?xml version="1.0" encoding="utf-8"?>\n""")
f.write(str(doc))
f.close()

View File

@ -29,7 +29,7 @@
"""Anonymize une base de données ScoDoc
Runned as "www-data" with scodoc and postgresql up.
Runned as user "scodoc" with scodoc and postgresql up.
E. Viennet, Jan 2019
"""

View File

@ -16,43 +16,31 @@ export PATH="${PATH}":/usr/sbin:/sbin
# ScoDoc: environment variables
umask 0022
export SCODOC_DIR=/opt/scodoc/Products/ScoDoc
export SCODOC_DIR=/opt/scodoc8
SCODOC_VAR_DIR=$(realpath -L "$SCODOC_DIR/../../var/scodoc") || die "can't set SCODOC_VAR_DIR"
SCODOC_VAR_DIR=$(realpath -L "$SCODOC_DIR/var") || die "can't set SCODOC_VAR_DIR"
export SCODOC_VAR_DIR
# = /opt/scodoc/var/scodoc
export SCODOC_VERSION_DIR="${SCODOC_VAR_DIR}/config/version"
export SCODOC_LOGOS_DIR="${SCODOC_VAR_DIR}/config/logos"
# user running ScoDoc server:
export SCODOC_USER=scodoc
export SCODOC_GROUP=root
# Postgresql normal user: (same as unix user)
# IMPORTANT: must match SCO_DEFAULT_SQL_USER defined in sco_utils.py
export POSTGRES_USER="$SCODOC_USER"
# Postgresql superuser:
export POSTGRES_SUPERUSER=postgres
# Postgresql normal user: (by default, same a zope==www-data)
# IMPORTANT: must match SCO_DEFAULT_SQL_USER defined in sco_utils.py
export POSTGRES_USER=www-data
# psql command: if various versions installed, force the one we want:
if [ "${debian_version}" = "10" ]
then
PSQL=/usr/lib/postgresql/11/bin/psql
export POSTGRES_SERVICE="postgresql@11-main.service"
elif [ "${debian_version}" = "9" ]
then
PSQL=/usr/lib/postgresql/9.6/bin/psql
export POSTGRES_SERVICE="postgresql"
elif [ "${debian_version}" = "8" ]
then
PSQL=/usr/lib/postgresql/9.4/bin/psql
elif [ "${debian_version}" = "7" ]
then
PSQL=/usr/lib/postgresql/9.1/bin/psql
elif [ "${debian_version}" = "5" ]
then
PSQL=/usr/lib/postgresql/8.3/bin/psql
elif [ "${debian_version}" = "6" ]
then
PSQL=/usr/lib/postgresql/8.4/bin/psql
else
PSQL=/usr/lib/postgresql/8.1/bin/psql
else
die "unsupported Debian version"
fi
export PSQL
@ -60,11 +48,3 @@ export PSQL
# Important note: if changed, you should probably also change it in
# sco_utils.py (SCO_DEFAULT_SQL_PORT).
export POSTGRES_PORT=5432
# Utilise par le script de reset du mot de passe:
if [ "${debian_version}" -ge "7" ]
then
export ZOPE_VERSION=2.13
else
export ZOPE_VERSION=2.11.0
fi

View File

@ -4,7 +4,7 @@
# ScoDoc: creation initiale d'un departement
#
# Ce script prend en charge la creation de la base de donnees
# et doit être lancé par l'utilisateur unix root dans le repertoire .../config
# et doit être lancé par l'utilisateur unix root dans le repertoire .../tools
# ^^^^^^^^^^^^^^^^^^^^^
# E. Viennet, Juin 2008
#
@ -56,14 +56,14 @@ then
exit 1
fi
# --- Ensure postgres user www-data exists
# --- Ensure postgres user scodoc exists
init_postgres_user
# ----------------------- Create database
su -c ./create_database.sh "$POSTGRES_SUPERUSER"
# ----------------------- Create tables
# POSTGRES_USER == regular unix user (www-data)
# POSTGRES_USER == regular unix user (scodoc)
if [ "$interactive" = 1 ]
then
su -c ./initialize_database.sh "$POSTGRES_USER"
@ -84,7 +84,7 @@ then
read -r ans
if [ "$(norm_ans "$ans")" != 'N' ]
then
(cd "$SCODOC_DIR/config" || terminate "no config directory"; ./upgrade.sh)
(cd "$SCODOC_DIR/tools" || terminate "no config directory"; ./upgrade.sh)
fi
# -----------------------
echo

View File

@ -8,7 +8,7 @@
#
# Ne fonctionne que pour les configurations "standards" (dbname=xxx)
#
# Il doit être lancé par l'utilisateur unix root dans le repertoire .../config
# Il doit être lancé par l'utilisateur unix root dans le repertoire .../tools
# ^^^^^^^^^^^^^^^^^^^^^
# E. Viennet, Sept 2008
#

View File

@ -16,6 +16,8 @@ DEPTS_TO_SAVE=""
SAVE_USERS=0
SEND_BY_MAIL=1
SCODOC_HOME="/opt/scodoc8"
# -------------------------------------
# Arguments
# -------------------------------------
@ -97,10 +99,10 @@ copy_log() {
fi
}
mkdir "$TMP"/scodoc_logs/
copy_log /opt/scodoc/log/event.log
copy_log /opt/scodoc/log/event.log.1
copy_log /opt/scodoc/log/notes.log
copy_log /opt/scodoc/log/notes.log.1
copy_log "$SCODOC_HOME/log/event.log"
copy_log "$SCODOC_HOME/log/event.log.1"
copy_log "$SCODOC_HOME/log/notes.log"
copy_log "$SCODOC_HOME/log/notes.log.1"
# -------------------------------------
@ -108,16 +110,16 @@ copy_log /opt/scodoc/log/notes.log.1
# -------------------------------------
iptables -L > "$TMP"/iptables.out
ip a > "$TMP"/ifconfig.out
ip a > "$TMP"/ip-a.out
ps auxww > "$TMP"/ps.out
df -h > "$TMP"/df.out
dpkg -l > "$TMP"/dpkg.lst
(cd /opt/scodoc/Products/ScoDoc; svn status > "$TMP"/svn.status)
(cd /opt/scodoc/Products/ScoDoc; svn diff > "$TMP"/svn.diff)
(cd "$SCODOC_HOME"; git status > "$TMP"/git.status)
(cd "$SCODOC_HOME"; git diff > "$TMP"/git.diff)
(cd /opt/scodoc/Products/ScoDoc; svnversion > "$TMP"/svn.version)
ls -laR /opt/scodoc/Products/ScoDoc > "$TMP"/ls-laR
(cd "$SCODOC_HOME"; git log -n 5 > "$TMP"/git.log)
ls -laR "$SCODOC_HOME" > "$TMP"/ls-laR
# -------------------------------------

View File

Can't render this file because it is too large.

View File

@ -14,5 +14,5 @@ Description=Update ScoDoc Software
[Service]
Type=oneshot
ExecStart=/opt/scodoc/Products/ScoDoc/config/upgrade.sh
ExecStart=/opt/scodoc8/tools/upgrade.sh

View File

@ -1,16 +1,16 @@
#!/bin/bash
# Initialize database (create tables) for a ScoDoc instance
# This script must be executed as www-data user
# This script must be executed as user scodoc
#
# $db_name and $DEPT passed as environment variables
source config.sh
source utils.sh
if [ "$(id -nu)" != "$POSTGRES_USER" ]
if [ "$(id -nu)" != "$SCODOC_USER" ]
then
echo "$0: script must be runned as user $POSTGRES_USER"
echo "$0: script must be runned as user $SCODOC_USER"
exit 1
fi
@ -20,4 +20,4 @@ $PSQL -U "$POSTGRES_USER" -p "$POSTGRES_PORT" "$db_name" -f "$SCODOC_DIR"/misc/c
# Set DeptName in preferences:
echo "insert into sco_prefs (name, value) values ('DeptName', '"${DEPT}\'\) | $PSQL -U "$POSTGRES_USER" -p "$POSTGRES_PORT" "$db_name"
echo "insert into sco_prefs (name, value) values ('DeptName', '"${DEPT}\'\) | $PSQL -U "$POSTGRES_USER" -p "$POSTGRES_PORT" "$db_name"

View File

@ -27,19 +27,8 @@ then
fi
# ------------ Permissions & directories
# source dir should be writable by scodoc to write bytecode files
chgrp www-data "$SCODOC_DIR" "$SCODOC_DIR"/ZopeProducts/*
chmod g+w "$SCODOC_DIR" "$SCODOC_DIR"/ZopeProducts/*
chown -R "$SCODOC_USER"."$SCODOC_GROUP" "${SCODOC_DIR}"
if [ -d "${SCODOC_VAR_DIR}"/photos ]; then
chgrp -R www-data "${SCODOC_VAR_DIR}"/photos
chmod -R g+w "${SCODOC_VAR_DIR}"/photos
fi
if [ ! -e "${SCODOC_VERSION_DIR}" ]; then
mkdir -p "${SCODOC_VERSION_DIR}"
chown www-data.www-data "${SCODOC_VERSION_DIR}"
fi
# ------------ LOCALES
echo
@ -64,7 +53,7 @@ done
/usr/sbin/locale-gen --keep-existing
# Voir si encore nécessaire avec ScoDoc8: ?
if [ "$LANG" != "en_US.UTF-8" ]
then
# ceci est necessaire a cause de postgresql 8.3 qui
@ -76,9 +65,6 @@ then
fi
echo 'Done.'
# ------------ FIX pour passage Debian 7 -> Debian >= 8
chsh -s /bin/sh www-data
# ------------ AJOUT DES PAQUETS NECESSAIRES
apt-get update
apt-get -y install subversion curl cracklib-runtime
@ -175,7 +161,7 @@ then
fi
# ---
echo 'generation de /etc/apache2/sites-available/scodoc-site-ssl'
cat "$SCODOC_DIR"/config/etc/scodoc-site-ssl-apache2.4.orig | sed -e "s:YOUR\.FULL\.HOST\.NAME:$server_name:g" > /etc/apache2/sites-available/scodoc-site-ssl.conf
cat "$SCODOC_DIR"/tools/etc/scodoc-site-ssl-apache2.4.orig | sed -e "s:YOUR\.FULL\.HOST\.NAME:$server_name:g" > /etc/apache2/sites-available/scodoc-site-ssl.conf
echo 'activation du site...'
a2ensite scodoc-site-ssl
@ -185,7 +171,7 @@ then
then
mv $fn $fn.bak
fi
cp "$SCODOC_DIR"/config/etc/scodoc-site.orig $fn
cp "$SCODOC_DIR"/tools/etc/scodoc-site.orig $fn
if [ -z "$(grep Listen /etc/apache2/ports.conf | grep 443)" ]
then
@ -218,7 +204,7 @@ read ans
if [ "$(norm_ans "$ans")" != 'N' ]
then
# ScoDoc 7.19+ uses systemd
$SCODOC_DIR/config/configure_systemd.sh
$SCODOC_DIR/tools/configure_systemd.sh
fi
@ -228,8 +214,8 @@ echo -n "Mises a jour hebdomadaires (tres recommande) ? (y/n) [y] "
read ans
if [ "$(norm_ans "$ans")" != 'N' ]
then
cp "$SCODOC_DIR"/config/etc/scodoc-updater.service /etc/systemd/system
cp "$SCODOC_DIR"/config/etc/scodoc-updater.timer /etc/systemd/system
cp "$SCODOC_DIR"/tools/etc/scodoc-updater.service /etc/systemd/system
cp "$SCODOC_DIR"/tools/etc/scodoc-updater.timer /etc/systemd/system
systemctl enable scodoc-updater.timer
systemctl start scodoc-updater.timer
fi
@ -241,7 +227,7 @@ echo
echo "Vous pouvez maintenant creer la base d'utilisateurs avec ./create_user_db.sh"
echo "puis creer un departement avec ./create_dept.sh"
echo "Ou bien restaurer vos donnees a partir d'une ancienne installation a l'aide du script restore_scodoc_data.sh"
echo "(voir https://trac.lipn.univ-paris13.fr/projects/scodoc/wiki/MigrationDonneesScoDoc)"
echo "(voir https://scodoc.org/MigrationDonneesScoDoc/)"
echo

View File

@ -6,7 +6,7 @@ ScoDoc post-upgrade script: databases housekeeping
This script is runned by upgrade.sh after each SVN update.
Runned as "www-data" with Zope shutted down and postgresql up.
Runned as "scodoc" with ScoDoc shutted down and postgresql up.
Useful to update database schema (eg add new tables or columns to

31
tools/postupgrade.py Executable file
View File

@ -0,0 +1,31 @@
#!/opt/zope213/bin/python
# -*- coding: utf-8 -*-
"""
ScoDoc post-upgrade script.
This script is launched by upgrade.sh after each SVN update.
Run as "root" with Zope shutted down and postgresql up,
_before_ upgrading the database.
E. Viennet, June 2008
Mar 2017: suppress upgrade of very old Apache configs
Aug 2020: move photos to .../var/scodoc/
Apr 2021: bug #70
Jun 2021: update for ScoDoc8
"""
import os
import sys
import glob
import shutil
from scodocutils import log, SCODOC_DIR, SCODOC_VAR_DIR, SCODOC_LOGOS_DIR, SCO_TMPDIR
if os.getuid() != 0:
log("postupgrade.py: must be run as root")
sys.exit(1)
# Continue here...
# ---
sys.exit(0)

View File

@ -5,18 +5,6 @@
PG_DUMPFILE=$1
# Check locale of installation. If invalid, reinitialize all system
is_latin1=$(psql -l | grep postgres | grep iso88591 | wc -l)
if [ "$is_latin1" -gt 1 ]
then
echo "Recreating postgres cluster using UTF-8"
pg_dropcluster --stop 9.1 main
pg_createcluster --locale en_US.UTF-8 --start 9.1 main
fi
# Drop all current ScoDoc databases, if any:
for f in $(psql -l --no-align --field-separator . | grep SCO | cut -f 1 -d.); do

View File

@ -6,14 +6,10 @@
# Utile pour migrer ScoDoc d'un serveur a un autre
# A executer en tant que root sur le nouveau serveur
#
# E. Viennet, Sept 2011, Nov 2013, Mar 2017, Aug 2020
# E. Viennet, Sept 2011, Nov 2013, Mar 2017, Aug 2020, Jul 2021
#
INSTANCE_DIR=/opt/scodoc/
SCODOC_DIR="${INSTANCE_DIR}/Products/ScoDoc"
SCODOC_VAR_DIR="${INSTANCE_DIR}/var/scodoc"
source config.sh
source utils.sh
check_uid_root "$0"
@ -78,19 +74,19 @@ chmod a+rx "$SRC"
chmod a+r "$SRC"/scodoc.dump.txt
PG_DUMPFILE="$SRC/scodoc.dump.txt"
su -c "$SCODOC_DIR/config/psql_restore_databases.sh $PG_DUMPFILE" postgres
su -c "$SCODOC_DIR/tools/psql_restore_databases.sh $PG_DUMPFILE" postgres
#
echo Copying data files...
rm -rf "${INSTANCE_DIR:?}/var"
$COPY "$SRC/var" "$INSTANCE_DIR"
rm -rf "${SCODOC_DIR:?}/var"
$COPY "$SRC/var" "$SCODOC_DIR"
if [ ! -e "${SCODOC_VAR_DIR:?}/config/" ]
then
mkdir "${SCODOC_VAR_DIR:?}/config/"
chown www-data.www-data "${SCODOC_VAR_DIR:?}/config/"
chmod 775 "${SCODOC_VAR_DIR:?}/config/"
chown "$SCODOC_USER"."$SCODOC_GROUP" "${SCODOC_VAR_DIR:?}/config/"
chmod 755 "${SCODOC_VAR_DIR:?}/config/"
fi
rm -rf "${SCODOC_DIR:?}/config/depts"
@ -119,15 +115,12 @@ then
iconv -f iso8859-15 -t utf-8 "$SCODOC_DIR/config/scodoc_config.py.orig" > "$SCODOC_DIR/config/scodoc_config.py"
fi
rm -rf "${INSTANCE_DIR:?}/log"
$COPY "$SRC/log" "$INSTANCE_DIR/"
rm -rf "${SCODOC_DIR:?}/log"
$COPY "$SRC/log" "$SCODOC_DIR/"
# Fix file ownership and access rights
chown -R www-data.root "$INSTANCE_DIR/log"
chown -R www-data.root "$INSTANCE_DIR/var"
chmod 775 "$INSTANCE_DIR./log" "$INSTANCE_DIR./var"
chown -R www-data.root "$SCODOC_DIR"
chmod -R 775 "$SCODOC_DIR"
chown -R "$SCODOC_USER"."$SCODOC_GROUP" "${SCODOC_DIR}"
chmod -R 755 "$SCODOC_DIR"
# Remove tmp directory
if [ "$IS_TMP" = "1" ]

View File

@ -6,8 +6,9 @@
# Utile pour migrer ScoDoc d'un serveur a un autre
# Executer en tant que root sur le serveur d'origine
#
# E. Viennet, Sept 2011, Aug 2020
# E. Viennet, Sept 2011, Aug 2020, Jul 2021
#
source config.sh
source utils.sh
check_uid_root "$0"
@ -33,15 +34,6 @@ else
exit 2
fi
INSTANCE_DIR=/opt/scodoc
SCODOC_DIR="$INSTANCE_DIR/Products/ScoDoc"
<<<<<<< HEAD
=======
source utils.sh
check_uid_root "$0"
>>>>>>> e2a2b0f0836fc6de922c35b77b236379783e7590
echo "Stopping ScoDoc..."
scodocctl stop
@ -51,44 +43,18 @@ chown postgres "$DEST"
su -c "pg_dumpall > \"$DEST\"/scodoc.dump.txt" postgres
if [ ! "$?" -eq 0 ]
then
<<<<<<< HEAD
printf "Error dumping postgresql database\nPlease check that SQL server is running\nAborting.\n"
=======
printf "Error dumping postgresql database\nPlease check that SQL server is running\nAborting."
>>>>>>> e2a2b0f0836fc6de922c35b77b236379783e7590
exit 1
fi
chown root "$DEST"
# Zope DB, ScoDoc archives, configuration, photos, etc.
# ScoDoc archives, configuration, photos, etc.
echo "Copying var/ ..."
cp -rp "$INSTANCE_DIR/var" "$DEST"
cp -rp "$SCODOC_DIR/var" "$DEST"
# Depts db config (now in .../var)
shopt -s nullglob
if [ -n "$(echo ${SCODOC_DIR}/config/depts/*.cfg)" ]
then
echo "Copying legacy depts configs..."
cp -rp "$SCODOC_DIR/config/depts" "$DEST"
fi
# Photos des etudiants (now in .../var)
if [ -e "$SCODOC_DIR/static/photos" ]
then
echo "Copying legacy photos..."
cp -rp "$SCODOC_DIR/static/photos" "$DEST"
fi
echo "Copying logos..."
cp -rp "$SCODOC_DIR/logos" "$DEST"
echo "Copying configuration file..."
cp -p "$SCODOC_DIR/config/scodoc_config.py" "$DEST"
echo "Copying server logs..."
cp -rp "$INSTANCE_DIR/log" "$DEST"
cp -rp "$SCODOC_DIR/log" "$DEST"
# --- Archive all files in a tarball to ease transfer

View File

@ -118,7 +118,7 @@ CONFIG.CUSTOM_HTML_FOOTER_CNX = CONFIG.CUSTOM_HTML_FOOTER
# Fichier de correspondance codelycee -> noms
# (chemin relatif au repertoire d'install des sources)
CONFIG.ETABL_FILENAME = "config/etablissements.csv"
CONFIG.ETABL_FILENAME = "tools/etablissements.csv"
# ----------------------------------------------------

View File

@ -3,7 +3,7 @@
#
# Configuration globale de ScoDoc (version juin 2009)
# Ce fichier est copié dans /opt/scodoc/var/scodoc/config
# Ce fichier est copié dans /opt/scodoc8/var/scodoc/config
# par les scripts d'installation/mise à jour.
# La plupart des réglages sont stoqués en base de donnée et accessibles via le web
@ -101,7 +101,7 @@ CONFIG = CFG()
# -----------------------------------------------------
# Fichier de correspondance codelycee -> noms
# (chemin relatif au repertoire d'install des sources)
# CONFIG.ETABL_FILENAME = "config/etablissements.csv"
# CONFIG.ETABL_FILENAME = "tools/etablissements.csv"
# ----------------------------------------------------

View File

@ -10,7 +10,7 @@
#
# E. Viennet, sep 2013, mar 2017, jun 2019, aug 2020, dec 2020
cd /opt/scodoc/Products/ScoDoc/config || { echo "Invalid directory"; exit 1; }
cd /opt/scodoc8 || { echo "Invalid directory"; exit 1; }
source config.sh
source utils.sh
@ -21,13 +21,6 @@ if [ -z "$SCODOC_UPGRADE_RUNNING" ]
apt-get update && apt-get -y dist-upgrade
fi
# Upgrade svn working copy if possible
svnver=$(svn --version --quiet)
# shellcheck disable=SC2072
if [[ ${svnver} > "1.7" ]]
then
(cd "$SCODOC_DIR"; find . -name .svn -type d -exec dirname {} \; | xargs svn upgrade)
fi
scodocctl stop
@ -39,7 +32,7 @@ SVNVERSION=$(cd ..; svnversion)
if [ ! -e "${SCODOC_VERSION_DIR}" ]; then
mkdir -p "${SCODOC_VERSION_DIR}"
chown www-data.www-data "${SCODOC_VERSION_DIR}"
chown "$SCODOC_USER"."$SCODOC_GROUP" "${SCODOC_VERSION_DIR}"
fi
if [ ! -e "${SCODOC_VERSION_DIR}"/scodoc.sn ]; then
if [ -e "$SCODOC_DIR"/config/scodoc.sn ]; then
@ -79,30 +72,14 @@ then
fi
# Fix some permissions which may have been altered in the way:
chsh -s /bin/sh "$POSTGRES_USER" # www-data, nologin in Debian 9
chown root.www-data "$SCODOC_DIR" # important to create .pyc
chmod 775 "${SCODOC_DIR}"
chmod a+r "$SCODOC_DIR"/*.py
chown -R "$SCODOC_USER"."$SCODOC_GROUP" "${SCODOC_DIR}"
chmod -R 775 "${SCODOC_DIR}"
chown -R root.www-data "$SCODOC_DIR"/config
chmod 775 "$SCODOC_DIR"/config
chmod a+rx "$SCODOC_DIR"/config/postupgrade-db.py
chmod a+r "$SCODOC_DIR"/config/scodocutils.py
chown -R root.www-data "$SCODOC_DIR"/misc
chmod -R a+r "$SCODOC_DIR"/misc
# depts dir:
if [ ! -e "${SCODOC_VAR_DIR}/config/depts" ]
then
mkdir "${SCODOC_VAR_DIR}/config/depts"
fi
# ScoDoc must be able to write to var directory:
chown -R www-data.www-data "${SCODOC_VAR_DIR}"
chmod -R u+w "${SCODOC_VAR_DIR}"
# Important to create .pyc:
chgrp -R www-data "${SCODOC_DIR}"/ZopeProducts
chmod -R g+w "${SCODOC_DIR}"/ZopeProducts
# Se recharge car ce fichier peut avoir change durant le svn up !
if [ -z "$SCODOC_UPGRADE_RUNNING" ]
@ -137,8 +114,8 @@ fi
v=$(/opt/zope213/bin/python -c "import dateutil; print dateutil.__version__")
[[ "$v" < "2.8.1" ]] && /opt/zope213/bin/pip install --upgrade python-dateutil
# Ensure www-data can duplicate databases (for dumps)
su -c $'psql -c \'alter role "www-data" with CREATEDB;\'' "$POSTGRES_SUPERUSER"
# Ensure scodoc can duplicate databases (for dumps)
su -c $'psql -c \'alter role "scodoc" with CREATEDB;\'' "$POSTGRES_SUPERUSER"
#'
# post-upgrade scripts

View File

@ -49,13 +49,13 @@ scodocctl() {
fi
}
# --- Ensure postgres user www-data exists
# --- Ensure postgres user scodoc exists
init_postgres_user() { # run as root
if [ -z $(echo "select usename from pg_user;" | su -c "$PSQL -d template1 -p $POSTGRES_PORT" $POSTGRES_SUPERUSER | grep $POSTGRES_USER) ]
then
# add database user
echo "Creating postgresql user $POSTGRES_USER"
su -c "createuser -p $POSTGRES_PORT --no-superuser --no-createdb --no-adduser --no-createrole ${POSTGRES_USER}" "$POSTGRES_SUPERUSER"
su -c "createuser -p $POSTGRES_PORT --createdb --no-superuser --no-adduser --no-createrole ${POSTGRES_USER}" "$POSTGRES_SUPERUSER"
fi
}