#!/bin/bash
dirn=$(CreoleGet container_path_proxy)/var/lib/eole/
if [ ! -d $dirn ]; then
    mkdir -p $dirn
fi
if [ "$1" = "instance" ];then
    . /usr/lib/eole/ihm.sh
    #enregistrement au domaine dans le cas du NTLM
    if [[ "$(CreoleGet type_squid_auth aucun)" =~ 'NTLM' ]]; then
        PRIVATE_DIR="$(CreoleGet container_path_domaine /)/etc/eole/private"
        PASSWORD_FILE="${PRIVATE_DIR}/eole-seth-education.password"
        if [ -f "$PASSWORD_FILE" ]; then
            CreoleRun "/usr/bin/wbinfo -t" proxy &>/dev/null && enregistrement="non" || enregistrement="oui"
        else
            Question_ouinon "Voulez-vous (ré)intégrer le serveur au domaine maintenant ?" "True" "oui"
            if [ $? -eq 0 ];then
                enregistrement="oui"
            fi
        fi
        if [ "$enregistrement" = "oui" ]; then
            /usr/share/eole/sbin/enregistrement_domaine.sh
            [ $? -ne 0 ] && exit 1
        fi
    fi
    echo
    if [ ! "$2" = "restauration" ]; then
        if [ $(CreoleGet activer_filtrage_proxy) = 'oui' ];then
            Question_ouinon "Voulez-vous mettre à jour les bases de filtrage maintenant ?" 'True' "oui"
            if [ $? -eq 0 ];then
                /usr/share/eole/sbin/Maj-blacklist.sh
            fi
            echo
        fi
        if [ $(CreoleGet proxy_download_bypass non) = 'oui' ];then
            Question_ouinon "Voulez-vous mettre à jour les bases des exceptions maintenant ?" 'True' "oui"
            if [ $? -eq 0 ];then
                /usr/share/eole/sbin/Maj-exceptions.sh
            fi
            echo
        fi
    fi
fi
exit 0
