From 3c943b21b2bc39a25355ff713ca86812044cbcb2 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Fri, 23 Jul 2021 10:32:20 +0300 Subject: [PATCH] install script for ScoDoc8 development --- requirements-3.7.txt | 93 +++++++++++++---------------------- tools/config.sh | 7 ++- tools/install_debian10.sh | 79 ++++++++++------------------- tools/migrate_from_scodoc7.sh | 26 +++------- tools/utils.sh | 16 ++++++ 5 files changed, 87 insertions(+), 134 deletions(-) diff --git a/requirements-3.7.txt b/requirements-3.7.txt index 60d8cd144..ccaf72da7 100644 --- a/requirements-3.7.txt +++ b/requirements-3.7.txt @@ -1,61 +1,34 @@ -alembic==1.6.5 -astroid==2.6.2 -Babel==2.9.1 -blinker==1.4 -certifi==2021.5.30 -chardet==4.0.0 -click==8.0.1 -cracklib==2.9.3 -dnspython==2.1.0 -dominate==2.6.0 -email-validator==1.1.3 -Flask==2.0.1 -Flask-Babel==2.0.0 -Flask-Bootstrap==3.3.7.1 -Flask-Caching==1.10.1 -Flask-Login==0.5.0 -Flask-Mail==0.9.1 -Flask-Migrate==3.0.1 -Flask-Moment==1.0.1 -Flask-SQLAlchemy==2.5.1 -Flask-WTF==0.15.1 -greenlet==1.1.0 -html2text==2020.1.16 -icalendar==4.0.7 -idna==2.10 -importlib-metadata==4.6.1 -isort==5.9.2 -itsdangerous==2.0.1 -Jinja2==3.0.1 -lazy-object-proxy==1.6.0 -Mako==1.1.4 -MarkupSafe==2.0.1 -mccabe==0.6.1 -Pillow==8.3.1 -pkg-resources==0.0.0 -psycopg2==2.9.1 -pydot==1.4.2 -PyJWT==2.1.0 -pylibmc==1.6.1 -pylint==2.9.3 -pylint-flask-sqlalchemy==0.2.0 -pymemcache==3.5.0 -pyparsing==2.4.7 +asn1crypto==0.24.0 +certifi==2018.8.24 +chardet==3.0.4 +configparser==3.5.0b2 +cracklib==2.9.6 +cryptography==2.6.1 +docutils==0.14 +entrypoints==0.3 +enum34==1.1.6 +gyp==0.1 +icalendar==4.0.3 +idna==2.6 +ipaddress==1.0.17 +jaxml==3.1 +keyring==17.1.1 +keyrings.alt==3.1.1 +olefile==0.46 +Pillow==5.4.1 +psycopg2==2.7.7 +pycrypto==2.6.1 +Pygments==2.3.1 +PyGObject==3.30.4 +pyOpenSSL==19.0.0 PyRSS2Gen==1.1 -python-dateutil==2.8.1 -python-dotenv==0.18.0 -python-editor==1.0.4 -pytz==2021.1 -reportlab==3.5.68 -requests==2.25.1 -six==1.16.0 -SQLAlchemy==1.4.20 -toml==0.10.2 -typed-ast==1.4.3 -typing-extensions==3.10.0.0 -urllib3==1.26.6 -visitor==0.1.3 -Werkzeug==2.0.1 -wrapt==1.12.1 -WTForms==2.3.3 -zipp==3.5.0 +python-dateutil==2.7.3 +pytz==2019.1 +pyxdg==0.25 +reportlab==3.5.13 +requests==2.21.0 +roman==2.0.0 +SecretStorage==2.3.1 +six==1.12.0 +urllib3==1.24.1 +virtualenv==15.1.0 diff --git a/tools/config.sh b/tools/config.sh index c17c6c7e6..3e91d757e 100644 --- a/tools/config.sh +++ b/tools/config.sh @@ -44,7 +44,12 @@ else fi export PSQL -# tcp port for SQL server (under Debian 4, 5432 or 5433 for 8.1 if 7.4 also installed !) +# tcp port for SQL server # Important note: if changed, you should probably also change it in # sco_utils.py (SCO_DEFAULT_SQL_PORT). export POSTGRES_PORT=5432 + +# --- +echo "SCODOC_USER=$SCODOC_USER" +echo "SCODOC_DIR=$SCODOC_DIR" +echo "SCODOC_VAR_DIR=$SCODOC_VAR_DIR" diff --git a/tools/install_debian10.sh b/tools/install_debian10.sh index 1e9e7c4b8..d05352ede 100755 --- a/tools/install_debian10.sh +++ b/tools/install_debian10.sh @@ -1,11 +1,11 @@ #!/bin/bash # -# ScoDoc: install third-party software necessary for our installation +# ScoDoc 8: install third-party software necessary for our installation # starting for a minimal Debian (Buster, 10.0) install. # # E. Viennet, Jun 2008, Apr 2009, Sept 2011, Sept 2013, Nov 2013, Mar 2017, Jul 2017, -# Jun 2019, Oct 2019, Dec 2020 +# Jun 2019, Oct 2019, Dec 2020, Jul 2021 # source config.sh @@ -27,65 +27,27 @@ then fi # ------------ Permissions & directories -chown -R "$SCODOC_USER"."$SCODOC_GROUP" "${SCODOC_DIR}" +change_scodoc_file_ownership - -# ------------ LOCALES -echo -echo '---- Configuration des locales...' -echo - -if [ ! -e /etc/locale.gen ] -then - touch /etc/locale.gen -fi - - -for locname in en_US.UTF-8 en_US.ISO-8859-15 en_US.ISO-8859-1 -do - 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 - fi -done - -/usr/sbin/locale-gen --keep-existing - -# Voir si encore nécessaire avec ScoDoc8: ? -if [ "$LANG" != "en_US.UTF-8" ] -then - # ceci est necessaire a cause de postgresql 8.3 qui - # cree son cluster lors de l'install avec la locale par defaut ! - echo "Attention: changement de la locale par defaut" - mv /etc/default/locale /etc/default/locale.orig - echo "LANG=\"en_US.UTF-8\"" > /etc/default/locale - export LANG=en_US.UTF-8 -fi -echo 'Done.' - -# ------------ AJOUT DES PAQUETS NECESSAIRES +# ------------ AJOUT DES PAQUETS DEBIAN NECESSAIRES apt-get update -apt-get -y install subversion curl cracklib-runtime -apt-get -y install apache2 ssl-cert +apt-get -y install python3-dev +apt-get -y install python3-venv +apt-get -y install libpq-dev +apt-get -y install libcrack2-dev apt-get -y install postgresql +apt-get -y install curl apt-get -y install graphviz -# ------------ INSTALL DES EXTENSIONS PYTHON (2.7) +# ------------ INSTALL DES PAQUETS PYTHON (3.7) # ScoDoc8 uses pip in our env -apt-get -y install python-docutils -apt-get -y install python-psycopg2 -apt-get -y install python-pyrss2gen -apt-get -y install python-pil python-reportlab -apt-get -y install python-cracklib # was python-crack -apt-get -y install python-icalendar -apt-get -y install python-requests - +source venv/bin/activate +pip install wheel +pip install -r requirements-3.7.txt # ------------ -SVNVERSION=$(cd ..; svnversion) -SVERSION=$(curl --silent http://scodoc.iutv.univ-paris13.fr/scodoc-installmgr/version?mode=install\&svn="$SVNVERSION") +GITCOMMIT=$(git rev-parse HEAD) +SVERSION=$(curl --silent http://scodoc.iutv.univ-paris13.fr/scodoc-installmgr/version?mode=install\&commit="$GITCOMMIT") echo "$SVERSION" > "${SCODOC_VERSION_DIR}/scodoc.sn" @@ -116,10 +78,19 @@ then yes | ufw enable fi +# --- XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX --- +echo +echo "WARNING: version ScoDoc8 expérimentale" +echo "Ne pas utiliser en production !" +echo +echo "Pour lancer le serveur de développement: voir README" +exit 0 +# --- XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX --- + # Nota: after this point, the network _may_ be unreachable # (if firewall config is wrong) -# ------------ CONFIG APACHE +# ------------ CONFIG NGINX a2enmod ssl a2enmod proxy a2enmod proxy_http diff --git a/tools/migrate_from_scodoc7.sh b/tools/migrate_from_scodoc7.sh index 655614dfa..b8d9be8be 100755 --- a/tools/migrate_from_scodoc7.sh +++ b/tools/migrate_from_scodoc7.sh @@ -29,25 +29,10 @@ check_uid_root SCODOC7_HOME="/opt/scodoc" SCODOC7_DIR="${SCODOC7_HOME}/Products/ScoDoc" -# --- 1. Utilisateur UNIX -migrate_unix_user() { - if [ $(id -u "${SCODOC_USER}" &> /dev/null) ] - then - echo "Unix user ${SCODOC_USER} exists" - else - echo "Creating unix user ${SCODOC_USER}" - adduser --no-create-home --shell /bin/bash --gecos "ScoDoc service" ${SCODOC_USER} || die "failed to create user" - fi -} - -migrate_file_ownership() { - echo "Changing owner of $SCODOC_DIR to ${SCODOC_USER}" - chown -R "${SCODOC_USER}:${SCODOC_GROUP}" "$SCODOC_DIR" -} # --- 2. Propriétaire des bases de données # Bases appartenant à www-data: -migrate_databse_ownsership() { +migrate_database_ownership() { SCO7_BASES=$(su -c "psql -l -t | grep www-data" "$POSTGRES_SUPERUSER" | awk -F '|' '{print $1}') for base in $SCO7_BASES do @@ -74,22 +59,25 @@ migrate_local_files() { # ------ MAIN -migrate_unix_user +check_create_scodoc_user +echo echo -n "Changer si nécessaire le propriétaire des fichiers de $SCODOC_DIR ? (y/n) [y] " read -r ans if [ "$(norm_ans "$ans")" != 'N' ] then - migrate_file_ownership + change_scodoc_file_ownership fi +echo echo -n "Changer si nécessaire le propriétaire des bases de données SQL ? (y/n) [y] " read -r ans if [ "$(norm_ans "$ans")" != 'N' ] then - migrate_databse_ownsership + migrate_database_ownership fi +echo echo "Les fichiers locaux de ScoDoc (configuration, photos, procès-verbaux...)" echo "sont maintenant stockées dans $SCODOC_VAR_DIR" echo -n "Copier les fichiers locaux de ScoDoc7 ? (y/n) [y] " diff --git a/tools/utils.sh b/tools/utils.sh index b192db7a6..a13e51953 100644 --- a/tools/utils.sh +++ b/tools/utils.sh @@ -59,6 +59,22 @@ init_postgres_user() { # run as root fi } +# --- Ensure Unix user "scodoc" exists +check_create_scodoc_user() { + if [ $(id -u "${SCODOC_USER}" &> /dev/null) ] + then + echo "Creating unix user ${SCODOC_USER}" + adduser --no-create-home --shell /bin/bash --gecos "ScoDoc service" ${SCODOC_USER} || die "failed to create user" + else + echo "Unix user ${SCODOC_USER} exists" + fi +} + +# --- 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" +} # XXX inutilise gen_passwd() {