8
0
Fork 0
mirror of https://gitlab.federez.net/re2o/re2o synced 2024-07-08 15:14:04 +00:00

Fix #122 + translation in install_re2o.sh

This commit is contained in:
Maël Kervella 2018-05-15 20:09:08 +00:00
parent c4997be31f
commit 54e378394f

View file

@ -3,24 +3,24 @@
setup_ldap() { setup_ldap() {
apt-get -y install slapd apt-get -y install slapd
echo "Hashage du mot de passe ldap..." echo "Hashing the LDAP password..."
hashed_ldap_passwd=$(slappasswd -s $1) hashed_ldap_passwd=$(slappasswd -s $1)
echo $hashed_ldap_passwd echo $hashed_ldap_passwd
echo "Formatage des fichiers de config ldap" echo "Building the LDAP config files"
sed 's|dc=example,dc=org|'"$2"'|g' install_utils/db.ldiff | sed 's|FILL_IT|'"$hashed_ldap_passwd"'|g' > /tmp/db sed 's|dc=example,dc=org|'"$2"'|g' install_utils/db.ldiff | sed 's|FILL_IT|'"$hashed_ldap_passwd"'|g' > /tmp/db
sed 's|dc=example,dc=org|'"$2"'|g' install_utils/schema.ldiff | sed 's|FILL_IT|'"$hashed_ldap_passwd"'|g' > /tmp/schema sed 's|dc=example,dc=org|'"$2"'|g' install_utils/schema.ldiff | sed 's|FILL_IT|'"$hashed_ldap_passwd"'|g' > /tmp/schema
echo "Destruction config ldap existante" echo "Deleting exisitng LDAP configuration"
service slapd stop service slapd stop
rm -rf /etc/ldap/slapd.d/* rm -rf /etc/ldap/slapd.d/*
rm -rf /var/lib/ldap/* rm -rf /var/lib/ldap/*
echo "Ecriture de la configuration actuelle" echo "Setting up the new LDAP configuration"
slapadd -n 0 -l /tmp/schema -F /etc/ldap/slapd.d/ slapadd -n 0 -l /tmp/schema -F /etc/ldap/slapd.d/
slapadd -n 1 -l /tmp/db slapadd -n 1 -l /tmp/db
echo "Reparation des permissions et redémarage de slapd" echo "Fixing the LDAP files permissions and restarting slapd"
chown -R openldap:openldap /etc/ldap/slapd.d chown -R openldap:openldap /etc/ldap/slapd.d
chown -R openldap:openldap /var/lib/ldap chown -R openldap:openldap /var/lib/ldap
service slapd start service slapd start
@ -28,33 +28,37 @@ setup_ldap() {
install_re2o_server() { install_re2o_server() {
echo "Installation de Re2o ! echo "Re2o setup !
Cet utilitaire va procéder à l'installation initiale de re2o. Le serveur présent doit être vierge. This tool will help you setup re2o. It is highly recommended to use a Debian clean server for this operation.
Preconfiguration..." Installing sudo and dialog packages..."
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
apt-get -y install sudo dialog apt-get -y install sudo dialog
HEIGHT=15
WIDTH=40
init=$(dialog --clear \
--title "Installation de Re2o !" \
--msgbox "Cet utilitaire va procéder à l'installation initiale de re2o. Le serveur présent doit être vierge de préférence. Preconfiguration..." \
$HEIGHT $WIDTH \
2>&1 >/dev/tty)
HEIGHT=15 HEIGHT=15
WIDTH=40 WIDTH=40
CHOICE_HEIGHT=4 CHOICE_HEIGHT=4
BACKTITLE="Preconfiguration re2o"
MENU="Choisir une option"
TITLE="Choix du moteur bdd" TITLE="Re2o setup !"
MSGBOX="This tool will help you setup re2o. It is highly recommended to use a Debian clean server for this operation."
init=$(dialog --clear \
--title "$TITLE" \
--msgbox "$MSGBOX" \
$HEIGHT $WIDTH \
2>&1 >/dev/tty)
BACKTITLE="Re2o preconfiguration of the database"
MENU="Choose an option"
TITLE="Database engine"
OPTIONS=(1 "mysql" OPTIONS=(1 "mysql"
2 "postgresql") 2 "postgresql")
sql_bdd_type=$(dialog --clear \ sql_bdd_type=$(dialog --clear \
--backtitle "$BACKTITLE" \ --backtitle "$BACKTITLE" \
--title "$TITLE" \ --title "$TITLE" \
@ -66,12 +70,16 @@ sql_bdd_type=$(dialog --clear \
clear clear
TITLE="Extension locale (ex : example.org)"
TITLE="Local extension to use (ex : example.net)"
extension_locale=$(dialog --title "$TITLE" \ extension_locale=$(dialog --title "$TITLE" \
--backtitle "$BACKTITLE" \ --backtitle "$BACKTITLE" \
--inputbox "$TITLE" $HEIGHT $WIDTH \ --inputbox "$TITLE" \
2>&1 >/dev/tty) $HEIGHT $WIDTH \
2>&1 >/dev/tty)
clear clear
IFS='.' read -a extension_locale_array <<< $extension_locale IFS='.' read -a extension_locale_array <<< $extension_locale
@ -84,9 +92,13 @@ done
ldap_dn=${ldap_dn::-1} ldap_dn=${ldap_dn::-1}
echo $ldap_dn echo $ldap_dn
TITLE="Emplacement de la bdd"
TITLE="SQL database location"
OPTIONS=(1 "Local" OPTIONS=(1 "Local"
2 "Distant") 2 "Remote")
sql_is_local=$(dialog --clear \ sql_is_local=$(dialog --clear \
--backtitle "$BACKTITLE" \ --backtitle "$BACKTITLE" \
@ -98,7 +110,7 @@ sql_is_local=$(dialog --clear \
clear clear
TITLE="Mot de passe sql" TITLE="SQL database password"
sql_password=$(dialog --title "$TITLE" \ sql_password=$(dialog --title "$TITLE" \
--backtitle "$BACKTITLE" \ --backtitle "$BACKTITLE" \
@ -109,19 +121,19 @@ clear
if [ $sql_is_local == 2 ] if [ $sql_is_local == 2 ]
then then
TITLE="Login sql" TITLE="Username to access the remote SQL database"
sql_login=$(dialog --title "$TITLE" \ sql_login=$(dialog --title "$TITLE" \
--backtitle "$BACKTITLE" \ --backtitle "$BACKTITLE" \
--inputbox "$TITLE" $HEIGHT $WIDTH \ --inputbox "$TITLE" $HEIGHT $WIDTH \
2>&1 >/dev/tty) 2>&1 >/dev/tty)
clear clear
TITLE="Nom de la bdd sql" TITLE="Name of the SQL database"
sql_name=$(dialog --title "$TITLE" \ sql_name=$(dialog --title "$TITLE" \
--backtitle "$BACKTITLE" \ --backtitle "$BACKTITLE" \
--inputbox "$TITLE" $HEIGHT $WIDTH \ --inputbox "$TITLE" $HEIGHT $WIDTH \
2>&1 >/dev/tty) 2>&1 >/dev/tty)
clear clear
TITLE="Hote de la base de donnée" TITLE="Host of the remote SQL database"
sql_host=$(dialog --title "$TITLE" \ sql_host=$(dialog --title "$TITLE" \
--backtitle "$BACKTITLE" \ --backtitle "$BACKTITLE" \
--inputbox "$TITLE" $HEIGHT $WIDTH \ --inputbox "$TITLE" $HEIGHT $WIDTH \
@ -133,18 +145,15 @@ sql_login="re2o"
sql_host="localhost" sql_host="localhost"
fi fi
mysql_command="CREATE DATABASE $sql_name collate='utf8_general_ci';
CREATE USER '$sql_login'@'localhost' IDENTIFIED BY '$sql_password';
GRANT ALL PRIVILEGES ON $sql_name.* TO '$sql_login'@'localhost';
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"
BACKTITLE="Re2o preconfiguration of the active directory"
TITLE="LDAP location"
OPTIONS=(1 "Local" OPTIONS=(1 "Local"
2 "Distant") 2 "Remote")
ldap_is_local=$(dialog --clear \ ldap_is_local=$(dialog --clear \
--backtitle "$BACKTITLE" \ --backtitle "$BACKTITLE" \
@ -154,16 +163,7 @@ ldap_is_local=$(dialog --clear \
"${OPTIONS[@]}" \ "${OPTIONS[@]}" \
2>&1 >/dev/tty) 2>&1 >/dev/tty)
TITLE="LDAP password"
HEIGHT=15
WIDTH=40
instal_ldap=$(dialog --clear \
--title "Installation de Re2o !" \
--msgbox "Vous devrez fournir un login/host dans le cas où le ldap est non local" \
$HEIGHT $WIDTH \
2>&1 >/dev/tty)
TITLE="Mot de passe ldap"
ldap_password=$(dialog --title "$TITLE" \ ldap_password=$(dialog --title "$TITLE" \
--backtitle "$BACKTITLE" \ --backtitle "$BACKTITLE" \
--inputbox "$TITLE" $HEIGHT $WIDTH \ --inputbox "$TITLE" $HEIGHT $WIDTH \
@ -171,35 +171,51 @@ ldap_password=$(dialog --title "$TITLE" \
clear clear
if [ $ldap_is_local == 2 ] if [ $ldap_is_local == 2 ]
then then
TITLE="Cn ldap admin" TITLE="CN entry for the admin user of the remote LDAP"
ldap_cn=$(dialog --title "$TITLE" \ ldap_cn=$(dialog --title "$TITLE" \
--backtitle "$BACKTITLE" \ --backtitle "$BACKTITLE" \
--inputbox "$TITLE" $HEIGHT $WIDTH \ --inputbox "$TITLE" $HEIGHT $WIDTH \
2>&1 >/dev/tty) 2>&1 >/dev/tty)
clear clear
TITLE="Hote ldap" TITLE="Host of the remote LDAP"
ldap_host=$(dialog --title "$TITLE" \ ldap_host=$(dialog --title "$TITLE" \
--backtitle "$BACKTITLE" \ --backtitle "$BACKTITLE" \
--inputbox "$TITLE" $HEIGHT $WIDTH \ --inputbox "$TITLE" $HEIGHT $WIDTH \
2>&1 >/dev/tty) 2>&1 >/dev/tty)
clear clear
TITLE="Is the TLS activated ?"
OPTIONS=(1 "Yes"
2 "No")
ldap_tls=$(dialog --title "$TITLE" \
--backtitle "$BACKTITLE" \
--MENU "$MENU"\
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
clear
else else
ldap_cn="cn=admin," ldap_cn="cn=admin,"
ldap_cn+=$ldap_dn ldap_cn+=$ldap_dn
ldap_host="localhost" ldap_host="localhost"
ldap_tls=2
fi fi
TITLE="Hôte pour l'envoi de mail"
BACKTITLE="Re2o preconfiguration of the mail server"
TITLE="Host of the mail server to use"
email_host=$(dialog --title "$TITLE" \ email_host=$(dialog --title "$TITLE" \
--backtitle "$BACKTITLE" \ --backtitle "$BACKTITLE" \
--inputbox "$TITLE" $HEIGHT $WIDTH \ --inputbox "$TITLE" \
$HEIGHT $WIDTH \
2>&1 >/dev/tty) 2>&1 >/dev/tty)
TITLE="Port du serveur mail" TITLE="Port of the mail server"
OPTIONS=(25 "25 (SMTP)" OPTIONS=(25 "SMTP"
465 "465 (SMTPS)" 465 "SMTPS"
587 "587 (Submission)") 587 "Submission")
email_port=$(dialog --clear \ email_port=$(dialog --clear \
--backtitle "$BACKTITLE" \ --backtitle "$BACKTITLE" \
@ -209,101 +225,100 @@ email_port=$(dialog --clear \
"${OPTIONS[@]}" \ "${OPTIONS[@]}" \
2>&1 >/dev/tty) 2>&1 >/dev/tty)
clear clear
if [ $ldap_is_local == 2 ]
then
TITLE="Cn ldap admin"
ldap_cn=$(dialog --title "$TITLE" \
--backtitle "$BACKTITLE" \
--inputbox "$TITLE" $HEIGHT $WIDTH \
2>&1 >/dev/tty)
clear
TITLE="Hote ldap"
ldap_host=$(dialog --title "$TITLE" \
--backtitle "$BACKTITLE" \
--inputbox "$TITLE" $HEIGHT $WIDTH \
2>&1 >/dev/tty)
clear
else
ldap_cn="cn=admin,"
ldap_cn+=$ldap_dn
ldap_host="localhost"
fi
HEIGHT=15
WIDTH=40
install_base=$(dialog --clear \ install_base=$(dialog --clear \
--title "Installation de Re2o !" \ --title "Re2o setup!" \
--msgbox "Installation des paquets de base" \ --msgbox "Installation des paquets de base" \
$HEIGHT $WIDTH \ $HEIGHT $WIDTH \
2>&1 >/dev/tty) 2>&1 >/dev/tty)
echo "Installation des paquets de base"
apt-get -y install python3-django python3-dateutil texlive-latex-base texlive-fonts-recommended python3-djangorestframework python3-django-reversion python3-pip libsasl2-dev libldap2-dev libssl-dev python3-crypto python3-git
pip3 install django-bootstrap3
pip3 install django-ldapdb==0.9.0
pip3 install django-macaddress
echo "Installation des paquets de base"
apt-get -y install python3-django python3-dateutil texlive-latex-base texlive-fonts-recommended python3-djangorestframework python3-django-reversion python3-pip libsasl2-dev libldap2-dev libssl-dev python3-crypto python3-git libjs-jquery libjs-jquery-uil libjs-jquery-timepicker libjs-bootstrap
pip3 install django-bootstrap3 django-ldapdb==0.9.0 django-macaddress
echo "SQL Database setup"
if [ $sql_bdd_type == 1 ] if [ $sql_bdd_type == 1 ]
then then
apt-get -y install python3-mysqldb mysql-client apt-get -y install python3-mysqldb mysql-client
mysql_command="CREATE DATABASE $sql_name collate='utf8_general_ci';
CREATE USER '$sql_login'@'localhost' IDENTIFIED BY '$sql_password';
GRANT ALL PRIVILEGES ON $sql_name.* TO '$sql_login'@'localhost';
FLUSH PRIVILEGES;"
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="$mysql_command" mysql -u root --execute="$mysql_command"
else else
echo "Veuillez saisir la commande suivante sur le serveur sql distant, puis validez" echo "Please execute the following command on the remote SQL server and then continue"
echo $mysql_command echo "$mysql_command"
while true; do while true
read -p "Continue (y/n)?" choice do
case "$choice" in read -p "Continue (y/n)?" choice
y|Y ) break;; case "$choice" in
n|N ) exit;; y|Y ) break;;
* ) echo "invalid";; n|N ) exit;;
esac * ) echo "Invalid";;
done esac
done
fi fi
else else
apt-get -y install postgresql-client apt-get -y install postgresql-client python3-psycopg2
apt-get -y install python3-psycopg2 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;"
if [ $sql_is_local == 1 ] if [ $sql_is_local == 1 ]
then then
apt-get -y install postgresql apt-get -y install postgresql
sudo -u postgres psql --command="$pgsql_command1" sudo -u postgres psql --command="$pgsql_command1"
sudo -u postgres psql --command="$pgsql_command2" sudo -u postgres psql --command="$pgsql_command2"
sudo -u postgres psql --command="$pgsql_command3" sudo -u postgres psql --command="$pgsql_command3"
else else
echo "Veuillez saisir la commande suivante sur le serveur sql distant, puis validez" 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_command1"
echo sudo -u postgres psql $pgsql_command2 echo "sudo -u postgres psql $pgsql_command2"
echo sudo -u postgres psql $pgsql_command3 echo "sudo -u postgres psql $pgsql_command3"
while true; do while true
read -p "Continue (y/n)?" choice do
case "$choice" in read -p "Continue (y/n)?" choice
y|Y ) break;; case "$choice" in
n|N ) exit;; y|Y ) break;;
* ) echo "invalid";; n|N ) exit;;
esac * ) echo "Invalid";;
done esac
done
fi fi
fi fi
echo "LDAP setup"
if [ $ldap_is_local == 1 ] if [ $ldap_is_local == 1 ]
then then
setup_ldap $ldap_password $ldap_dn
setup_ldap $ldap_password $ldap_dn
else else
TITLE="LDAP server setup"
HEIGHT=15 MSGBOX="Please manually setup the remote LDAP server by launching the following commands: ./install_re2o.sh ldap $ldap_password $ldap_dn"
WIDTH=40 ldap_setup=$(dialog --clear \
ldap_setup=$(dialog --clear \ --title "$TITLE" \
--title "Setup ldap" \ --msgbox "$MSGBOX" \
--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 \
$HEIGHT $WIDTH \ 2>&1 >/dev/tty)
2>&1 >/dev/tty)
fi 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)]))") 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)]))") 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 sed -i 's/db_engine/django.db.backends.postgresql_psycopg2/g' re2o/settings_local.py
fi 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/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/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_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_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/db_host_value/'"$sql_host"'/g' re2o/settings_local.py
sed -i 's/ldap_dn/'"$ldap_cn"'/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/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/ldap_host_ip/'"$ldap_host"'/g' re2o/settings_local.py
sed -i 's/dc=example,dc=org/'"$ldap_dn"'/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_HOST/'"$email_host"'/g' re2o/settings_local.py
sed -i 's/MY_EMAIL_PORT/'"$email_port"'/g' re2o/settings_local.py sed -i 's/MY_EMAIL_PORT/'"$email_port"'/g' re2o/settings_local.py
HEIGHT=15
WIDTH=40
TITLE="Django setup"
MSGBOX="Applying the Django database migrations"
migrations=$(dialog --clear \ migrations=$(dialog --clear \
--title "Setup django" \ --title "$TITLE" \
--msgbox "Application des migrations" \ --msgbox "$MSGBOX" \
$HEIGHT $WIDTH \ $HEIGHT $WIDTH \
2>&1 >/dev/tty) 2>&1 >/dev/tty)
python3 manage.py migrate python3 manage.py migrate
HEIGHT=15
WIDTH=40
TITLE="Django setup"
MSGBOX="Collecting statics"
static=$(dialog --clear \ static=$(dialog --clear \
--title "Setup django" \ --title "$TITLE" \
--msgbox "Collecte des statiques" \ --msgbox "$MSGBOX" \
$HEIGHT $WIDTH \ $HEIGHT $WIDTH \
2>&1 >/dev/tty) 2>&1 >/dev/tty)
python3 manage.py collectstatic python3 manage.py collectstatic
BACKTITLE="Fin de l'installation"
TITLE="Serveur web à utiliser"
BACKTITLE="Web server"
TITLE="Web server to use"
OPTIONS=(1 "apache2" OPTIONS=(1 "apache2"
2 "nginx") 2 "nginx")
@ -362,14 +394,15 @@ web_serveur=$(dialog --clear \
clear clear
TITLE="Url où servir le serveur web (ex : re2o.example.org). Assurez-vous que ce tld existe bien et répond auprès du DNS" TITLE="URL for accessing the web server (e.g. re2o.example.net). Be sure that this URL is accessible and correspond to a DNS entry if applicable."
url_server=$(dialog --title "$TITLE" \ url_server=$(dialog --title "$TITLE" \
--backtitle "$BACKTITLE" \ --backtitle "$BACKTITLE" \
--inputbox "$TITLE" $HEIGHT $WIDTH \ --inputbox "$TITLE" \
$HEIGHT $WIDTH \
2>&1 >/dev/tty) 2>&1 >/dev/tty)
clear clear
TITLE="Utiliser tls et générer automatiquement le certificat LE ?" TITLE="Activate TLS with Let'Encrypt on the web server ?"
OPTIONS=(1 "Oui" OPTIONS=(1 "Oui"
2 "Non") 2 "Non")
@ -385,72 +418,70 @@ clear
sed -i 's/URL_SERVER/'"$url_server"'/g' re2o/settings_local.py sed -i 's/URL_SERVER/'"$url_server"'/g' re2o/settings_local.py
if [ $web_serveur == 1 ] 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 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
apt-get -y install certbot apt-get -y install certbot
apt-get -y install python-certbot-apache apt-get -y install python-certbot-apache
certbot certonly --rsa-key-size 4096 --apache -d $url_server certbot certonly --rsa-key-size 4096 --apache -d $url_server
sed -i 's/LE_PATH/'"$url_server"'/g' /etc/apache2/sites-available/re2o.conf sed -i 's/LE_PATH/'"$url_server"'/g' /etc/apache2/sites-available/re2o.conf
else
cp install_utils/apache2/re2o.conf /etc/apache2/sites-available/re2o.conf
fi
rm /etc/apache2/sites-enabled/000-default.conf
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 else
cp install_utils/apache2/re2o.conf /etc/apache2/sites-available/re2o.conf TITLE="Web server setup"
fi MSGBOX="Nginx non supporté, vous devrez installer manuellement"
rm /etc/apache2/sites-enabled/000-default.conf web_server=$(dialog --clear \
sed -i 's|URL_SERVER|'"$url_server"'|g' /etc/apache2/sites-available/re2o.conf --title "$TITLE" \
current_path=$(pwd) --msgbox "$MSGBOX" \
sed -i 's|PATH|'"$current_path"'|g' /etc/apache2/sites-available/re2o.conf $HEIGHT $WIDTH \
a2ensite re2o 2>&1 >/dev/tty)
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)
fi fi
python3 manage.py createsuperuser 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 \ 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" \ --msgbox "Vous pouvez à présent vous rendre sur $url_server, et vous connecter. Votre utilisateur dispose des privilèges superuser" \
$HEIGHT $WIDTH \ $HEIGHT $WIDTH \
2>&1 >/dev/tty) 2>&1 >/dev/tty)
} }
apt install libjs-jquery
apt install libjs-jquery-ui
apt install libjs-jquery-timepicker
apt install libjs-bootstrap
main_function() { main_function() {
if [ ! -z "$1" ] if [ ! -z "$1" ]
then then
if [ $1 == ldap ] if [ $1 == ldap ]
then then
if [ ! -z "$2" ] if [ ! -z "$2" ]
then then
echo Installation du ldap echo Installation du ldap
setup_ldap $2 $3 setup_ldap $2 $3
else else
echo Arguments invalides ! echo Arguments invalides !
exit exit
fi fi
fi fi
else else
install_re2o_server install_re2o_server
fi fi
} }
main_function $1 $2 $3 main_function $1 $2 $3