ScoDoc-PE/tools/debian/postinst

57 lines
2.0 KiB
Plaintext
Raw Normal View History

2021-08-24 16:18:00 +02:00
#!/bin/bash
# Post-installation de scodoc
# ici, le répertoire /opt/scodoc vient d'être installé
cd /opt/scodoc || (echo "Error chdir to /opt/scodoc"; exit 1)
2021-08-24 16:18:00 +02:00
# On peut donc charger la config:
source /opt/scodoc/tools/config.sh
source /opt/scodoc/tools/utils.sh
# -- Création au besoin de notre utilisateur
2021-08-24 18:55:58 +02:00
# adduser --system "${SCODOC_USER}"
check_create_scodoc_user
2021-08-24 16:18:00 +02:00
# -- Répertoires /opt/scodoc donné à scodoc
change_scodoc_file_ownership
# --- Création au bseoin de /opt/scodoc-data
set_scodoc_var_dir
# ------------ LOCALES (pour compat bad ScoDoc 7)
locname="en_US.UTF-8"
outname=$(echo ${locname//-/} | tr '[A-Z]' '[a-z]')
if [ "$(locale -a | grep -E -i ^${outname}$ | wc -l)" -lt 1 ]
then
echo adding $locname
echo "$locname ${locname##*.}" >> /etc/locale.gen
/usr/sbin/locale-gen --keep-existing
fi
SCODOC_RELEASE=$(grep SCOVERSION sco_version.py | awk '{ print substr($3, 2, length($3)-2) }')
SVERSION=$(curl --silent http://scodoc.iutv.univ-paris13.fr/scodoc-installmgr/version?mode=install\&release="$SCODOC_RELEASE")
echo "$SVERSION" > "${SCODOC_VERSION_DIR}/scodoc.sn"
2021-08-24 23:36:58 +02:00
# --- XXX TODO générer SECRET_KEY dans .env ?
# idealement, demander le mail de l'admin et son mot de passe lors de la première install
# python3 -c "import uuid; print(uuid.uuid4().hex)"
# ------------ CREATION DU VIRTUALENV
#echo "Creating python3 virtualenv..."
(cd $SCODOC_DIR && python3 -m venv venv) || die "Error creating Python 3 virtualenv"
# ------------ INSTALL DES PAQUETS PYTHON (3.9)
# pip in our env, as user "scodoc"
(cd $SCODOC_DIR && source venv/bin/activate && pip install wheel && pip install -r requirements-3.9.txt) || die "Error installing python packages"
# --- NGINX
ln -s /etc/nginx/sites-available/scodoc9.nginx /etc/nginx/sites-enabled/
/bin/rm -f /etc/nginx/sites-enabled/default
2021-08-24 23:36:58 +02:00
2021-08-24 16:18:00 +02:00
# --- POSTGRESQL
# --- Ensure postgres user "scodoc" ($POSTGRES_USER) exists
init_postgres_user
# --- SYSTEMD: on a installé un fichier de service
systemctl daemon-reload