Peaufine script config

This commit is contained in:
Emmanuel Viennet 2021-08-25 18:15:03 +02:00
parent 98f7fd165b
commit a6e9be59b8
2 changed files with 41 additions and 4 deletions

View File

@ -15,7 +15,9 @@ from flask import g, current_app
""" """
LOG_FILENAME = "notes.log" # empty to disable logging LOG_FILENAME = "notes.log" # empty to disable logging
DEFAULT_LOG_DIR = "/tmp" # clients should call set_log_directory to change this DEFAULT_LOG_DIR = (
"/opt/scodoc-data/log" # clients should call set_log_directory to change this
)
ALARM_DESTINATION = "emmanuel.viennet@gmail.com" # XXX a mettre en preference ALARM_DESTINATION = "emmanuel.viennet@gmail.com" # XXX a mettre en preference

41
tools/configure-scodoc9.sh Normal file → Executable file
View File

@ -14,6 +14,26 @@ source "$SCRIPT_DIR/utils.sh"
cd /opt/scodoc || die "Error: chdir to /opt/scodoc" cd /opt/scodoc || die "Error: chdir to /opt/scodoc"
# ------------ VERIF SYSTEME
if [ -e /etc/debian_version ]
then
debian_version=$(cat /etc/debian_version)
debian_version=${debian_version%%.*}
echo "Detected Debian version: ${debian_version}"
if [ "$debian_version" != "11" ]
then
echo "Erreur: version Linux Debian incompatible"
echo "Utiliser un système Debian Bullseye (11)"
echo
exit 1
fi
else
echo "can't detect Debian version"
exit 1
fi
echo "--- Configuration de ScoDoc pour Debian 11"
# ------------ CONFIG FIREWALL OPTIONNELLE # ------------ CONFIG FIREWALL OPTIONNELLE
echo echo
echo "Le firewall aide a proteger votre serveur d'intrusions indesirables." echo "Le firewall aide a proteger votre serveur d'intrusions indesirables."
@ -26,9 +46,12 @@ then
ufw default deny incoming ufw default deny incoming
ufw default allow outgoing ufw default allow outgoing
ufw allow ssh ufw allow ssh
ufw allow http
ufw allow https ufw allow https
yes | ufw enable yes | ufw enable
echo
echo "firewall ufw activé." echo "firewall ufw activé."
echo
fi fi
# ------------ CONFIG NGINX # ------------ CONFIG NGINX
@ -45,7 +68,6 @@ if [ "$(norm_ans "$ans")" != 'N' ]
then then
# génération des certifs: cert.pem key.pem dans /opt/scodoc-data/certs/ # génération des certifs: cert.pem key.pem dans /opt/scodoc-data/certs/
su -c "(cd $SCODOC_VAR_DIR && mkdir -p certs && openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -keyout certs/key.pem -out certs/cert.pem)" "$SCODOC_USER" su -c "(cd $SCODOC_VAR_DIR && mkdir -p certs && openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -keyout certs/key.pem -out certs/cert.pem)" "$SCODOC_USER"
systemctl restart nginx
fi fi
# ------------ CREATION ENVIRONNEMENT # ------------ CREATION ENVIRONNEMENT
@ -79,6 +101,12 @@ EOF
echo echo
fi fi
# ------------ VERIFICATIONS DES REPERTOIRES ET DROITS
# déjà fait par le postinst, mais certaines fausses manips de nos utilisateurs
# ont pu changer ça:
set_scodoc_var_dir
change_scodoc_file_ownership
# ------------ CREATION BASE DE DONNEES # ------------ CREATION BASE DE DONNEES
echo echo
echo "Voulez-vous créer la base SQL SCODOC ?" echo "Voulez-vous créer la base SQL SCODOC ?"
@ -89,12 +117,19 @@ read -r ans
if [ "$(norm_ans "$ans")" != 'N' ] if [ "$(norm_ans "$ans")" != 'N' ]
then then
# on ne créée pas les bases TEST et DEV # on ne créée pas les bases TEST et DEV
su -c "/opt/scodoc/tools/create_database.sh SCODOC" || die "Erreur: create_database.sh SCODOC" su -c "/opt/scodoc/tools/create_database.sh SCODOC" "$SCODOC_USER" || die "Erreur: create_database.sh SCODOC"
echo "base SCODOC créée." echo "base SCODOC créée."
# ------------ INITIALISATION BASE DE DONNEES # ------------ INITIALISATION BASE DE DONNEES
su -c "(cd /opt/scodoc; source venv/bin/activate; flask db-init; flask user-password admin)" || die "Erreur: db-init" echo
echo "Création des tables et du compte admin"
echo
su -c "(cd /opt/scodoc; source venv/bin/activate; flask db-init; flask user-password admin)" "$SCODOC_USER" || die "Erreur: db-init"
echo
echo "base initialisée et admin créé."
echo
fi fi
# ------------ LANCEMENT DES SERVICES
systemctl start redis systemctl start redis
systemctl start scodoc9 systemctl start scodoc9