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
|
# ------------ CREATION ENVIRONNEMENT
|
||||||
echo
|
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 " définissant les variables d\'environnement ?"
|
||||||
echo "(si vous ne savez pas, répondez oui !)"
|
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
|
read -r ans
|
||||||
if [ "$(norm_ans "$ans")" != 'N' ]
|
if [ "$(norm_ans "$ans")" != 'N' ]
|
||||||
then
|
then
|
||||||
echo -n "Adresse mail de l\'administrateur du site: "
|
echo -n "Adresse mail de l\'administrateur du site: "
|
||||||
read SCODOC_ADMIN_MAIL
|
read SCODOC_ADMIN_MAIL
|
||||||
SECRET_KEY=$(python3 -c "import uuid; print(uuid.uuid4().hex)")
|
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)
|
# .env for ScoDoc (production)
|
||||||
FLASK_APP=scodoc.py
|
FLASK_APP=scodoc.py
|
||||||
FLASK_ENV=production
|
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"
|
SECRET_KEY="$SECRET_KEY" # une chaine aléatoire"
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
echo "Fichier /opt/scodoc/.env créé avec:"
|
echo "Fichier /opt/scodoc-data/.env créé avec:"
|
||||||
cat /opt/scodoc/.env
|
cat /opt/scodoc-data/.env
|
||||||
echo
|
echo
|
||||||
echo "Vous pouvez le modifier si besoin."
|
echo "Vous pouvez le modifier si besoin."
|
||||||
echo
|
echo
|
||||||
|
@ -28,15 +28,45 @@ then
|
|||||||
/usr/sbin/locale-gen --keep-existing
|
/usr/sbin/locale-gen --keep-existing
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SCODOC_RELEASE=$(grep SCOVERSION sco_version.py | awk '{ print substr($3, 2, length($3)-2) }')
|
# Le numero de version complet, genre 9.0.0
|
||||||
SVERSION=$(curl --silent http://scodoc.iutv.univ-paris13.fr/scodoc-installmgr/version?mode=install\&release="$SCODOC_RELEASE")
|
SCODOC_RELEASE=$(grep SCOVERSION $SCODOC_DIR/sco_version.py | awk '{ print substr($3, 2, length($3)-2) }')
|
||||||
echo "$SVERSION" > "${SCODOC_VERSION_DIR}/scodoc.sn"
|
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 ?
|
CMD="curl --fail --connect-timeout 5 --silent http://scodoc.iutv.univ-paris13.fr/scodoc-installmgr/version?mode=$mode\&release=${SCODOC_RELEASE}\&sn=${SN}"
|
||||||
# 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)"
|
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
|
# ------------ CREATION DU VIRTUALENV
|
||||||
|
# donc re-créé sur le client à chaque install ou upgrade
|
||||||
#echo "Creating python3 virtualenv..."
|
#echo "Creating python3 virtualenv..."
|
||||||
(cd $SCODOC_DIR && python3 -m venv venv) || die "Error creating Python 3 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"
|
(cd $SCODOC_DIR && source venv/bin/activate && pip install wheel && pip install -r requirements-3.9.txt) || die "Error installing python packages"
|
||||||
|
|
||||||
# --- NGINX
|
# --- 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
|
/bin/rm -f /etc/nginx/sites-enabled/default
|
||||||
|
|
||||||
# --- POSTGRESQL
|
# --- POSTGRESQL
|
||||||
# --- Ensure postgres user "scodoc" ($POSTGRES_USER) exists
|
# --- Ensure postgres user "scodoc" ($POSTGRES_USER) exists
|
||||||
init_postgres_user
|
init_postgres_user
|
||||||
|
|
||||||
# --- SYSTEMD: on a installé un fichier de service
|
# --- SYSTEMD: on a (peut-être) installé un fichier de service
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
|
Loading…
Reference in New Issue
Block a user