#!/bin/bash
. /usr/lib/eole/ihm.sh

NETLOGON="/home/netlogon/infosquota"
DOMAINUSERS="/home/netlogon/scripts/groups/DomainUsers.txt"

if [ ! -f "$NETLOGON/infosquota.ini" ];then
    # mise en place de la configuation initiale
    cp "$NETLOGON/infosquota.ini.sample" "$NETLOGON/infosquota.ini"
fi

grep -q infosquota.exe $DOMAINUSERS 2>/dev/null
if [ $? -ne 0 ];then
    echo "Mise en place de la commande infosquota dans DomainUsers.txt"
    echo "cmd,\\\\$(CreoleGet adresse_ip_eth0)\\netlogon\\infosquota\\infosquota.exe,NOWAIT" >> $DOMAINUSERS
fi

if [ ! -f /var/log/infosquota/recherche-fich-users.log ];then
    echo  "Première exécution de infosquota2"
    EchoOrange "Lancement de la recherche, "
    EchoOrange "veuillez patienter quelques minutes."
    EchoOrange "Merci ..."
    /etc/cron.weekly/findfic
    if [ $? -ne 0 ] ; then
        EchoRouge "Problème lors de l'exécution de /etc/cron.weekly/findfic"
    fi
fi

exit 0
