pgsql_command2="CREATE USER $sql_login with password '$sql_password';"
pgsql_command3="ALTER DATABASE $sql_name owner to $sql_login;"
if[$sql_is_local==1]
then
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"
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
echo"Please execute the following commands on the remote SQL server and then continue"
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
echo"LDAP setup"
if[$ldap_is_local==1]
then
setup_ldap $ldap_password$ldap_dn
else
TITLE="LDAP server setup"
MSGBOX="Please manually setup the remote LDAP server by launching the following commands: ./install_re2o.sh ldap $ldap_password$ldap_dn"
ldap_setup=$(dialog --clear \
--title "$TITLE"\
--msgbox "$MSGBOX"\
$HEIGHT$WIDTH\
2>&1 >/dev/tty)
fi
setup_ldap $ldap_password$ldap_dn
else
HEIGHT=15
WIDTH=40
ldap_setup=$(dialog --clear \
--title "Setup ldap"\
--msgbox "Vous devrez manuellement effectuer les opérations de setup de la base ldap sur le serveurs distant. Lancez la commande : ./install_re2o.sh ldap $ldap_password$ldap_dn"\
$HEIGHT$WIDTH\
2>&1 >/dev/tty)
fi
echo"Ecriture de settings_local"
echo"Writing of the settings_local.py file"
django_secret_key=$(python -c "import random; print(''.join([random.SystemRandom().choice('abcdefghijklmnopqrstuvwxyz0123456789%=+') for i in range(50)]))")
aes_key=$(python -c "import random; print(''.join([random.SystemRandom().choice('abcdefghijklmnopqrstuvwxyz0123456789%=+') for i in range(32)]))")
@ -316,12 +331,16 @@ 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/THE_AES_KEY/'"$aes_key"'/g' re2o/settings_local.py
sed -i 's/SUPER_SECRET_DB/'"$sql_password"'/g' re2o/settings_local.py
sed -i 's/A_SECRET_AES_KEY/'"$aes_key"'/g' re2o/settings_local.py
sed -i 's/db_name_value/'"$sql_name"'/g' re2o/settings_local.py
sed -i 's/db_user_value/'"$sql_login"'/g' re2o/settings_local.py
sed -i 's/db_host_value/'"$sql_host"'/g' re2o/settings_local.py
sed -i 's/ldap_dn/'"$ldap_cn"'/g' re2o/settings_local.py
if[$ldap_tls==2]
then
sed -i "s/'TLS': True,/# 'TLS': True,#/g" re2o/settings_local.py
fi
sed -i 's/SUPER_SECRET_LDAP/'"$ldap_password"'/g' re2o/settings_local.py
sed -i 's/ldap_host_ip/'"$ldap_host"'/g' re2o/settings_local.py
sed -i 's/dc=example,dc=org/'"$ldap_dn"'/g' re2o/settings_local.py
@ -329,26 +348,39 @@ sed -i 's/example.org/'"$extension_locale"'/g' re2o/settings_local.py
sed -i 's/MY_EMAIL_HOST/'"$email_host"'/g' re2o/settings_local.py
sed -i 's/MY_EMAIL_PORT/'"$email_port"'/g' re2o/settings_local.py
sed -i 's|URL_SERVER|'"$url_server"'|g' /etc/apache2/sites-available/re2o.conf
current_path=$(pwd)
sed -i 's|PATH|'"$current_path"'|g' /etc/apache2/sites-available/re2o.conf
a2ensite re2o
service apache2 reload
else
HEIGHT=15
WIDTH=40
web_server=$(dialog --clear \
--title "Setup serveur web"\
--msgbox "Nginx non supporté, vous devrez installer manuellement"\
$HEIGHT$WIDTH\
2>&1 >/dev/tty)
TITLE="Web server setup"
MSGBOX="Nginx non supporté, vous devrez installer manuellement"
web_server=$(dialog --clear \
--title "$TITLE"\
--msgbox "$MSGBOX"\
$HEIGHT$WIDTH\
2>&1 >/dev/tty)
fi
python3 manage.py createsuperuser
HEIGHT=15
WIDTH=40
TITLE="End of the setup"
MSGBOX="You can now visit $url_server and connect with the credentials you just entered. This user hhas the superuser rights, meaning he can access and do everything."
end=$(dialog --clear \
--title "Installation terminée"\
--title "$TITLE"\
--msgbox "Vous pouvez à présent vous rendre sur $url_server, et vous connecter. Votre utilisateur dispose des privilèges superuser"\