install_re2o.sh 21 KB
Newer Older
1
#!/bin/bash
2 3

setup_ldap() {
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
    ### Usage: setup_ldap <ldap_password> <local_domain>
    #
    #   This function is used to setup the LDAP structure based on the ldiff files
    #   located in 'install_utils/'. It will delete the previous structure and data
    #   and recreate a new empty one.
    #   
    #   Parameters:
    #     * ldap_password: the clear password for the admin user of the LDAP
    #     * local_domain: the domain extension to use for the LDAP structure in LDAP notation
    ###

    apt-get -y install slapd

    echo "Hashing the LDAP password ..."
    hashed_ldap_passwd=$(slappasswd -s $1)
    echo "Hash of the password: $hashed_ldap_passwd"

    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/schema.ldiff | sed 's|FILL_IT|'"$hashed_ldap_passwd"'|g' > /tmp/schema
    echo "Building the LDAP config files: Done"

    echo "Stopping slapd service ..."
    service slapd stop
    echo "Stopping slapd service: Done"

    echo "Deleting exisitng LDAP configuration ..."
    rm -rf /etc/ldap/slapd.d/*
    rm -rf /var/lib/ldap/*
    echo "Deleting existing LDAP configuration: Done"

    echo "Setting up the new LDAP configuration ..."
    slapadd -n 0 -l /tmp/schema -F /etc/ldap/slapd.d/
    slapadd -n 1 -l /tmp/db
    echo "Setting up the new LDAP configuration: Done"

    echo "Fixing the LDAP files permissions ..."
    chown -R openldap:openldap /etc/ldap/slapd.d
    chown -R openldap:openldap /var/lib/ldap
    echo "Fixing the LDAP files permissions: Done"

    echo "Starting slapd service ..."
    service slapd start
    echo "Starting slapd service: Done"
48 49 50 51
}


install_re2o_server() {
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
    ### Usage: install_re2o_server
    #
    #   This function will guide through the automated setup of Re2o by asking
    #   the user for some informations and some installation choices. It will
    #   then proceed to setup and configuration of the required tools according
    #   to the user choices.
    ###

    echo "Re2o setup !"
    echo "This tool will help you setup re2o. It is highly recommended to use a Debian clean server for this operation."

    echo "Installing basic packages required for this script to work  ..."
    apt-get -y install sudo dialog
    echo "Installing basic packages required for this script to work: Done"

    # Common setup for the dialog prompts
    export DEBIAN_FRONTEND=noninteractive
69 70
    HEIGHT=20
    WIDTH=60
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
    CHOICE_HEIGHT=4



    #############
    ## Welcome ##
    #############

    BACKTITLE="Re2o setup"

    # Welcome prompt
    TITLE="Welcome"
    MSGBOX="This tool will help you setup re2o. It is highly recommended to use a Debian clean server for this operation."
    init=$(dialog --clear --backtitle "$BACKTITLE" \
        --title "$TITLE" --msgbox "$MSGBOX" \
        $HEIGHT $WIDTH 2>&1 >/dev/tty)



    ######################
    ## Database options ##
    ######################

    BACKTITLE="Re2o setup - configuration of the database"

    # Prompt for choosing the database engine
    TITLE="Database engine"
    MENU="Which engine should be used as the database ?"
    OPTIONS=(1 "mysql"
             2 "postgresql")
    sql_bdd_type=$(dialog --clear --backtitle "$BACKTITLE" \
        --title "$TITLE" --menu "$MENU" \
        $HEIGHT $WIDTH $CHOICE_HEIGHT "${OPTIONS[@]}" 2>&1 >/dev/tty)

    # Prompt for choosing the database location
    TITLE="SQL location"
    MENU="Where to install the SQL database ?
    * 'Local' will setup everything automatically but is not recommended for production
109
    * 'Remote' will ask you to manually perform some setup commands on the remote server"
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
    OPTIONS=(1 "Local"
             2 "Remote")
    sql_is_local=$(dialog --clear --backtitle "$BACKTITLE" \
        --title "$TITLE" --menu "$MENU" \
        $HEIGHT $WIDTH $CHOICE_HEIGHT "${OPTIONS[@]}" 2>&1 >/dev/tty)

    if [ $sql_is_local == 2 ]; then
        # Prompt to enter the remote database hostname
        TITLE="SQL hostname"
        INPUTBOX="The hostname of the remote SQL database"
        sql_host=$(dialog --clear --backtitle "$BACKTITLE" \
            --title "$TITLE" --inputbox "$INPUTBOX" \
            $HEIGHT $WIDTH 2>&1 >/dev/tty)
        
        # Prompt to enter the remote database name
        TITLE="SQL database name"
        INPUTBOX="The name of the remote SQL database"
        sql_name=$(dialog --clear --backtitle "$BACKTITLE" \
            --title "$TITLE" --inputbox "$INPUTBOX" \
            $HEIGHT $WIDTH 2>&1 >/dev/tty)

        # Prompt to enter the remote database username
        TITLE="SQL username"
        INPUTBOX="The username to access the remote SQL database"
        sql_login=$(dialog --clear --backtitle "$BACKTITLE" \
            --title "$TITLE" --inputbox "$INPUTBOX" \
            $HEIGHT $WIDTH 2>&1 >/dev/tty)
        clear
    else
        # Use of default values for local setup
        sql_name="re2o"
        sql_login="re2o"
        sql_host="localhost"
    fi
144

145 146 147
    # Prompt to enter the database password
    TITLE="SQL password"
    INPUTBOX="The password to access the SQL database"
148
    sql_password=$(dialog --clear --backtitle "$BACKTITLE" \
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
        --title "$TITLE" --inputbox "$INPUTBOX" \
        $HEIGHT $WIDTH 2>&1 >/dev/tty)



    ##############################
    ## Active directory options ##
    ##############################

    BACKTITLE="Re2o setup - configuration of the active directory"

    # Prompt to choose the LDAP location
    TITLE="LDAP location"
    MENU="Where would you like to install the LDAP ?
    * 'Local' will setup everything automatically but is not recommended for production
164
    * 'Remote' will ask you to manually perform some setup commands on the remote server"
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
    OPTIONS=(1 "Local"
             2 "Remote")
    ldap_is_local=$(dialog --clear --backtitle "$BACKTITLE" \
        --title "$TITLE" --menu "$MENU" \
        $HEIGHT $WIDTH $CHOICE_HEIGHT "${OPTIONS[@]}" 2>&1 >/dev/tty)
    
    # Prompt to enter the LDAP domain extension
    TITLE="Domain extension"
    INPUTBOX="The local domain extension to use (e.g. 'example.net'). This is used in the LDAP configuration."
    extension_locale=$(dialog --clear --backtitle "$BACKTITLE" \
        --title "$TITLE" --inputbox "$INPUTBOX" \
        $HEIGHT $WIDTH 2>&1 >/dev/tty)
    
    # Building the DN of the LDAP from the extension
    IFS='.' read -a extension_locale_array <<< $extension_locale
    for i in "${extension_locale_array[@]}"
    do
        ldap_dn+="dc=$i,"
    done
    ldap_dn=${ldap_dn::-1}

    if [ $ldap_is_local == 2 ]; then
        # Prompt to enter the remote LDAP hostname
        TITLE="LDAP hostname"
        INPUTBOX="The hostname of the remote LDAP"
        ldap_host=$(dialog --clear --backtitle "$BACKTITLE" \
            --title "$TITLE" --inputbox "$INPUTBOX" \
            $HEIGHT $WIDTH 2>&1 >/dev/tty)
        
        # Prompt to choose if TLS should be activated or not for the LDAP
        TITLE="TLS on LDAP"
        MENU="Would you like to activate TLS for communicating with the remote LDAP ?"
        OPTIONS=(1 "Yes"
                 2 "No")
        ldap_tls=$(dialog --clear --backtitle "$BACKTITLE" \
            --title "$TITLE" --MENU "$MENU" \
            $HEIGHT $WIDTH $CHOICE_HEIGHT "${OPTIONS[@]}" 2>&1 >/dev/tty)

        # Prompt to enter the admin's CN of the remote LDAP
        TITLE="CN of amdin user"
        INPUTBOX="The CN entry for the admin user of the remote LDAP"
        ldap_cn=$(dialog --clear --backtitle "$BACKTITLE" \
            --title "$TITLE" --inputbox "$INPUTBOX" \
            $HEIGHT $WIDTH 2>&1 >/dev/tty)
    else
        ldap_cn="cn=admin,"
        ldap_cn+=$ldap_dn
        ldap_host="localhost"
        ldap_tls=2
    fi
215

216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
    # Prompt to enter the LDAP password
    TITLE="LDAP password"
    INPUTBOX="The password to access the LDAP"
    ldap_password=$(dialog --clear --backtitle "$BACKTITLE" \
        --title "$TITLE" --inputbox "$INPUTBOX" \
        $HEIGHT $WIDTH 2>&1 >/dev/tty)



    #########################
    ## Mail server options ##
    #########################

    BACKTITLE="Re2o setup - configuration of the mail server"
    
    # Prompt to enter the hostname of the mail server
    TITLE="Mail server hostname"
    INPUTBOX="The hostname of the mail server to use"
    email_host=$(dialog --clear --backtitle "$BACKTITLE" \
        --title "$TITLE" --inputbox "$TITLE" \
        $HEIGHT $WIDTH 2>&1 >/dev/tty)

    # Prompt to choose the port of the mail server    
    TITLE="Mail server port"
    MENU="Which port (thus which protocol) to use to contact the mail server"
    OPTIONS=(25 "SMTP"
             465 "SMTPS"
             587 "Submission")
    email_port=$(dialog --clear --backtitle "$BACKTITLE" \
        --title "$TITLE" --menu "$MENU" \
        $HEIGHT $WIDTH $CHOICE_HEIGHT "${OPTIONS[@]}" 2>&1 >/dev/tty)



    ########################
    ## Web server options ##
    ########################

    BACKTITLE="Re2o setup - configuration of the web server"
    
    # Prompt to choose the web server
    TITLE="Web server to use"
    MENU="Which web server to install for accessing Re2o web frontend (automatic setup of nginx is not supported) ?"
    OPTIONS=(1 "apache2"
             2 "nginx")
    web_serveur=$(dialog --clear --backtitle "$BACKTITLE" \
        --title "$TITLE" --menu "$MENU" \
        $HEIGHT $WIDTH $CHOICE_HEIGHT "${OPTIONS[@]}" 2>&1 >/dev/tty)
    
    # Prompt to enter the requested URL for the web frontend
    TITLE="Web URL"
    INPUTBOX="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 --clear --backtitle "$BACKTITLE" \
        --title "$TITLE" --inputbox "$INPUTBOX" \
        $HEIGHT $WIDTH 2>&1 >/dev/tty)
    
    # Prompt to choose if the TLS should be setup or not for the web server
    TITLE="TLS on web server"
    MENU="Would you like to activate the TLS (with Let'Encrypt) on the web server ?"
    OPTIONS=(1 "Yes"
             2 "No")
    is_tls=$(dialog --clear --backtitle "$BACKTITLE" \
        --title "$TITLE" --menu "$MENU" \
        $HEIGHT $WIDTH $CHOICE_HEIGHT "${OPTIONS[@]}" 2>&1 >/dev/tty)
280 281


282

283 284 285
    ###############################
    ## End of configuration step ##
    ###############################
286

287
    BACKTITLE="Re2o setup"
288

289 290 291 292 293 294 295 296 297 298 299 300 301 302
    # Prompt to inform the config setup is over
    TITLE="End of configuration step"
    MSGBOX="The configuration step is now finished. The script will now perform the following actions:
    * Install the required packages
    * Install and setup the requested database if 'local' has been selected
    * Install and setup the ldap if 'local' has been selected
    * Write a local version of 'settings_local.py' file with the previously given informations
    * Apply the Django migrations for the project
    * Collect the statics for the web interface
    * Install and setup the requested web server
    * Install and setup a TLS certificate for the web server if requested"
    end_config=$(dialog --clear --backtitle "$BACKTITLE" \
        --title "$TITLE" --msgbox "$MSGBOX" \
        $HEIGHT $WIDTH 2>&1 >/dev/tty)
303

304
    clear
305

306

307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
    ###############################
    ## Install required packages ##
    ###############################

    echo "Setting up the required packages ..."
    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 \
325
        libjs-jquery-ui \
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366
        libjs-jquery-timepicker \
        libjs-bootstrap
    pip3 install django-bootstrap3 django-ldapdb==0.9.0 django-macaddress
    echo "Setting up the required packages: Done"



    ####################
    ## Setup database ##
    ####################

    echo "Setting up the database ..."

    if [ $sql_bdd_type == 1 ]; then

        echo "Installing MySQL client ..."
        apt-get -y install python3-mysqldb mysql-client
        echo "Installing MySQL client: Done"

        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 ]; then
            echo "Setting up local MySQL server ..."
            apt-get -y install mysql-server
            mysql -u root --execute="$mysql_command"
            echo "Setting up local MySQL server: Done"
        else
            echo "Please execute the following command on the remote SQL server and then continue"
            echo "$mysql_command"
            while true; do
                read -p "Continue (y/n)?" choice
                case "$choice" in
                    y|Y ) break;;
                    n|N ) exit;;
                    * ) echo "Invalid";;
                esac
            done
        fi
367

368
    else
369

370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398
        echo "Installing PostgreSQL client ..."
        apt-get -y install postgresql-client python3-psycopg2
        echo "Installing PostgreSQL client: Done"

        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 ]; then
            echo "Setting up local 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"
            echo "Setting up local PostgreSQL server: Done"
        else
            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
399

400
    fi
401

402
    echo "Setting up the database: Done"
403 404 405



406 407 408
    ############################
    ## Setup active directory ##
    ############################
Gabriel Detraz's avatar
Gabriel Detraz committed
409

410
    echo "Setting up the active direcory ..."
411

412
    if [ $ldap_is_local == 1 ]; then
413

414 415 416
        echo "Setting up local active directory ..."
        setup_ldap $ldap_password $ldap_dn
        echo "Setting up local active directory: Done"
417

Gabriel Detraz's avatar
Gabriel Detraz committed
418
    else
419 420 421 422

        echo "Please execute the following command on the remote LDAP server and then continue"
        echo "./install_re2o.sh ldap $ldap_password $ldap_dn"
        while true; do
423 424 425 426 427 428 429
            read -p "Continue (y/n)?" choice
            case "$choice" in
                y|Y ) break;;
                n|N ) exit;;
                * ) echo "Invalid";;
            esac
        done
430

Gabriel Detraz's avatar
Gabriel Detraz committed
431 432
    fi

433
    echo "Setting up the active directory: Done"
434 435 436



437 438 439
    ###################################
    ## Setup settings_locale.py file ##
    ###################################
440

441
    echo "Writing of the settings_local.py file ..."
Gabriel Detraz's avatar
Gabriel Detraz committed
442

443 444 445 446
    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)]))")
    
    cp re2o/settings_local.example.py re2o/settings_local.py
Gabriel Detraz's avatar
Gabriel Detraz committed
447

448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469
    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_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
    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' re2o/settings_local.py
470

471
    echo "Writing of the settings_local.py file: Done"
Gabriel Detraz's avatar
Gabriel Detraz committed
472

473

Gabriel Detraz's avatar
Gabriel Detraz committed
474

475 476 477
    #############################
    ## Apply Django migrations ##
    #############################
Gabriel Detraz's avatar
Gabriel Detraz committed
478

479 480 481
    echo "Applying Django migrations ..."
    python3 manage.py migrate
    echo "Applying Django migrations: Done"
Gabriel Detraz's avatar
Gabriel Detraz committed
482

483 484


485 486 487
    ######################
    ## Create superuser ##
    ######################
488

489 490 491
    echo "Creating a superuser ..."
    python3 manage.py createsuperuser
    echo "Creating a superuser: Done"
492

493

494

495 496 497
    ##################################
    ## Collect web frontend statics ##
    ##################################
498

499 500 501
    echo "Collecting web frontend statics ..."
    python3 manage.py collectstatic
    echo "Collecting web frontend statics: Done"
502 503 504



505 506 507
    #######################
    ## Set up web server ##
    #######################
508

509 510
    echo "Setting up web server ..."
    if [ $web_serveur == 1 ]; then
511

512
        echo "Setting up Apache2 web server ..."
513

514 515 516
        apt-get -y install apache2 libapache2-mod-wsgi-py3
        a2enmod ssl
        a2enmod wsgi
517

518 519 520 521 522 523 524 525 526 527 528
        if [ $is_tls == 1 ]; then
            echo "Setting up TLS with LE for Apache2 web server ..."
            cp install_utils/apache2/re2o-tls.conf /etc/apache2/sites-available/re2o.conf
            apt-get -y install certbot
            apt-get -y install python-certbot-apache
            certbot certonly --rsa-key-size 4096 --apache -d $url_server
            sed -i 's/LE_PATH/'"$url_server"'/g' /etc/apache2/sites-available/re2o.conf
            echo "Setting up TLS with LE for Apache2 web server: Done"
        else
            cp install_utils/apache2/re2o.conf /etc/apache2/sites-available/re2o.conf
        fi
529

530 531 532 533 534
        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
535

536
        echo "Setting up Apache2 web server: Done"
537

538 539 540
        echo "Reloading Apache2 service ..."
        service apache2 reload
        echo "Reloading Apache2 service: Done"
541

542
    else
543 544 545 546 547 548 549 550 551 552 553 554

        echo "Nginx automatic setup is not supported. Please configure it manually."
        echo "Please onfirm you have acknowledged this message."
        while true; do
            read -p "Acknowledged (y/n)?" choice
            case "$choice" in
                y|Y ) break;;
                n|N ) exit;;
                * ) echo "Invalid";;
            esac
        done

555
    fi
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570



    ###########################
    ## End of the setup step ##
    ###########################

    BACKTITLE="Re2o setup"

    # Prompt to inform the installation process is over
    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 --BACKTITLE "$BACKTITLE"\
        --title "$TITLE" --msgbox "$MSGBOX" \
        $HEIGHT $WIDTH 2>&1 >/dev/tty)
571 572
}

573

574
main_function() {
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589
    ### Usage: main_function [ldap <ldap_password> [<local_domain>]]
    #
    #   This function will parse the arguments to determine which part of the tool to start.
    #   If launched with no arguments, the full setup guide will be started.
    #   If launched with the 'ldap' argument, only the ldap setup will performed.
    #
    #   Parameters:
    #     * ldap_password: the clear password for the admin user of the LDAP
    #     * local_domain: the domain extension to use for the LDAP structure in LDAP notation
    ###

    if [ ! -z "$1" ]; then
        if [ $1 == ldap ]; then
            if [ ! -z "$2" ]; then
                echo "Setting up local active directory ..."
590
                setup_ldap $2 $3
591
                echo "Setting up local active directory: Done"
592
            else
593
                echo "Arguments invalides !"
594
                echo "Usage: ./install_re2o.sh [ldap <ldap_password> [<local_domain>]]"
595 596 597 598 599 600
                exit
            fi
        fi
    else
        install_re2o_server
    fi
601 602 603
}

main_function $1 $2 $3