forked from ScoDoc/ScoDoc
Reorganisation des fichiers, scripts d'install et doc installation
This commit is contained in:
parent
fb8f6641f8
commit
c2d89799f0
69
README.md
69
README.md
@ -42,18 +42,41 @@ On peut installer à partir de zéro, ou sur une machine ayant déjà un ScoDoc
|
||||
|
||||
### Installation
|
||||
|
||||
#### Arrêter et renommer ScoDoc7
|
||||
**Important**: si vous avez un ScoDoc7 installé sur ce serveur, le mettre à jour, l'arrêter et renommer son répertoire avant de commencer l'installation de ScoDoc 8:
|
||||
|
||||
1. S'assurer que l'installation ScoDoc 7 est à jour
|
||||
|
||||
sudo su
|
||||
cd /opt/scodoc/Products/ScoDoc/config
|
||||
./upgrade.sh
|
||||
|
||||
2. Arrêter le service ScoDoc 7
|
||||
|
||||
systemctl stop scodoc7
|
||||
|
||||
S'assurer qu'il est bien stoppé (`ps auxw`, ...), sans qui la migration va échouer.
|
||||
|
||||
3. Renommer le répertoire de ScoDoc 7:
|
||||
|
||||
sudo su
|
||||
mv /opt/scodoc /opt/scodoc7
|
||||
|
||||
Les données pourront être migrées après installation la nouvelle evrsion, voir plus loin.
|
||||
|
||||
#### Installer ScoDoc
|
||||
Sur un système Linux Debian 10, en tant que `root`:
|
||||
|
||||
- Charger la dernière release depuis https://scodoc.org/git/viennet/ScoDoc/releases
|
||||
|
||||
- Déplacer ou copier le fichier `scodoc-v8.x.y.tgz` dans `/opt` et le décomprimer:
|
||||
- Déplacer ou copier le fichier `scodoc-x.y.z.tgz` dans `/opt` et le décomprimer:
|
||||
|
||||
sudo su
|
||||
cd /opt; tar xf - scodoc-v8.x.y.tgz # remplacer x et y par votre version
|
||||
cd /opt; tar xf - scodoc-x.y.z.tgz # remplacer x.y.z par votre version
|
||||
|
||||
- Lancer le script d'installation:
|
||||
|
||||
cd /opt/scodoc8/tools
|
||||
cd /opt/scodoc/tools
|
||||
./install_debian10.sh
|
||||
|
||||
ce script crée un compte utilisateur "scodoc".
|
||||
@ -71,7 +94,7 @@ via `sqlalchemy`.
|
||||
Lancer le script:
|
||||
|
||||
su postgres
|
||||
cd /opt/scodoc8/tools
|
||||
cd /opt/scodoc/tools
|
||||
./create_database.sh
|
||||
|
||||
Ce script crée une base nommée `SCO8USERS`, appartenant à l'utilisateur (role) postgres `scodoc`.
|
||||
@ -115,23 +138,11 @@ Le script `migrate_from_scodoc7.sh` va déplacer les donneés et reconfigurer le
|
||||
de votre installation ScoDoc 7 pour passer à ScoDoc 8 (*ne pas utiliser en production !*).
|
||||
**Les modifications effectuées sont sans retour: ScoDoc 7 ne fonctionnera plus !**
|
||||
|
||||
1. S'assurer que l'installation ScoDoc 7 est à jour
|
||||
|
||||
sudo su
|
||||
cd /opt/scodoc/Products/ScoDoc/config
|
||||
./upgrade.sh
|
||||
|
||||
2. Arrêter le service ScoDoc 7
|
||||
|
||||
systemctl stop scodoc7
|
||||
|
||||
S'assurer qu'il est bien stoppé (`ps auxw`, ...), sans qui la migration va échouer.
|
||||
|
||||
3. Lancer le script de migration
|
||||
1. Lancer le script de migration
|
||||
ScoDoc 8 doit avoir été installé comme expliqué plus haut.
|
||||
|
||||
sudo su
|
||||
cd /opt/scodoc8/tools
|
||||
cd /opt/scodoc/tools
|
||||
./migrate_from_scodoc7.sh
|
||||
|
||||
|
||||
@ -149,6 +160,28 @@ En tant qu'utilisateur `scodoc` (pour avoir accès aux bases départements de Sc
|
||||
export FLASK_ENV=development
|
||||
flask run --host=0.0.0.0
|
||||
|
||||
## Organisation des fichiers
|
||||
|
||||
L'installation comporte les fichiers de l'application, sous `/opt/scodoc/`, et les fichiers locaux (archives, photos, configurations, logs) sous `/opt/scodoc-data`. Par ailleurs, il y a évidemment les bases de données postgresql et la configuration du système.
|
||||
|
||||
### Fichiers locaux
|
||||
Sous `/opt/scodoc-data`, fichiers et répertoires appartienant à l'utilisateur `scodoc`.
|
||||
Ils ne doivent pas être modifiés à la main, sauf certains fichiers de configuration sous
|
||||
`/opt/scodoc-data/config`.
|
||||
|
||||
Le répertoire `/opt/scodoc-data` doit être régulièrement sauvegardé.
|
||||
|
||||
Principaux contenus:
|
||||
|
||||
/opt/scodoc-data
|
||||
/opt/scodoc-data/log # Fichiers de log ScoDoc
|
||||
/opt/scodoc-data/config # Fichiers de configuration
|
||||
.../config/logos # Logos de l'établissement
|
||||
.../config/depts # un fichier par département
|
||||
/opt/scodoc-data/photos # Photos des étudiants
|
||||
/opt/scodoc-data/archives # Archives: PV de jury, maquettes Apogée, fichiers étudiants
|
||||
|
||||
|
||||
## Tests unitaires
|
||||
|
||||
pytest tests/unit
|
||||
|
@ -445,13 +445,11 @@ def get_templates_from_distrib(template="avis"):
|
||||
|
||||
if template in ["avis", "footer"]:
|
||||
# pas de preference pour le template: utilise fichier du serveur
|
||||
p = os.path.join(scu.SCO_SRC_DIR, pe_local_tmpl)
|
||||
if os.path.exists(p):
|
||||
template_latex = get_code_latex_from_modele(p)
|
||||
if os.path.exists(pe_local_tmpl):
|
||||
template_latex = get_code_latex_from_modele(pe_local_tmpl)
|
||||
else:
|
||||
p = os.path.join(scu.SCO_SRC_DIR, pe_default_tmpl)
|
||||
if os.path.exists(p):
|
||||
template_latex = get_code_latex_from_modele(p)
|
||||
if os.path.exists(pe_default_tmpl):
|
||||
template_latex = get_code_latex_from_modele(pe_default_tmpl)
|
||||
else:
|
||||
template_latex = "" # fallback: avis vides
|
||||
return template_latex
|
||||
|
@ -62,11 +62,14 @@ else:
|
||||
# Generated LaTeX files are encoded as:
|
||||
PE_LATEX_ENCODING = "utf-8"
|
||||
|
||||
REP_DEFAULT_AVIS = "config/doc_poursuites_etudes/"
|
||||
# /opt/scodoc/tools/doc_poursuites_etudes
|
||||
REP_DEFAULT_AVIS = os.path.join(scu.SCO_TOOLS_DIR, "doc_poursuites_etudes/")
|
||||
REP_LOCAL_AVIS = os.path.join(scu.SCODOC_CFG_DIR, "doc_poursuites_etudes/")
|
||||
|
||||
PE_DEFAULT_AVIS_LATEX_TMPL = REP_DEFAULT_AVIS + "distrib/modeles/un_avis.tex"
|
||||
PE_LOCAL_AVIS_LATEX_TMPL = REP_DEFAULT_AVIS + "local/modeles/un_avis.tex"
|
||||
PE_LOCAL_AVIS_LATEX_TMPL = REP_LOCAL_AVIS + "local/modeles/un_avis.tex"
|
||||
PE_DEFAULT_FOOTER_TMPL = REP_DEFAULT_AVIS + "distrib/modeles/un_footer.tex"
|
||||
PE_LOCAL_FOOTER_TMPL = REP_DEFAULT_AVIS + "local/modeles/un_footer.tex"
|
||||
PE_LOCAL_FOOTER_TMPL = REP_LOCAL_AVIS + "local/modeles/un_footer.tex"
|
||||
|
||||
# ----------------------------------------------------------------------------------------
|
||||
|
||||
@ -176,15 +179,14 @@ def add_pe_stuff_to_zip(context, zipfile, ziproot):
|
||||
|
||||
Also copy logos
|
||||
"""
|
||||
PE_AUX_DIR = os.path.join(scu.SCO_SRC_DIR, "config/doc_poursuites_etudes")
|
||||
distrib_dir = os.path.join(PE_AUX_DIR, "distrib")
|
||||
distrib_dir = os.path.join(REP_DEFAULT_AVIS, "distrib")
|
||||
distrib_pathnames = list_directory_filenames(
|
||||
distrib_dir
|
||||
) # eg /opt/scodoc/Products/ScoDoc/config/doc_poursuites_etudes/distrib/modeles/toto.tex
|
||||
) # eg /opt/scodoc/tools/doc_poursuites_etudes/distrib/modeles/toto.tex
|
||||
l = len(distrib_dir)
|
||||
distrib_filenames = {x[l + 1 :] for x in distrib_pathnames} # eg modeles/toto.tex
|
||||
|
||||
local_dir = os.path.join(PE_AUX_DIR, "local")
|
||||
local_dir = os.path.join(REP_LOCAL_AVIS, "local")
|
||||
local_pathnames = list_directory_filenames(local_dir)
|
||||
l = len(local_dir)
|
||||
local_filenames = {x[l + 1 :] for x in local_pathnames}
|
||||
|
@ -29,8 +29,8 @@
|
||||
|
||||
|
||||
Archives are plain files, stored in
|
||||
<INSTANCE_HOME>/var/scodoc/archives/<deptid>
|
||||
(where <INSTANCE_HOME> is usually /opt/scodoc/instance, and <deptid> a departement id)
|
||||
<SCODOC_VAR_DIR>/archives/<deptid>
|
||||
(where <SCODOC_VAR_DIR> is usually /opt/scodoc-data, and <deptid> a departement id)
|
||||
|
||||
Les PV de jurys et documents associés sont stockées dans un sous-repertoire de la forme
|
||||
<archivedir>/<dept>/<formsemestre_id>/<YYYY-MM-DD-HH-MM-SS>
|
||||
@ -72,7 +72,7 @@ from app.scodoc import sco_pvpdf
|
||||
|
||||
class BaseArchiver(object):
|
||||
def __init__(self, archive_type=""):
|
||||
dirs = [Config.INSTANCE_HOME, "var", "scodoc", "archives"]
|
||||
dirs = [Config.SCODOC_VAR_DIR, "archives"]
|
||||
if archive_type:
|
||||
dirs.append(archive_type)
|
||||
self.root = os.path.join(*dirs)
|
||||
|
@ -87,7 +87,10 @@ class ScoDocCache:
|
||||
"""Store value"""
|
||||
key = cls._get_key(oid)
|
||||
log(f"CACHE key={key}, timeout={cls.timeout}")
|
||||
return CACHE.set(key, value, timeout=cls.timeout)
|
||||
status = CACHE.set(key, value, timeout=cls.timeout)
|
||||
if not status:
|
||||
log("Error: cache set failed")
|
||||
return status
|
||||
|
||||
@classmethod
|
||||
def delete(cls, oid):
|
||||
@ -205,9 +208,7 @@ class NotesTableCache(ScoDocCache):
|
||||
nt = notes_table.NotesTable(None, formsemestre_id)
|
||||
dt = time.time() - t0
|
||||
log("caching formsemestre_id=%s (%gs)" % (formsemestre_id, dt))
|
||||
s = cls.set(formsemestre_id, nt)
|
||||
if not s:
|
||||
log("Warning: cache.set failed")
|
||||
_ = cls.set(formsemestre_id, nt)
|
||||
return nt
|
||||
|
||||
|
||||
|
@ -89,8 +89,8 @@ 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"
|
||||
# (dans tools/)
|
||||
CONFIG.ETABL_FILENAME = "etablissements.csv"
|
||||
|
||||
# ----------------------------------------------------
|
||||
# -------------- Divers:
|
||||
|
@ -124,7 +124,6 @@ def _report_request(context, REQUEST, fmt="txt"):
|
||||
HTTP_USER_AGENT=HTTP_USER_AGENT,
|
||||
form=REQUEST.form,
|
||||
HTTP_X_FORWARDED_FOR="?",
|
||||
svn_version=scu.get_svn_version(scu.SCO_SRC_DIR),
|
||||
SCOVERSION=VERSION.SCOVERSION,
|
||||
)
|
||||
txt = (
|
||||
|
@ -29,7 +29,7 @@
|
||||
"""
|
||||
|
||||
# Ancien module "scolars"
|
||||
|
||||
import os
|
||||
import time
|
||||
|
||||
from flask import url_for, g
|
||||
@ -811,7 +811,7 @@ appreciations_edit = _appreciationsEditor.edit
|
||||
|
||||
# -------- Noms des Lycées à partir du code
|
||||
def read_etablissements():
|
||||
filename = scu.SCO_SRC_DIR + "/" + scu.CONFIG.ETABL_FILENAME
|
||||
filename = os.path.join(scu.SCO_TOOLS_DIR, scu.CONFIG.ETABL_FILENAME)
|
||||
log("reading %s" % filename)
|
||||
f = open(filename)
|
||||
L = [x[:-1].split(";") for x in f]
|
||||
|
@ -28,10 +28,10 @@
|
||||
""" Importation des etudiants à partir de fichiers CSV
|
||||
"""
|
||||
|
||||
|
||||
import time
|
||||
import collections
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
|
||||
import app.scodoc.sco_utils as scu
|
||||
import app.scodoc.notesdb as ndb
|
||||
@ -59,8 +59,8 @@ from app.scodoc import sco_groups_view
|
||||
from app.scodoc import sco_news
|
||||
from app.scodoc import sco_preferences
|
||||
|
||||
# format description (relative to Product directory))
|
||||
FORMAT_FILE = "misc/format_import_etudiants.txt"
|
||||
# format description (in tools/)
|
||||
FORMAT_FILE = "format_import_etudiants.txt"
|
||||
|
||||
# Champs modifiables via "Import données admission"
|
||||
ADMISSION_MODIFIABLE_FIELDS = (
|
||||
@ -109,7 +109,7 @@ ADMISSION_MODIFIABLE_FIELDS = (
|
||||
def sco_import_format(with_codesemestre=True):
|
||||
"returns tuples (Attribut, Type, Table, AllowNulls, Description)"
|
||||
r = []
|
||||
for l in open(scu.SCO_SRC_DIR + "/" + FORMAT_FILE):
|
||||
for l in open(os.path.join(scu.SCO_TOOLS_DIR, FORMAT_FILE)):
|
||||
l = l.strip()
|
||||
if l and l[0] != "#":
|
||||
fs = l.split(";")
|
||||
|
@ -70,8 +70,8 @@ import app.scodoc.notesdb as ndb
|
||||
import app.scodoc.sco_utils as scu
|
||||
|
||||
# Full paths on server's filesystem. Something like "/opt/scodoc/var/scodoc/photos"
|
||||
PHOTO_DIR = os.path.join(Config.INSTANCE_HOME, "var", "scodoc", "photos")
|
||||
ICONS_DIR = os.path.join(scu.SCO_SRC_DIR, "app", "static", "icons")
|
||||
PHOTO_DIR = os.path.join(Config.SCODOC_VAR_DIR, "photos")
|
||||
ICONS_DIR = os.path.join(Config.SCODOC_DIR, "app", "static", "icons")
|
||||
UNKNOWN_IMAGE_PATH = os.path.join(ICONS_DIR, "unknown.jpg")
|
||||
UNKNOWN_IMAGE_URL = "get_photo_image?etudid=" # with empty etudid => unknown face image
|
||||
IMAGE_EXT = ".jpg"
|
||||
|
@ -220,24 +220,22 @@ def group_by_key(d, key):
|
||||
# ----- Global lock for critical sections (except notes_tables caches)
|
||||
GSL = six.moves._thread.allocate_lock() # Global ScoDoc Lock
|
||||
|
||||
# ----- Repertoire "var" (local)
|
||||
SCODOC_VAR_DIR = os.path.join(Config.INSTANCE_HOME, "var", "scodoc")
|
||||
SCODOC_DIR = Config.SCODOC_DIR
|
||||
|
||||
# ----- Repertoire "config" modifiable
|
||||
# /opt/scodoc/var/scodoc/config
|
||||
SCODOC_CFG_DIR = os.path.join(SCODOC_VAR_DIR, "config")
|
||||
# /opt/scodoc-data/config
|
||||
SCODOC_CFG_DIR = os.path.join(Config.SCODOC_VAR_DIR, "config")
|
||||
# ----- Version information
|
||||
SCODOC_VERSION_DIR = os.path.join(SCODOC_CFG_DIR, "version")
|
||||
# ----- Repertoire tmp
|
||||
SCO_TMP_DIR = os.path.join(SCODOC_VAR_DIR, "tmp")
|
||||
# ----- Repertoire tmp : /opt/scodoc-data/tmp
|
||||
SCO_TMP_DIR = os.path.join(Config.SCODOC_VAR_DIR, "tmp")
|
||||
if not os.path.exists(SCO_TMP_DIR):
|
||||
os.mkdir(SCO_TMP_DIR, 0o755)
|
||||
# ----- Les logos: /opt/scodoc/var/scodoc/config/logos
|
||||
# ----- Les logos: /opt/scodoc-data/config/logos
|
||||
SCODOC_LOGOS_DIR = os.path.join(SCODOC_CFG_DIR, "logos")
|
||||
|
||||
# Racine projet: /.../ScoDoc/
|
||||
SCO_SRC_DIR = os.path.join(Config.INSTANCE_HOME, "Products", "ScoDoc")
|
||||
# - Les outils distribués
|
||||
SCO_TOOLS_DIR = os.path.join(SCO_SRC_DIR, "config")
|
||||
# ----- Les outils distribués
|
||||
SCO_TOOLS_DIR = os.path.join(Config.SCODOC_DIR, "tools")
|
||||
|
||||
|
||||
# ----- Lecture du fichier de configuration
|
||||
@ -720,7 +718,14 @@ def icontag(name, file_format="png", **attrs):
|
||||
"""
|
||||
if ("width" not in attrs) or ("height" not in attrs):
|
||||
if name not in ICONSIZES:
|
||||
img_file = SCO_SRC_DIR + "/app/static/icons/%s.%s" % (name, file_format)
|
||||
img_file = os.path.join(
|
||||
Config.SCODOC_DIR,
|
||||
"app/static/icons/%s.%s"
|
||||
% (
|
||||
name,
|
||||
file_format,
|
||||
),
|
||||
)
|
||||
im = PILImage.open(img_file)
|
||||
width, height = im.size[0], im.size[1]
|
||||
ICONSIZES[name] = (width, height) # cache
|
||||
|
@ -125,7 +125,7 @@ def sco_publish(route, function, permission, methods=("GET",)):
|
||||
)
|
||||
|
||||
|
||||
log.set_log_directory(Config.INSTANCE_HOME + "/log")
|
||||
log.set_log_directory(Config.SCODOC_VAR_DIR + "/log")
|
||||
log("ScoDoc8 restarting...")
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
@ -28,11 +28,8 @@ class Config:
|
||||
ADMINS = [SCODOC_ADMIN_MAIL]
|
||||
SCODOC_ERR_MAIL = os.environ.get("SCODOC_ERR_MAIL")
|
||||
BOOTSTRAP_SERVE_LOCAL = os.environ.get("BOOTSTRAP_SERVE_LOCAL")
|
||||
# for ScoDoc 7 compat (à changer)
|
||||
INSTANCE_HOME = os.environ.get("INSTANCE_HOME", "/opt/scodoc")
|
||||
SCODOC_VAR_DIR = os.path.join(
|
||||
os.environ.get("INSTANCE_HOME", "/opt/scodoc"), "var", "scodoc"
|
||||
)
|
||||
SCODOC_DIR = os.environ.get("SCODOC_DIR", "/opt/scodoc")
|
||||
SCODOC_VAR_DIR = os.environ.get("SCODOC_VAR_DIR", "/opt/scodoc-data")
|
||||
|
||||
# For legacy ScoDoc7 installs: postgresql user
|
||||
SCODOC7_SQL_USER = os.environ.get("SCODOC7_SQL_USER", "www-data")
|
||||
|
@ -17,6 +17,7 @@ import pprint
|
||||
import random
|
||||
|
||||
import scodoc_manager
|
||||
from config import Config
|
||||
from app.scodoc import notesdb as ndb
|
||||
from app.scodoc import sco_codes_parcours
|
||||
from app.scodoc import sco_edit_formation
|
||||
@ -40,7 +41,7 @@ from app.scodoc.sco_exceptions import ScoValueError
|
||||
random.seed(12345) # tests reproductibles
|
||||
|
||||
|
||||
DEMO_DIR = scu.SCO_SRC_DIR + "/scotests/demo/"
|
||||
DEMO_DIR = Config.SCODOC_DIR + "/scotests/demo/"
|
||||
NOMS = [x.strip() for x in open(DEMO_DIR + "/noms.txt").readlines()]
|
||||
PRENOMS_H = [x.strip() for x in open(DEMO_DIR + "/prenoms-h.txt").readlines()]
|
||||
PRENOMS_F = [x.strip() for x in open(DEMO_DIR + "/prenoms-f.txt").readlines()]
|
||||
|
@ -30,6 +30,15 @@ def test_notes_table(test_client):
|
||||
assert sco_cache.NotesTableCache.get(formsemestre_id, compute=False)
|
||||
sco_cache.invalidate_formsemestre(formsemestre_id)
|
||||
assert not sco_cache.NotesTableCache.get(formsemestre_id, compute=False)
|
||||
# cache les 5 premiers
|
||||
for sem in sems[:5]:
|
||||
formsemestre_id = sem["formsemestre_id"]
|
||||
nt = sco_cache.NotesTableCache.get(formsemestre_id)
|
||||
assert sco_cache.NotesTableCache.get(formsemestre_id, compute=False)
|
||||
# assert "SEM38882" in {s["formsemestre_id"] for s in sems}
|
||||
# formsemestre_id = "SEM38882"
|
||||
# nt = sco_cache.NotesTableCache.get(formsemestre_id)
|
||||
# assert sco_cache.NotesTableCache.get(formsemestre_id, compute=False)
|
||||
|
||||
|
||||
def test_cache_evaluations(test_client):
|
||||
|
@ -16,11 +16,9 @@ export PATH="${PATH}":/usr/sbin:/sbin
|
||||
# ScoDoc: environment variables
|
||||
umask 0022
|
||||
|
||||
export SCODOC_DIR=/opt/scodoc8
|
||||
export SCODOC_DIR=/opt/scodoc
|
||||
export SCODOC_VAR_DIR=/opt/scodoc-data
|
||||
|
||||
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"
|
||||
|
||||
|
@ -8,15 +8,14 @@
|
||||
#
|
||||
DEST_ADDRESS=emmanuel.viennet@gmail.com
|
||||
|
||||
INSTANCE_DIR=/opt/scodoc
|
||||
|
||||
TMP=/tmp/scodoc-$(date +%F-%s)
|
||||
|
||||
DEPTS_TO_SAVE=""
|
||||
SAVE_USERS=0
|
||||
SEND_BY_MAIL=1
|
||||
|
||||
SCODOC_HOME="/opt/scodoc8"
|
||||
SCODOC_DIR="/opt/scodoc"
|
||||
SCODOC_VAR_DIR="/opt/scodoc-data"
|
||||
|
||||
# -------------------------------------
|
||||
# Arguments
|
||||
@ -76,7 +75,7 @@ fi
|
||||
mkdir "$TMP"
|
||||
|
||||
# Files to copy:
|
||||
FILES="/etc/hosts /etc/debian_version /etc/apt /etc/apache2"
|
||||
FILES="/etc/hosts /etc/debian_version /etc/apt /etc/apache2 $SCODOC_DIR/VERSION"
|
||||
|
||||
|
||||
echo "ScoDoc diagnostic: informations about your system will be "
|
||||
@ -92,18 +91,8 @@ echo "left in ${TMP}"
|
||||
# Logs
|
||||
# -------------------------------------
|
||||
|
||||
copy_log() {
|
||||
if [ -e "$1" ]
|
||||
then
|
||||
cp "$1" "$TMP"/scodoc_logs/
|
||||
fi
|
||||
}
|
||||
mkdir "$TMP"/scodoc_logs/
|
||||
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"
|
||||
|
||||
cp "$SCODOC_VAR_DIR"/log/*.log "$TMP"/scodoc_logs/
|
||||
|
||||
# -------------------------------------
|
||||
# Linux System Configuration
|
||||
@ -126,7 +115,7 @@ ls -laR "$SCODOC_HOME" > "$TMP"/ls-laR
|
||||
# Databases configurations
|
||||
# -------------------------------------
|
||||
(su postgres -c "psql -l") > "${TMP}/psql-l.out"
|
||||
for dept in "${INSTANCE_DIR}"/var/scodoc/config/depts/*.cfg
|
||||
for dept in "${SCODOC_VAR_DIR}"/config/depts/*.cfg
|
||||
do
|
||||
cnx=$(cat "$dept")
|
||||
(su postgres -c "echo '\dt' | psql -d $cnx") > "${TMP}/psql-$(basename ${dept%%.*}).out"
|
||||
@ -138,8 +127,11 @@ done
|
||||
# -------------------------------------
|
||||
# copy files:
|
||||
for f in $FILES
|
||||
do
|
||||
cp -R "$f" "$TMP"
|
||||
do
|
||||
if [ -e "$f" ]
|
||||
then
|
||||
cp -R "$f" "$TMP"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
|
@ -14,5 +14,5 @@ Description=Update ScoDoc Software
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/opt/scodoc8/tools/upgrade.sh
|
||||
ExecStart=/opt/scodoc/tools/upgrade.sh
|
||||
|
||||
|
@ -11,7 +11,9 @@
|
||||
source config.sh
|
||||
source utils.sh
|
||||
|
||||
check_uid_root $0
|
||||
check_uid_root "$0"
|
||||
|
||||
cd "$SCODOC_DIR" || die "can't cd $SCODOC_DIR"
|
||||
|
||||
# ------------ Safety checks
|
||||
if [ "${debian_version}" != "10" ]
|
||||
@ -29,13 +31,24 @@ fi
|
||||
# ------------ Unix user
|
||||
check_create_scodoc_user
|
||||
|
||||
# --- Create empty .../var/ subdir
|
||||
echo "Creating empty local directories..."
|
||||
for d in var var/scodoc var/scodoc/archives var/scodoc/photos var/scodoc/tmp var/scodoc/config var/scodoc/config/version var/scodoc/config/depts var/scodoc/config/logos
|
||||
do
|
||||
[ -d "$d" ] || mkdir "$d" || die "can't create $d subdirectory"
|
||||
done
|
||||
|
||||
# ------------ Permissions & directories
|
||||
change_scodoc_file_ownership
|
||||
set_scodoc_var_dir
|
||||
|
||||
# ------------ AJOUT DES PAQUETS DEBIAN NECESSAIRES
|
||||
apt-get update
|
||||
apt-get -y install gcc
|
||||
apt-get -y install python3-dev
|
||||
apt-get -y install python3-venv
|
||||
apt-get -y install python3-pip
|
||||
apt-get install -y python3-wheel
|
||||
apt-get -y install libpq-dev
|
||||
apt-get -y install libcrack2-dev
|
||||
apt-get -y install postgresql
|
||||
@ -44,12 +57,12 @@ apt-get -y install graphviz
|
||||
|
||||
# ------------ CREATION DU VIRTUALENV
|
||||
echo "Creating python3 virtualenv..."
|
||||
cd "$SCODOC_DIR" || die "can't cd $SCODOC_DIR"
|
||||
python3 -m venv venv || die "can't create Python 3 virtualenv"
|
||||
|
||||
# ------------ INSTALL DES PAQUETS PYTHON (3.7)
|
||||
# ScoDoc8 uses pip in our env
|
||||
source venv/bin/activate
|
||||
pip install --upgrade pip
|
||||
pip install wheel
|
||||
pip install -r requirements-3.7.txt
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# INUTILE
|
||||
|
||||
# Préparation d'une release ScoDoc
|
||||
# Download last git
|
||||
source config.sh
|
||||
@ -61,18 +63,13 @@ git clone "$SOURCE_URL" || die "git error cloning $SOURCE_URL"
|
||||
cd ScoDoc || die "no ScoDoc directory !"
|
||||
git checkout "$SOURCE_BRANCH" || die "git ckecking out branch $SOURCE_BRANCH"
|
||||
|
||||
# --- Create empty .../var/ subdir
|
||||
echo "Creating empty local directories..."
|
||||
mkdir -p var/scodoc || die "can't create var subdirectory"
|
||||
mkdir var/scodoc/archives var/scodoc/photos var/scodoc/tmp var/scodoc/config
|
||||
mkdir var/scodoc/config/version var/scodoc/config/depts var/scodoc/config/logos
|
||||
cd ..
|
||||
|
||||
# --- Archive
|
||||
echo "Preparing archive..."
|
||||
mv ScoDoc scodoc8
|
||||
chown -R scodoc scodoc8
|
||||
tar cfz "$RESULTFILE" scodoc8
|
||||
mv ScoDoc scodoc
|
||||
chown -R scodoc scodoc
|
||||
tar cfz "$RESULTFILE" scodoc
|
||||
echo
|
||||
echo "Release: $(pwd)/$RESULTFILE"
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Migre une install ScoDoc 7 vers ScoDoc 8
|
||||
# Le ScoDoc7 est supposé être dans /opt/scodoc/Products/ScoDoc
|
||||
# Le nouveau est /opt/scodoc8/
|
||||
# Le ScoDoc7 est supposé être dans /opt/scodoc7/Products/ScoDoc
|
||||
# Le nouveau est /opt/scodoc/
|
||||
#
|
||||
# L'install ScoDoc7 de départ doit impérativement être à jour (upgrade.sh).
|
||||
#
|
||||
# 1- Utilisateur Unix:
|
||||
# scodoc7 tournait comme www-data
|
||||
# scodoc8 tourne sous l'utilisateur unix scodoc
|
||||
# scodoc >= 8 tourne sous l'utilisateur unix scodoc
|
||||
#
|
||||
# 2- Utilisateur postgresql (bases de données)
|
||||
# scodoc7 les bases appartenaient à "www-data"
|
||||
@ -17,7 +17,7 @@
|
||||
# idem pour la base SCOUSERS (avant sa migration vers SCO8USERS)
|
||||
#
|
||||
# 3- Fichiers de données et config locale:
|
||||
# archives, photos: /opt/scodoc/var/ => /opt/scodoc8/var
|
||||
# archives, photos: /opt/scodoc/var/ => /opt/scodoc-data
|
||||
#
|
||||
# 4- TODO migrer de Apache à nginx, installer memcached, scripts service systemd
|
||||
#
|
||||
@ -26,7 +26,7 @@ source config.sh
|
||||
source utils.sh
|
||||
check_uid_root
|
||||
|
||||
SCODOC7_HOME="/opt/scodoc"
|
||||
SCODOC7_HOME="/opt/scodoc7"
|
||||
SCODOC7_DIR="${SCODOC7_HOME}/Products/ScoDoc"
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ migrate_database_ownership() {
|
||||
su -c "psql -c 'REASSIGN OWNED BY \"www-data\" TO scodoc;'" "$POSTGRES_SUPERUSER"
|
||||
}
|
||||
|
||||
# --- 3. Fichiers locaux: /opt/scodoc/var => /opt/scodoc8/var
|
||||
# --- 3. Fichiers locaux: /opt/scodoc/var => /opt/scodoc-data
|
||||
migrate_local_files() {
|
||||
SCODOC_VAR_DIR_BACKUP="$SCODOC_VAR_DIR".bak
|
||||
if [ -e "$SCODOC_VAR_DIR_BACKUP" ]
|
||||
@ -53,7 +53,15 @@ migrate_local_files() {
|
||||
echo "renomme $SCODOC_VAR_DIR en $SCODOC_VAR_DIR_BACKUP"
|
||||
mv "$SCODOC_VAR_DIR" "$SCODOC_VAR_DIR_BACKUP"
|
||||
fi
|
||||
mv "${SCODOC7_HOME}"/var/* "$SCODOC_VAR_DIR" || die "migrate_local_files failed"
|
||||
mv "${SCODOC7_HOME}"/var/scodoc/* "$SCODOC_VAR_DIR" || die "migrate_local_files failed"
|
||||
|
||||
# Templates locaux poursuites etudes
|
||||
if [ -e "${SCODOC7_DIR}"/config/doc_poursuites_etudes/local ]
|
||||
then
|
||||
mv "${SCODOC7_DIR}"/config/doc_poursuites_etudes/local "$SCODOC_VAR_DIR"/config/doc_poursuites_etudes || die "migrate_local_files failed to migrate doc_poursuites_etudes/local"
|
||||
fi
|
||||
# S'assure que le propriétaire est "scodoc":
|
||||
chown -R "${SCODOC_USER}:${SCODOC_GROUP}" "${SCODOC_VAR_DIR}" || die "change_scodoc_file_ownership failed on ${SCODOC_VAR_DIR}"
|
||||
}
|
||||
|
||||
|
||||
@ -85,5 +93,12 @@ read -r ans
|
||||
if [ "$(norm_ans "$ans")" != 'N' ]
|
||||
then
|
||||
migrate_local_files
|
||||
else
|
||||
echo -n "Vérifier et créer si besoin le répertoire local /opt/scodoc-data ?"
|
||||
read -r ans
|
||||
if [ "$(norm_ans "$ans")" != 'N' ]
|
||||
then
|
||||
set_scodoc_var_dir
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -117,8 +117,8 @@ 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 = "tools/etablissements.csv"
|
||||
# (dans tools/)
|
||||
CONFIG.ETABL_FILENAME = "etablissements.csv"
|
||||
|
||||
|
||||
# ----------------------------------------------------
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#
|
||||
# Configuration globale de ScoDoc (version juin 2009)
|
||||
# Ce fichier est copié dans /opt/scodoc8/var/scodoc/config
|
||||
# Ce fichier est copié dans /opt/scodoc-data/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
|
||||
@ -100,8 +100,7 @@ CONFIG = CFG()
|
||||
# -------------- Noms de Lycées
|
||||
# -----------------------------------------------------
|
||||
# Fichier de correspondance codelycee -> noms
|
||||
# (chemin relatif au repertoire d'install des sources)
|
||||
# CONFIG.ETABL_FILENAME = "tools/etablissements.csv"
|
||||
# CONFIG.ETABL_FILENAME = "etablissements.csv"
|
||||
|
||||
|
||||
# ----------------------------------------------------
|
||||
|
@ -12,12 +12,6 @@ import traceback
|
||||
|
||||
sys.path.append("..")
|
||||
|
||||
# INSTANCE_HOME est nécessaire pour sco_utils.py
|
||||
# note: avec le python 2.7 de Zope2, l'import de pyscopg2 change
|
||||
# INSTANCE_HOME dans l'environnement !
|
||||
# Ici on le fixe à la "bonne" valeur pour ScoDoc7.
|
||||
os.environ["INSTANCE_HOME"] = "/opt/scodoc"
|
||||
|
||||
|
||||
def log(msg):
|
||||
"write msg on stderr, add newline and flush"
|
||||
|
@ -10,7 +10,10 @@
|
||||
#
|
||||
# E. Viennet, sep 2013, mar 2017, jun 2019, aug 2020, dec 2020
|
||||
|
||||
cd /opt/scodoc8 || { echo "Invalid directory"; exit 1; }
|
||||
|
||||
A REVOIR : utiliser releases
|
||||
|
||||
cd /opt/scodoc || { echo "Invalid directory"; exit 1; }
|
||||
source config.sh
|
||||
source utils.sh
|
||||
|
||||
|
@ -72,10 +72,21 @@ check_create_scodoc_user() {
|
||||
|
||||
# --- Give all ScoDoc files to user "scodoc":
|
||||
change_scodoc_file_ownership() {
|
||||
echo "Changing owner of $SCODOC_DIR to ${SCODOC_USER}"
|
||||
chown -R "${SCODOC_USER}:${SCODOC_GROUP}" "$SCODOC_DIR"
|
||||
echo "Changing owner of ${SCODOC_DIR} to ${SCODOC_USER}"
|
||||
chown -R "${SCODOC_USER}:${SCODOC_GROUP}" "${SCODOC_DIR}" || die "change_scodoc_file_ownership failed on ${SCODOC_DIR}"
|
||||
}
|
||||
|
||||
# Création du répertoire local (scodoc-data) et vérification du propriétaire
|
||||
set_scodoc_var_dir() {
|
||||
echo "Checking $SCODOC_VAR_DIR..."
|
||||
for d in archives photos tmp log config config/version config/depts config/logos
|
||||
do
|
||||
[ -d "$SCODOC_VAR_DIR/$d" ] || mkdir "$SCODOC_VAR_DIR/$d" || die "can't create $SCODOC_VAR_DIR/$d subdirectory"
|
||||
done
|
||||
chown -R "${SCODOC_USER}:${SCODOC_GROUP}" "${SCODOC_VAR_DIR}" || die "change_scodoc_file_ownership failed on ${SCODOC_VAR_DIR}"
|
||||
}
|
||||
|
||||
|
||||
# XXX inutilise
|
||||
gen_passwd() {
|
||||
PASSWORD_LENGTH="8"
|
||||
|
Loading…
Reference in New Issue
Block a user