forked from ScoDoc/ScoDoc
modif pour apt-get upgrade
This commit is contained in:
parent
a6e9be59b8
commit
f363e8b926
@ -72,17 +72,17 @@ fi
|
||||
|
||||
# ------------ CREATION ENVIRONNEMENT
|
||||
echo
|
||||
echo "Créer (et écraser) le fichier /opt/scodoc/.env"
|
||||
echo "Créer (et écraser) le fichier /opt/scodoc-data/.env"
|
||||
echo " définissant les variables d\'environnement ?"
|
||||
echo "(si vous ne savez pas, répondez oui !)"
|
||||
echo -n 'Générer /opt/scodoc/.env ? (y/n) [y] '
|
||||
echo -n 'Générer /opt/scodoc-data/.env ? (y/n) [y] '
|
||||
read -r ans
|
||||
if [ "$(norm_ans "$ans")" != 'N' ]
|
||||
then
|
||||
echo -n "Adresse mail de l\'administrateur du site: "
|
||||
read SCODOC_ADMIN_MAIL
|
||||
SECRET_KEY=$(python3 -c "import uuid; print(uuid.uuid4().hex)")
|
||||
cat > /opt/scodoc/.env <<EOF
|
||||
cat > /opt/scodoc-data/.env <<EOF
|
||||
# .env for ScoDoc (production)
|
||||
FLASK_APP=scodoc.py
|
||||
FLASK_ENV=production
|
||||
@ -94,8 +94,8 @@ SCODOC_ADMIN_MAIL="$SCODOC_ADMIN_MAIL" # important: le mail de admin
|
||||
SECRET_KEY="$SECRET_KEY" # une chaine aléatoire"
|
||||
|
||||
EOF
|
||||
echo "Fichier /opt/scodoc/.env créé avec:"
|
||||
cat /opt/scodoc/.env
|
||||
echo "Fichier /opt/scodoc-data/.env créé avec:"
|
||||
cat /opt/scodoc-data/.env
|
||||
echo
|
||||
echo "Vous pouvez le modifier si besoin."
|
||||
echo
|
||||
|
@ -28,15 +28,45 @@ then
|
||||
/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"
|
||||
# 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
|
||||
|
||||
# --- 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)"
|
||||
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"
|
||||
|
||||
@ -45,12 +75,15 @@ echo "$SVERSION" > "${SCODOC_VERSION_DIR}/scodoc.sn"
|
||||
(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/
|
||||
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 installé un fichier de service
|
||||
# --- SYSTEMD: on a (peut-être) installé un fichier de service
|
||||
systemctl daemon-reload
|
||||
|
Loading…
Reference in New Issue
Block a user