mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 03:13:12 +00:00
Support de postgresql par l'installateur
This commit is contained in:
parent
7c45194e6f
commit
0626089c73
2 changed files with 36 additions and 9 deletions
|
@ -34,7 +34,7 @@ Preconfiguration..."
|
||||||
|
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
apt-get -y install dialog
|
apt-get -y install sudo dialog
|
||||||
|
|
||||||
HEIGHT=15
|
HEIGHT=15
|
||||||
WIDTH=40
|
WIDTH=40
|
||||||
|
@ -124,11 +124,14 @@ sql_login="re2o"
|
||||||
sql_host="localhost"
|
sql_host="localhost"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sql_command="CREATE DATABASE $sql_name collate='utf8_general_ci';
|
mysql_command="CREATE DATABASE $sql_name collate='utf8_general_ci';
|
||||||
CREATE USER '$sql_login'@'localhost' IDENTIFIED BY '$sql_password';
|
CREATE USER '$sql_login'@'localhost' IDENTIFIED BY '$sql_password';
|
||||||
GRANT ALL PRIVILEGES ON $sql_name.* TO '$sql_login'@'localhost';
|
GRANT ALL PRIVILEGES ON $sql_name.* TO '$sql_login'@'localhost';
|
||||||
FLUSH PRIVILEGES;"
|
FLUSH PRIVILEGES;"
|
||||||
|
|
||||||
|
pgsql_command1="CREATE DATABASE $sql_name ENCODING 'UTF8' LC_COLLATE='fr_FR.UTF-8' LC_CTYPE='fr_FR.UTF-8';"
|
||||||
|
pgsql_command2="CREATE USER $sql_login with password '$sql_password';"
|
||||||
|
pgsql_command3="ALTER DATABASE $sql_name owner to $sql_login;"
|
||||||
|
|
||||||
TITLE="Emplacement du ldap"
|
TITLE="Emplacement du ldap"
|
||||||
OPTIONS=(1 "Local"
|
OPTIONS=(1 "Local"
|
||||||
|
@ -219,13 +222,14 @@ pip3 install django-macaddress
|
||||||
|
|
||||||
if [ $sql_bdd_type == 1 ]
|
if [ $sql_bdd_type == 1 ]
|
||||||
then
|
then
|
||||||
|
apt-get -y install python3-mysqldb mysql-client
|
||||||
if [ $sql_is_local == 1 ]
|
if [ $sql_is_local == 1 ]
|
||||||
then
|
then
|
||||||
apt-get -y install mysql-server
|
apt-get -y install mysql-server
|
||||||
mysql -u root --execute="$sql_command"
|
mysql -u root --execute="$mysql_command"
|
||||||
else
|
else
|
||||||
echo "Veuillez saisir la commande suivante sur le serveur sql distant, puis validez"
|
echo "Veuillez saisir la commande suivante sur le serveur sql distant, puis validez"
|
||||||
echo $sql_command
|
echo $mysql_command
|
||||||
while true; do
|
while true; do
|
||||||
read -p "Continue (y/n)?" choice
|
read -p "Continue (y/n)?" choice
|
||||||
case "$choice" in
|
case "$choice" in
|
||||||
|
@ -235,13 +239,29 @@ then
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
apt-get -y install python3-mysqldb mysql-client
|
else
|
||||||
else
|
apt-get -y install postgresql-client
|
||||||
|
apt-get -y install python3-psycopg2
|
||||||
if [ $sql_is_local == 1 ]
|
if [ $sql_is_local == 1 ]
|
||||||
then
|
then
|
||||||
apt-get -y install postgresql-server
|
apt-get -y install postgresql
|
||||||
|
sudo -u postgres psql --command="$pgsql_command1"
|
||||||
|
sudo -u postgres psql --command="$pgsql_command2"
|
||||||
|
sudo -u postgres psql --command="$pgsql_command3"
|
||||||
|
else
|
||||||
|
echo "Veuillez saisir la commande suivante sur le serveur sql distant, puis validez"
|
||||||
|
echo sudo -u postgres psql $pgsql_command1
|
||||||
|
echo sudo -u postgres psql $pgsql_command2
|
||||||
|
echo sudo -u postgres psql $pgsql_command3
|
||||||
|
while true; do
|
||||||
|
read -p "Continue (y/n)?" choice
|
||||||
|
case "$choice" in
|
||||||
|
y|Y ) break;;
|
||||||
|
n|N ) exit;;
|
||||||
|
* ) echo "invalid";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
apt-get -y install postgresql-client
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $ldap_is_local == 1 ]
|
if [ $ldap_is_local == 1 ]
|
||||||
|
@ -259,6 +279,12 @@ echo "Ecriture de settings_local"
|
||||||
django_secret_key=$(python -c "import random; print(''.join([random.SystemRandom().choice('abcdefghijklmnopqrstuvwxyz0123456789%=+') for i in range(50)]))")
|
django_secret_key=$(python -c "import random; print(''.join([random.SystemRandom().choice('abcdefghijklmnopqrstuvwxyz0123456789%=+') for i in range(50)]))")
|
||||||
|
|
||||||
cp re2o/settings_local.example.py re2o/settings_local.py
|
cp re2o/settings_local.example.py re2o/settings_local.py
|
||||||
|
if [ $sql_bdd_type == 1 ]
|
||||||
|
then
|
||||||
|
sed -i 's/db_engine/django.db.backends.mysql/g' re2o/settings_local.py
|
||||||
|
else
|
||||||
|
sed -i 's/db_engine/django.db.backends.postgresql_psycopg2/g' re2o/settings_local.py
|
||||||
|
fi
|
||||||
sed -i 's/SUPER_SECRET_KEY/'"$django_secret_key"'/g' re2o/settings_local.py
|
sed -i 's/SUPER_SECRET_KEY/'"$django_secret_key"'/g' re2o/settings_local.py
|
||||||
sed -i 's/SUPER_SECRET_DB/'"$sql_password"'/g' re2o/settings_local.py
|
sed -i 's/SUPER_SECRET_DB/'"$sql_password"'/g' re2o/settings_local.py
|
||||||
sed -i 's/db_name_value/'"$sql_name"'/g' re2o/settings_local.py
|
sed -i 's/db_name_value/'"$sql_name"'/g' re2o/settings_local.py
|
||||||
|
@ -321,6 +347,7 @@ if [ $web_serveur == 1 ]
|
||||||
then
|
then
|
||||||
apt-get -y install apache2 libapache2-mod-wsgi-py3
|
apt-get -y install apache2 libapache2-mod-wsgi-py3
|
||||||
a2enmod ssl
|
a2enmod ssl
|
||||||
|
a2enmod wsgi
|
||||||
if [ $is_tls == 1 ]
|
if [ $is_tls == 1 ]
|
||||||
then
|
then
|
||||||
cp install_utils/apache2/re2o-tls.conf /etc/apache2/sites-available/re2o.conf
|
cp install_utils/apache2/re2o-tls.conf /etc/apache2/sites-available/re2o.conf
|
||||||
|
|
|
@ -36,7 +36,7 @@ ALLOWED_HOSTS = ['URL_SERVER']
|
||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.mysql',
|
'ENGINE': 'db_engine',
|
||||||
'NAME': 'db_name_value',
|
'NAME': 'db_name_value',
|
||||||
'USER': 'db_user_value',
|
'USER': 'db_user_value',
|
||||||
'PASSWORD': DB_PASSWORD,
|
'PASSWORD': DB_PASSWORD,
|
||||||
|
|
Loading…
Reference in a new issue