forked from ScoDoc/ScoDoc
90 lines
2.7 KiB
Bash
90 lines
2.7 KiB
Bash
#!/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)
|
|
|
|
# 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
|
|
# adduser --system "${SCODOC_USER}"
|
|
check_create_scodoc_user
|
|
|
|
# -- 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
|
|
|
|
# Le numero de version complet, genre 9.0.0
|
|
SCODOC_RELEASE=$(grep SCOVERSION $SCODOC_DIR/sco_version.py | awk '{ print substr($3, 2, length($3)-2) }')
|
|
if [ -e "${SCODOC_VERSION_DIR}/scodoc.sn" ]
|
|
then
|
|
# upgrading
|
|
echo "mode: upgrade"
|
|
mode=upgrade
|
|
SN=$(cat "${SCODOC_VERSION_DIR}"/scodoc.sn)
|
|
if [[ ! "${SN}" =~ ^[0-9].* ]]
|
|
then
|
|
SN='' # fix for invalid previous replies
|
|
fi
|
|
else
|
|
# first install
|
|
echo "mode: install"
|
|
mode=install
|
|
SN=""
|
|
fi
|
|
|
|
CMD="curl --fail --connect-timeout 5 --silent http://scodoc.iutv.univ-paris13.fr/scodoc-installmgr/version?mode=$mode\&release=${SCODOC_RELEASE}\&sn=${SN}"
|
|
|
|
SVERSION="$(${CMD})"
|
|
if [ "$?" == 0 ]; then
|
|
#echo "answer=${SVERSION}"
|
|
echo "${SVERSION}" > "${SCODOC_VERSION_DIR}"/scodoc.sn
|
|
else
|
|
echo 'Warning: cannot connect to scodoc release server'
|
|
fi
|
|
|
|
# ------------ LIEN VERS .env
|
|
# Pour conserver le .env entre les mises à jour, on le génère dans
|
|
# /opt/scodoc-data/;env et on le lie:
|
|
if [ ! -e "$SCODOC_DIR/.env" ] && [ ! -L "$SCODOC_DIR/.env" ]
|
|
then
|
|
ln -s "$SCODOC_VAR_DIR/.env" "$SCODOC_DIR"
|
|
fi
|
|
|
|
# ------------ CREATION DU VIRTUALENV
|
|
# donc re-créé sur le client à chaque install ou upgrade
|
|
#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
|
|
if [ ! -L /etc/nginx/sites-enabled/scodoc9.nginx ]
|
|
then
|
|
ln -s /etc/nginx/sites-available/scodoc9.nginx /etc/nginx/sites-enabled/
|
|
fi
|
|
/bin/rm -f /etc/nginx/sites-enabled/default
|
|
|
|
# --- POSTGRESQL
|
|
# --- Ensure postgres user "scodoc" ($POSTGRES_USER) exists
|
|
init_postgres_user
|
|
|
|
# --- SYSTEMD: on a (peut-être) installé un fichier de service
|
|
systemctl daemon-reload
|